-------------------------------------------------------------------------------
       log:  C:\AAA Miker Files\newer web pages\soc_388_notes\soc_388_2003\clas
> s 4.smcl
  log type:  smcl
 opened on:   8 Oct 2003, 11:29:26
 
. set linesize 79
 
. edit
(3 vars, 16 obs pasted into editor)
- preserve
 
. poisson count
 
Iteration 0:   log likelihood = -221501.22  
Iteration 1:   log likelihood = -221501.22  
 
Poisson regression                                Number of obs   =         16
                                                  LR chi2(0)      =      -0.00
                                                  Prob > chi2     =          .
Log likelihood = -221501.22                       Pseudo R2       =    -0.0000
 
------------------------------------------------------------------------------
       count |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _cons |   10.39578   .0013821  7521.99   0.000     10.39308    10.39849
------------------------------------------------------------------------------
 
. poisgof
 
         Goodness-of-fit chi2  =  442816.4
         Prob > chi2(15)       =    0.0000
 
. predict const_only
(option n assumed; predicted number of events)
 
. table hed wed, contents (sum  const_only) row col
 
------------------------------------------------------------
          |                       wed                       
      hed |        1         2         3         4     Total
----------+-------------------------------------------------
        1 | 32721.38  32721.38  32721.38  32721.38  130885.5
        2 | 32721.38  32721.38  32721.38  32721.38  130885.5
        3 | 32721.38  32721.38  32721.38  32721.38  130885.5
        4 | 32721.38  32721.38  32721.38  32721.38  130885.5
          | 
    Total | 130885.5  130885.5  130885.5  130885.5    523542
------------------------------------------------------------
 
. desmat: poisson count hed wed
-----------------------------------------------------------------------------------
   Poisson regression
-----------------------------------------------------------------------------------
   Dependent variable                                                        count
   Optimization:                                                                 ml
   Number of observations:                                                       16
   Initial log likelihood:                                             -221501.223
   Log likelihood:                                                     -113882.425
   LR chi square:                                                       215237.595
   Model degrees of freedom:                                                     6
   Pseudo R-squared:                                                         0.486
   Prob:                                                                     0.000
-----------------------------------------------------------------------------------
nr Effect                                                        Coeff        s.e.
----------------------------------------------------------------------------------
   count
     hed
1      2                                                         1.072**     0.004
2      3                                                         0.595**     0.005
3      4                                                         0.235**     0.005
     wed
4      2                                                         1.229**     0.004
5      3                                                         0.733**     0.005
6      4                                                         0.142**     0.005
7    _cons                                                       9.187**     0.005
-----------------------------------------------------------------------------------
*  p < .05
** p < .01
 
. poisgof
 
         Goodness-of-fit chi2  =  227578.9
         Prob > chi2(9)        =    0.0000
 
. predict indep_model
(option n assumed; predicted number of events)


. table hed wed, contents (sum indep_model) row col
 
------------------------------------------------------------
          |                       wed                       
      hed |        1         2         3         4     Total
----------+-------------------------------------------------
        1 | 9773.551  33398.43  20349.32   11263.7     74785
        2 |  28552.2  97569.33  59447.98   32905.5    218475
        3 | 17727.26  60578.06  36909.58   20430.1    135645
        4 | 12367.98  42264.19  25751.13   14253.7     94637
          | 
    Total |    68421    233810    142458     78853    523542
------------------------------------------------------------
 
. table hed wed, contents (sum count) row col
 
--------------------------------------------------
          |                  wed                  
      hed |      1       2       3       4   Total
----------+---------------------------------------
        1 |  32016   33374    8407     988   74785
        2 |  28370  137876   43783    8446  218475
        3 |   7051   48766   61633   18195  135645
        4 |    984   13794   28635   51224   94637
          | 
    Total |  68421  233810  142458   78853  523542
--------------------------------------------------
 
. *The independence model fits the actual data perfectly on the marginals, but 
> not very well at all in the interior
. *let's introduce a single term that accounts for educational endogamy.
. gen ed_endogamy_simple=0
 
. replace  ed_endogamy_simple=1 if hed==wed
(4 real changes made)
 
. table hed wed, contents (mean  ed_endogamy_simple)
 
----------------------------------
          |          wed          
      hed |    1     2     3     4
----------+-----------------------
        1 |    1     0     0     0
        2 |    0     1     0     0
        3 |    0     0     1     0
        4 |    0     0     0     1
----------------------------------
 
. desmat: poisson count hed wed  ed_endogamy_simple
-----------------------------------------------------------------------------------
   Poisson regression
-----------------------------------------------------------------------------------
   Dependent variable                                                        count
   Optimization:                                                               ml
   Number of observations:                                                     16
   Initial log likelihood:                                             -221501.223
   Log likelihood:                                                      -41944.565
   LR chi square:                                                       359113.316
   Model degrees of freedom:                                                   7
   Pseudo R-squared:                                                         0.811
   Prob:                                                                     0.000
-----------------------------------------------------------------------------------
nr Effect                                                        Coeff        s.e.
----------------------------------------------------------------------------------
   count
     hed
1      2                                                         0.740**     0.005
2      3                                                         0.414**     0.005
3      4                                                         0.216**     0.005
     wed
4      2                                                         0.979**     0.005
5      3                                                         0.608**     0.005
6      4                                                         0.081**     0.005
     ed_endogamy_simple
7      1                                                         1.115**     0.003
8    _cons                                                       9.067**     0.005
----------------------------------------------------------------------------------
*  p < .05
** p < .01
 
. display exp(1.115)
3.0495682
 
. poisgof
 
         Goodness-of-fit chi2  =  83703.13
         Prob > chi2(8)        =    0.0000
 
. predict simple_endogamy
(option n assumed; predicted number of events)
 
. table hed wed, contents (sum  simple_endogamy) row col
 
------------------------------------------------------------
          |                       wed                       
      hed |        1         2         3         4     Total
----------+-------------------------------------------------
        1 | 26426.32  23047.51  15915.36  9395.808     74785
        2 | 18145.71  147304.7  33341.21  19683.35    218475
        3 | 13104.12  34867.67  73458.66  14214.54    135645
        4 | 10744.85  28590.09  19742.76   35559.3     94637
          | 
    Total |    68421    233810    142458     78853    523542
------------------------------------------------------------
 
. table hed wed, contents (sum  count) row col
 
--------------------------------------------------
          |                  wed                  
      hed |      1       2       3       4   Total
----------+---------------------------------------
        1 |  32016   33374    8407     988   74785
        2 |  28370  137876   43783    8446  218475
        3 |   7051   48766   61633   18195  135645
        4 |    984   13794   28635   51224   94637
          | 
    Total |  68421  233810  142458   78853  523542
--------------------------------------------------
 
. gen ed_endogamy_particular=0
 
. replace  ed_endogamy_particular=hed if hed==wed
(4 real changes made)
 
. table hed wed, contents (mean ed_endogamy_particular)
 
----------------------------------
          |          wed          
      hed |    1     2     3     4
----------+-----------------------
        1 |    1     0     0     0
        2 |    0     2     0     0
        3 |    0     0     3     0
        4 |    0     0     0     4
----------------------------------
 
. desmat: poisson count hed wed   ed_endogamy_particular
---------------------------------------------------------------------------------
   Poisson regression
----------------------------------------------------------------------------------
   Dependent variable                                                        count
   Optimization:                                                                ml
   Number of observations:                                                      16
   Initial log likelihood:                                             -221501.223
   Log likelihood:                                                      -24059.274
   LR chi square:                                                       394883.898
   Model degrees of freedom:                                                    10
   Pseudo R-squared:                                                         0.891
   Prob:                                                                     0.000
----------------------------------------------------------------------------------
nr Effect                                                        Coeff        s.e.
---------------------------------------------------------------------------------
   count
     hed
1      2                                                         1.134**     0.007
2      3                                                         0.819**     0.006
3      4                                                        -0.017*      0.007
     wed
4      2                                                         1.372**     0.007
5      3                                                         1.020**     0.007
6      4                                                        -0.278**     0.008
     ed_endogamy_particular
7      1                                                         1.722**     0.009
8      2                                                         0.676**     0.007
9      3                                                         0.537**     0.008
10     4                                                         2.487**     0.009
11   _cons                                                       8.652**     0.008
-------------------------------------------------------------------------------
----
*  p < .05
** p < .01
 
. poisgof
 
         Goodness-of-fit chi2  =  47932.55
         Prob > chi2(5)        =    0.0000
 
. predict P_full_endogamy
(option n assumed; predicted number of events)
 
. table hed wed, contents (sum P_full_endogamy) row col
 
------------------------------------------------------------
          |                       wed                       
      hed |        1         2         3         4     Total
----------+-------------------------------------------------
        1 |    32016  22561.17  15875.39  4332.443     74785
        2 | 17790.29    137876  49342.89  13465.83    218475
        3 |  12987.8  51193.47     61633   9830.73    135645
        4 | 5626.913  22179.36  15606.73     51224     94637
          | 
    Total |    68421    233810    142458     78853    523542
------------------------------------------------------------
 
. table hed wed, contents (sum count) row col
 
--------------------------------------------------
          |                  wed                  
      hed |      1       2       3       4   Total
----------+---------------------------------------
        1 |  32016   33374    8407     988   74785
        2 |  28370  137876   43783    8446  218475
        3 |   7051   48766   61633   18195  135645
        4 |    984   13794   28635   51224   94637
          | 
    Total |  68421  233810  142458   78853  523542
--------------------------------------------------
 
. *We have 4 interaction terms for educational endogamy for the different educational groups.
  The likelihood ratio test can confirm that this model fits better than the model which had 
uniform educational endogamy across groups.
. *If we want to ask questions about which kinds of endogamy are significantly 
> stronger than which other kinds, we need to test the parameters of the model 
> directly.
. desmat: poisson count hed wed   ed_endogamy_particular
---------------------------------------------------------------------------------
   Poisson regression
---------------------------------------------------------------------------------
   Dependent variable                                                        count
   Optimization:                                                               ml
   Number of observations:                                                      16
   Initial log likelihood:                                             -221501.223
   Log likelihood:                                                      -24059.274
   LR chi square:                                                       394883.898
   Model degrees of freedom:                                                    10
   Pseudo R-squared:                                                         0.891
   Prob:                                                                     0.000
----------------------------------------------------------------------------------
nr Effect                                                        Coeff        s.e.
---------------------------------------------------------------------------------
   count
     hed
1      2                                                         1.134**     0.007
2      3                                                         0.819**     0.006
3      4                                                        -0.017*      0.007
     wed
4      2                                                         1.372**     0.007
5      3                                                         1.020**     0.007
6      4                                                        -0.278**     0.008
     ed_endogamy_particular
7      1                                                         1.722**     0.009
8      2                                                         0.676**     0.007
9      3                                                         0.537**     0.008
10     4                                                         2.487**     0.009
11   _cons                                                       8.652**     0.008
---------------------------------------------------------------------------------
*  p < .05
** p < .01
 
. *If we want to ask whether the force of educational endogamy is significantly
>  stronger for group 4 than group 1, we test:
. test _x_10-_x_7=0
 
 ( 1) - [count]_x_7 + [count]_x_10 = 0
 
           chi2(  1) = 3300.64
         Prob > chi2 =    0.0000
 
. *
. *This tells us that category 4 and category 1 are very significantly different in terms of educational endogamy.
. *Categories 2 and 3 are not so far apart, it might be more interesting to test whether that difference is statistically significant.
. test _x_8-_x_9=0
 
 ( 1)  [count]_x_8 - [count]_x_9 = 0
 
           chi2(  1) =  129.03
         Prob > chi2 =    0.0000
-------------------------------------------------------------------------------