---------------------------------------------------------------------------------

       log:  C:\AAA Miker Files\newer web pages\soc_388_notes\soc_388_2007\cla

> ss_18_log.log

  log type:  text

 opened on:  29 Nov 2007, 10:56:32

 

. table color labor, contents(sum uwcount sum wncount mean weight) by(sex)

 

----------------------------------------------

sex and   |               labor              

color     | unemployed   part-time       other

----------+-----------------------------------

male      |

    white |       3511        4227       31467

          |       3530        4183       31131

          |       1431        1408        1408

          |

    black |        604         356        2245

          |        815         462        2783

          |       1921        1849        1764

          |

    other |        165         157         924

          |        119         124         797

          |       1029        1124        1228

----------+-----------------------------------

female    |

    white |       2281        7833       18945

          |       2234        7559       18704

          |       1394        1373        1405

          |

    black |        545         563        2132

          |        653         644        2498

          |       1705        1627        1668

          |

    other |         89         216         725

          |         64         162         574

          |       1029        1070        1127

----------------------------------------------

 

. table color labor, contents(sum uwcount sum wncount mean weight) by(sex)

 

----------------------------------------------

sex and   |               labor              

color     | unemployed   part-time       other

----------+-----------------------------------

male      |

    white |       3511        4227       31467

          |       3530        4183       31131

          |       1431        1408        1408

          |

    black |        604         356        2245

          |        815         462        2783

          |       1921        1849        1764

          |

    other |        165         157         924

          |        119         124         797

          |       1029        1124        1228

----------+-----------------------------------

female    |

    white |       2281        7833       18945

          |       2234        7559       18704

          |       1394        1373        1405

          |

    black |        545         563        2132

          |        653         644        2498

          |       1705        1627        1668

          |

    other |         89         216         725

          |         64         162         574

          |       1029        1070        1127

----------------------------------------------

 

. *I am going to run some loglinear models to immitate what Clogg and Eliason do in their Table 6

. desmat: poisson  uwcount labor*sex=dev(3)*dev(2) color*labor=dev(3)*dev(3) color*sex=dev(3)*dev(2)

--------------------------------------------------------------------------------

   Poisson regression

--------------------------------------------------------------------------------

   Dependent variable                                                   uwcount

   Optimization:                                                             ml

   Number of observations:                                                   18

   Initial log likelihood:                                           -81627.074

   Log likelihood:                                                     -123.390

   LR chi square:                                                    163007.367

   Model degrees of freedom:                                                 13

   Pseudo R-squared:                                                      0.998

   Prob:                                                                  0.000

--------------------------------------------------------------------------------

nr Effect                                                     Coeff        s.e.

--------------------------------------------------------------------------------

   uwcount

     labor

1      unemployed                                            -0.677**     0.018

2      part-time                                             -0.433**     0.017

     sex

3      male                                                  -0.018*      0.009

     labor.sex

4      unemployed.male                                        0.161**     0.009

5      part-time.male                                        -0.347**     0.007

     color

6      white                                                  1.852**     0.011

7      black                                                 -0.364**     0.014

     color.labor

8      white.unemployed                                      -0.282**     0.018

9      white.part-time                                        0.193**     0.017

10     black.unemployed                                       0.340**     0.022

11     black.part-time                                       -0.229**     0.022

     color.sex

12     white.male                                             0.080**     0.009

13     black.male                                            -0.097**     0.011

14   _cons                                                    7.053**     0.011

--------------------------------------------------------------------------------

*  p < .05

** p < .01

 

. poisgof

 

         Goodness-of-fit chi2  =  86.53056

         Prob > chi2(4)        =    0.0000

 

. poisgof, pearson

 

         Goodness-of-fit chi2  =  89.79915

         Prob > chi2(4)        =    0.0000

 

. *This is clogg and Eliason's model 1, ignoring the weights.

. desrep, z

option z not allowed

r(198);

 

. desrep, zscore

option zscore not allowed

r(198);

 

. desrep, zval

--------------------------------------------------------------------------------

   Poisson regression

--------------------------------------------------------------------------------

   Dependent variable                                                   uwcount

   Optimization:                                                             ml

   Number of observations:                                                   18

   Initial log likelihood:                                           -81627.074

   Log likelihood:                                                     -123.390

   LR chi square:                                                    163007.367

   Model degrees of freedom:                                                 13

   Pseudo R-squared:                                                      0.998

   Prob:                                                                  0.000

--------------------------------------------------------------------------------

nr Effect                                           Coeff        s.e.       z 

--------------------------------------------------------------------------------

   uwcount

     labor

1      unemployed                                  -0.677**     0.018   -38.575

2      part-time                                   -0.433**     0.017   -26.205

     sex

3      male                                        -0.018*      0.009    -2.004

     labor.sex

4      unemployed.male                              0.161**     0.009    18.482

5      part-time.male                              -0.347**     0.007   -46.843

     color

6      white                                        1.852**     0.011   162.348

7      black                                       -0.364**     0.014   -25.659

     color.labor

8      white.unemployed                            -0.282**     0.018   -15.386

9      white.part-time                              0.193**     0.017    11.300

10     black.unemployed                             0.340**     0.022    15.425

11     black.part-time                             -0.229**     0.022   -10.465

     color.sex

12     white.male                                   0.080**     0.009     9.162

13     black.male                                  -0.097**     0.011    -8.679

14   _cons                                          7.053**     0.011   640.281

--------------------------------------------------------------------------------

*  p < .05

** p < .01

 

. *Now the crazy one.

. gen crazy_wt_count= uwcount*weight

 

. desmat: poisson   crazy_wt_count  labor*sex=dev(3)*dev(2) color*labor=dev(3)*dev(3) color*sex=dev(3)*dev(2)

--------------------------------------------------------------------------------

   Poisson regression

--------------------------------------------------------------------------------

   Dependent variable                                            crazy_wt_count

   Optimization:                                                             ml

   Number of observations:                                                   18

   Initial log likelihood:                                           -1.137e+08

   Log likelihood:                                                   -71806.645

   LR chi square:                                                     2.273e+08

   Model degrees of freedom:                                                 13

   Pseudo R-squared:                                                      0.999

   Prob:                                                                  0.000

--------------------------------------------------------------------------------

nr Effect                                                     Coeff        s.e.

--------------------------------------------------------------------------------

   crazy_wt_count

     labor

1      unemployed                                            -0.689**     0.001

2      part-time                                             -0.435**     0.000

     sex

3      male                                                   0.013**     0.000

     labor.sex

4      unemployed.male                                        0.165**     0.000

5      part-time.male                                        -0.340**     0.000

     color

6      white                                                  1.858**     0.000

7      black                                                 -0.133**     0.000

     color.labor

8      white.unemployed                                      -0.263**     0.001

9      white.part-time                                        0.186**     0.000

10     black.unemployed                                       0.383**     0.001

11     black.part-time                                       -0.231**     0.001

     color.sex

12     white.male                                             0.059**     0.000

13     black.male                                            -0.083**     0.000

14   _cons                                                   14.294**     0.000

--------------------------------------------------------------------------------

*  p < .05

** p < .01

 

. poisgof

 

         Goodness-of-fit chi2  =  143357.3

         Prob > chi2(4)        =    0.0000

 

. poisgof, pearson

 

         Goodness-of-fit chi2  =  148750.5

         Prob > chi2(4)        =    0.0000

 

. *OK, crazy model has correct coefficients but unbelievably small SE and wildly large goodness of fit, because we have basically multiplied all counts by 1500

. *let's put that model behind us.

. *The next reasonable approach, is to normalize the weights. Actually, the weighted counts provided by Clogg and Eliason already do this.

. *C+E's weighted counts are already normalized...

. desmat: poisson  wncount labor*sex=dev(3)*dev(2) color*labor=dev(3)*dev(3) color*sex=dev(3)*dev(2)

--------------------------------------------------------------------------------

   Poisson regression

--------------------------------------------------------------------------------

   Dependent variable                                                   wncount

   Optimization:                                                             ml

   Number of observations:                                                   18

   Initial log likelihood:                                           -79982.751

   Log likelihood:                                                     -130.057

   LR chi square:                                                    159705.387

   Model degrees of freedom:                                                 13

   Pseudo R-squared:                                                      0.998

   Prob:                                                                  0.000

--------------------------------------------------------------------------------

nr Effect                                                     Coeff        s.e.

--------------------------------------------------------------------------------

   wncount

     labor

1      unemployed                                            -0.690**     0.020

2      part-time                                             -0.435**     0.018

     sex

3      male                                                   0.013       0.010

     labor.sex

4      unemployed.male                                        0.165**     0.009

5      part-time.male                                        -0.340**     0.007

     color

6      white                                                  1.858**     0.012

7      black                                                 -0.133**     0.015

     color.labor

8      white.unemployed                                      -0.263**     0.020

9      white.part-time                                        0.186**     0.018

10     black.unemployed                                       0.384**     0.023

11     black.part-time                                       -0.232**     0.022

     color.sex

12     white.male                                             0.059**     0.009

13     black.male                                            -0.083**     0.011

14   _cons                                                    7.033**     0.012

--------------------------------------------------------------------------------

*  p < .05

** p < .01

 

. poisgof

 

         Goodness-of-fit chi2  =  100.2395

         Prob > chi2(4)        =    0.0000

 

. poisgof, pearson

 

         Goodness-of-fit chi2  =  104.0537

         Prob > chi2(4)        =    0.0000

 

. *This is clogg and eliason's model 2, using the normalized weights.

. *changing the dataset by a factor leaves the coefficients the same, but makes the SE and fit statistics reasonable again.

. *The way to do C+E's recommended weighting scheme in Stata, is to use the exposure function, which is also relevant to log-rate models, that is it is supposed to correct for the different exposure of each cell.

. gen inv_weight=1/weight

 

. desmat: poisson   uwcount labor*sex=dev(3)*dev(2) color*labor=dev(3)*dev(3) color*sex=dev(3)*dev(2), exposure( inv_weight)

--------------------------------------------------------------------------------

   Poisson regression

--------------------------------------------------------------------------------

   Dependent variable                                                   uwcount

   Optimization:                                                             ml

   Number of observations:                                                   18

   Initial log likelihood:                                           -84619.027

   Log likelihood:                                                     -124.919

   LR chi square:                                                    168988.216

   Model degrees of freedom:                                                 13

   Pseudo R-squared:                                                      0.999

   Prob:                                                                  0.000

--------------------------------------------------------------------------------

nr Effect                                                     Coeff        s.e.

--------------------------------------------------------------------------------

   uwcount

     labor

1      unemployed                                            -0.688**     0.018

2      part-time                                             -0.440**     0.017

     sex

3      male                                                   0.013       0.009

     labor.sex

4      unemployed.male                                        0.166**     0.009

5      part-time.male                                        -0.343**     0.007

     color

6      white                                                  1.860**     0.011

7      black                                                 -0.136**     0.014

     color.labor

8      white.unemployed                                      -0.265**     0.018

9      white.part-time                                        0.191**     0.017

10     black.unemployed                                       0.386**     0.022

11     black.part-time                                       -0.238**     0.022

     color.sex

12     white.male                                             0.058**     0.009

13     black.male                                            -0.085**     0.011

14   _cons                                                   14.292**     0.011

     ln(inv_weight)                                                    (offset)

--------------------------------------------------------------------------------

*  p < .05

** p < .01

 

. poisgof

 

         Goodness-of-fit chi2  =  89.58815

         Prob > chi2(4)        =    0.0000

 

. poisgof, pearson

 

         Goodness-of-fit chi2  =  93.54537

         Prob > chi2(4)        =    0.0000

 

. *This is C+E's model 3, their correct approved procedure, using the unweighted counts and the inverse weights as exposure.

. *note that the coefficients are the same as all the weighted models.

. *This model, Model 3, also has the same standard errors as M1, which ignored the weights.

. *Take away message: the proper coefficients take the weights into account. The proper SE are unaffected by the weights.

. log close

       log:  C:\AAA Miker Files\newer web pages\soc_388_notes\soc_388_2007\class

> _18_log.log

  log type:  text

 closed on:  29 Nov 2007, 12:09:07

--------------------------------------------------------------------------------