Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fitting topological model of social mobility with design matrix in Stata

    Dear Stata users,

    My question is about mobility table analysis, and the relevant commands including -poisson-, -glm-, and -loglin- (SSC). I want to replicate the result of John Goldthorpe who used level matrix or design matrix in fitting partitioning models (or called topological models). The model tells us that the log likelihood ratio, i.e. G2 = 351 with 31 degrees of freedom. How can I fit this model and get significance test results in Stata? Thank you very much.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(father son count levels)
    1 1 311 2
    1 2 130 2
    1 3  79 1
    1 4  53 1
    1 5  33 1
    1 6  37 1
    1 7  45 1
    2 1 161 2
    2 2 128 2
    2 3  66 1
    2 4  39 1
    2 5  53 1
    2 6  59 1
    2 7  48 1
    3 1 128 1
    3 2 109 1
    3 3  89 3
    3 4  54 1
    3 5  89 1
    3 6 108 1
    3 7 117 1
    4 1 167 1
    4 2 151 1
    4 3 106 1
    4 4 324 4
    4 5 116 1
    4 6 192 1
    4 7 273 1
    5 1 154 1
    5 2 147 1
    5 3 109 1
    5 4  83 1
    5 5 170 5
    5 6 229 1
    5 7 190 1
    6 1 202 1
    6 2 228 1
    6 3 216 1
    6 4 170 1
    6 5 319 1
    6 6 788 6
    6 7 671 6
    7 1 162 1
    7 2 194 1
    7 3 205 1
    7 4 164 1
    7 5 311 1
    7 6 587 6
    7 7 870 6
    end
    label values father class
    label values son class
    label def class 1 "I", modify
    label def class 2 "II", modify
    label def class 3 "III", modify
    label def class 4 "IV", modify
    label def class 5 "V", modify
    label def class 6 "VI", modify
    label def class 7 "VII", modify
    
    */ Show the Intergenerational class mobility
    tabulate father son [fw=count]
    
    */ Show the Levels matrix (design matrix) for model
    tabulate father son [fw=levels]

  • #2
    https://www.maartenbuis.nl/presentations/london15b.pdf
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Dear Maarten Buis thank you very much. I have noticed your presentation in 2015 and it really helps me a lot. I have wrongly inputted data in Class II of father and Class I of son cell that made me can't replicate the significance test result G2 = 351. (The data I provide in 1# is right. However, I have wrong copy in my own disk.)
      Code:
      poisson count i.father##i.son
      est store full
      poisson count i.father i.son i.levels, irr
      lrtest full
      llingov, sat(full)
      
      . lrtest full
      
      Likelihood-ratio test                                 LR chi2(31) =    351.25
      (Assumption: . nested in full)                        Prob > chi2 =    0.0000
      
      . llgof, sat(full)
      
                   |        LL         df          p        BIC          D 
      -------------+-------------------------------------------------------
                r1 |  351.2547         31   6.09e-56   67.54032   .0765724
      Now, my further question is when I examine specific partitioned table should I use one combined design matrix or should I use separate ones? I find that the lrtest gives different significance test results. For example:
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(meduc feduc count diag move_sym move_asym full_matrix) byte _est_full
      1 1 2068 1 0 0 1 1
      1 2  703 0 1 2 2 1
      1 3  426 0 0 0 0 1
      1 4  122 0 0 0 0 1
      1 5   60 0 0 0 0 1
      2 1 4555 0 1 1 1 1
      2 2 7200 2 0 0 2 1
      2 3 2523 0 1 2 2 1
      2 4  416 0 0 0 0 1
      2 5  229 0 0 0 0 1
      3 1 1032 0 0 0 0 1
      3 2 1792 0 1 1 1 1
      3 3 4845 3 0 0 3 1
      3 4  856 0 1 2 2 1
      3 5  544 0 0 0 0 1
      4 1  334 0 0 0 0 1
      4 2  472 0 0 0 0 1
      4 3 1157 0 1 1 1 1
      4 4 1100 4 0 0 4 1
      4 5  471 0 1 2 2 1
      5 1  389 0 0 0 0 1
      5 2  740 0 0 0 0 1
      5 3 1783 0 0 0 0 1
      5 4  999 0 1 1 1 1
      5 5 2418 5 0 0 5 1
      end
      label values meduc edu
      label values feduc edu
      label def edu 1 "low", modify
      label def edu 2 "lower voc", modify
      label def edu 3 "medium voc", modify
      label def edu 4 "higher voc", modify
      label def edu 5 "university", modify
      
      . tabdisp meduc feduc, cell(count)
      
      -----------------------------------------------------------------------
                 |                           feduc                           
           meduc |        low   lower voc  medium voc  higher voc  university
      -----------+-----------------------------------------------------------
             low |       2068         703         426         122          60
       lower voc |       4555        7200        2523         416         229
      medium voc |       1032        1792        4845         856         544
      higher voc |        334         472        1157        1100         471
      university |        389         740        1783         999        2418
      -----------------------------------------------------------------------
      
      
      gen diag = (meduc==feduc)*meduc
      gen move_sym = abs(feduc-meduc) == 1
      gen move_asym = (meduc-feduc==1) + 2*(meduc-feduc==-1)
      gen full_matrix=diag
      replace full_matrix= move_asym if full_matrix==0
      
      poisson count i.meduc##i.feduc
      est store full
      
      poisson count i.meduc i.feduc i.diag i.move_asym, nolog
      
      Poisson regression                              Number of obs     =         25
                                                      LR chi2(15)       =   35202.87
                                                      Prob > chi2       =     0.0000
      Log likelihood = -923.95537                     Pseudo R2         =     0.9501
      
      ------------------------------------------------------------------------------
             count |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
             meduc |
        lower voc  |   1.155873   .0343001    33.70   0.000     1.088646      1.2231
       medium voc  |   .9144184   .0327381    27.93   0.000     .8502528    .9785839
       higher voc  |   .0403103   .0374226     1.08   0.281    -.0330366    .1136572
       university  |   .9259324   .0339594    27.27   0.000     .8593732    .9924916
                   |
             feduc |
        lower voc  |  -.3596171   .0258192   -13.93   0.000    -.4102218   -.3090123
       medium voc  |   .0997877   .0223721     4.46   0.000     .0559393    .1436362
       higher voc  |  -1.049797   .0280252   -37.46   0.000    -1.104725   -.9948684
       university  |  -.9977161   .0329306   -30.30   0.000    -1.062259   -.9331732
                   |
              diag |
                1  |   1.642732   .0394995    41.59   0.000     1.565314     1.72015
                2  |   2.093975   .0365023    57.37   0.000     2.022432    2.165519
                3  |   1.479891    .031555    46.90   0.000     1.418045    1.541738
                4  |   2.020947   .0481663    41.96   0.000     1.926543    2.115351
                5  |   1.870874   .0395989    47.25   0.000     1.793262    1.948487
                   |
         move_asym |
                1  |     1.1175   .0204131    54.74   0.000     1.077491    1.157509
                2  |   .7335041   .0261475    28.05   0.000     .6822559    .7847522
                   |
             _cons |   5.991605   .0328124   182.60   0.000     5.927294    6.055916
      ------------------------------------------------------------------------------
      
      . lrtest full
      
      Likelihood-ratio test                                 LR chi2(9)  =   1633.31
      (Assumption: . nested in full)                        Prob > chi2 =    0.0000
      
      
      poisson count i.meduc i.feduc i.full_matrix, nolog
      
      Poisson regression                              Number of obs     =         25
                                                      LR chi2(13)       =   32396.71
                                                      Prob > chi2       =     0.0000
      Log likelihood = -2327.0359                     Pseudo R2         =     0.8744
      
      ------------------------------------------------------------------------------
             count |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
             meduc |
        lower voc  |   1.300971   .0194043    67.05   0.000      1.26294    1.339003
       medium voc  |   .5554793   .0244917    22.68   0.000     .5074763    .6034822
       higher voc  |   .0473744   .0282109     1.68   0.093    -.0079179    .1026668
       university  |   .8472129   .0273145    31.02   0.000     .7936774    .9007484
                   |
             feduc |
        lower voc  |   .0776559   .0193121     4.02   0.000     .0398048     .115507
       medium voc  |  -.2826242   .0210531   -13.42   0.000    -.3238875   -.2413609
       higher voc  |  -1.139246   .0264795   -43.02   0.000    -1.191144   -1.087347
       university  |  -1.184959   .0328806   -36.04   0.000    -1.249403   -1.120514
                   |
       full_matrix |
                1  |   1.079217   .0184555    58.48   0.000     1.043045    1.115389
                2  |    1.11327   .0230316    48.34   0.000     1.068129    1.158411
                3  |   2.117254   .0295994    71.53   0.000     2.059241    2.175268
                4  |   1.999344   .0456336    43.81   0.000     1.909903    2.088784
                5  |   2.032849   .0393746    51.63   0.000     1.955676    2.110021
                   |
             _cons |   6.095593   .0235744   258.57   0.000     6.049388    6.141798
      ------------------------------------------------------------------------------
      
      . lrtest full
      
      Likelihood-ratio test                                 LR chi2(11) =   4439.47
      (Assumption: . nested in full)                        Prob > chi2 =    0.0000


      Comment


      • #4
        That just depends on the hypothesis you want to test.
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment

        Working...
        X