Announcement

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

  • difference in results between including an interaction with categorical variable v. subgroup analysis


    Hi all! I’m running multinomial logit models with gender as an outcome. Goal: look at gender over time for each category of position_department_n. Model has cluster standard errors to account for repeated observations within individuals.

    When I include a year*position_department_n interaction, I get different predicted probabilities than if I choose a specific position_department_n and look at the trend over time. For example, first approach - 1#1#Senior, Social Sci - gives .6817881. The second approach when I only keep records of "Senior, Social Sci" and run a model with year as independent, I get _predict#_at |1 1 = .6639009.

    Question: which of the two ways is the most accurate? The second one (no interaction) is easier to interpret, but not sure if that's a good enough justification to use it if the first approach is more accurate. any help is much appreciated!


    More info on Data structure: There are no duplicate records across person, year, position_department_n, and gender_n. However, the same person can show up multiple times in the same year corresponding to different values of position_department_n, and same person can show up in several years. Data sample:
    person year position_department_n gender_n
    1 2010 Senior, Art M
    1 2011 Senior, Art M
    1 2012 Senior, Art M
    1 2012 Principal, Social Sci M
    1 2013 Principal, Social Sci M
    1 2013 Senior, Social Sci M



    Results below:

    First, I run the model with the interaction of year and position_department_n as the only explanatory variables (including the main effects led to some of the predicted probabilities not estimating):


    Code:
    . mlogit gender_n c.year#i.position_department_n, rrr vce(cluster person)
    
    Iteration 0:   log pseudolikelihood = -25756.382  
    Iteration 1:   log pseudolikelihood = -25585.173  
    Iteration 2:   log pseudolikelihood = -25583.289  
    Iteration 3:   log pseudolikelihood = -25583.288  
    
    Multinomial logistic regression                 Number of obs     =     31,306
                                                    Wald chi2(12)     =     252.02
                                                    Prob > chi2       =     0.0000
    Log pseudolikelihood = -25583.288               Pseudo R2         =     0.0067
    
                                                (Std. Err. adjusted for 10,425 clusters in person)
    ----------------------------------------------------------------------------------------------
                                 |               Robust
                        gender_n |        RRR   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -----------------------------+----------------------------------------------------------------
    F                            |  (base outcome)
    -----------------------------+----------------------------------------------------------------
    M                            |
    position_department_n#c.year |
                 Principal, Art  |   1.053355   .0092655     5.91   0.000     1.035351    1.071673
                  Principal, HR  |   1.053391   .0092637     5.91   0.000      1.03539    1.071705
          Principal, Social Sci  |   1.053518   .0092623     5.93   0.000      1.03552    1.071829
                    Senior, Art  |   1.053325   .0092646     5.91   0.000     1.035322    1.071641
                     Senior, HR  |   1.053309   .0092623     5.91   0.000      1.03531     1.07162
             Senior, Social Sci  |   1.053433   .0092615     5.92   0.000     1.035436    1.071742
                                 |
                           _cons |   1.19e-46   2.10e-45    -5.98   0.000     1.06e-61    1.33e-31
    -----------------------------+----------------------------------------------------------------
    U                            |
    position_department_n#c.year |
                 Principal, Art  |   .8998399   .0109779    -8.65   0.000     .8785788    .9216156
                  Principal, HR  |   .8999677   .0109865    -8.63   0.000     .8786901    .9217605
          Principal, Social Sci  |   .8998911   .0109781    -8.65   0.000     .8786297    .9216671
                    Senior, Art  |   .8996119   .0109747    -8.67   0.000      .878357    .9213811
                     Senior, HR  |   .8998544   .0109813    -8.65   0.000     .8785867    .9216369
             Senior, Social Sci  |   .8997857   .0109742    -8.66   0.000     .8785317    .9215539
                                 |
                           _cons |   2.12e+91   5.19e+92     8.58   0.000     2.90e+70    1.5e+112
    ----------------------------------------------------------------------------------------------
    Note: _cons estimates baseline relative risk for each outcome.
    
    . margins i.position_department_n, at(year=(2008(1)2013))
    
    Adjusted predictions                            Number of obs     =     31,306
    Model VCE    : Robust
    
    1._predict   : Pr(gender_n==F), predict(pr outcome(1))
    2._predict   : Pr(gender_n==M), predict(pr outcome(2))
    3._predict   : Pr(gender_n==U), predict(pr outcome(3))
    
    1._at        : year            =        2008
    
    2._at        : year            =        2009
    
    3._at        : year            =        2010
    
    4._at        : year            =        2011
    
    5._at        : year            =        2012
    
    6._at        : year            =        2013
    
    ----------------------------------------------------------------------------------------------------
                                       |            Delta-method
                                       |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -----------------------------------+----------------------------------------------------------------
    _predict#_at#position_department_n |
                   1#1#Principal, Art  |   .6904148   .0146884    47.00   0.000     .6616262    .7192034
                    1#1#Principal, HR  |   .6534034   .0179981    36.30   0.000     .6181278     .688679
            1#1#Principal, Social Sci  |   .6393116   .0117618    54.35   0.000     .6162589    .6623644
                      1#1#Senior, Art  |   .7371994   .0104295    70.68   0.000     .7167579    .7576409
                       1#1#Senior, HR  |   .6977463   .0130652    53.41   0.000     .6721391    .7233536
               1#1#Senior, Social Sci  |   .6817881   .0087808    77.65   0.000      .664578    .6989982
                   1#2#Principal, Art  |   .6932711   .0142585    48.62   0.000     .6653249    .7212173
                    1#2#Principal, HR  |   .6583121   .0176441    37.31   0.000     .6237302     .692894
            1#2#Principal, Social Sci  |   .6406808   .0112269    57.07   0.000     .6186766    .6626851
                      1#2#Senior, Art  |   .7366476   .0101531    72.55   0.000     .7167479    .7565474
                       1#2#Senior, HR  |   .7015478   .0126924    55.27   0.000     .6766712    .7264244
               1#2#Senior, Social Sci  |   .6825181   .0081336    83.91   0.000     .6665765    .6984596
                   1#3#Principal, Art  |   .6948569   .0141003    49.28   0.000     .6672208    .7224929
                    1#3#Principal, HR  |   .6618178   .0175169    37.78   0.000     .6274853    .6961503
            1#3#Principal, Social Sci  |   .6407483   .0109669    58.43   0.000     .6192537     .662243
                      1#3#Senior, Art  |   .7350899   .0101333    72.54   0.000      .715229    .7549508
                       1#3#Senior, HR  |   .7040617   .0125678    56.02   0.000     .6794293    .7286941
               1#3#Senior, Social Sci  |   .6820508    .007796    87.49   0.000      .666771    .6973305
                   1#4#Principal, Art  |   .6952305   .0142038    48.95   0.000     .6673914    .7230695
                    1#4#Principal, HR  |   .6639706   .0176048    37.72   0.000     .6294659    .6984753
            1#4#Principal, Social Sci  |   .6395812    .010991    58.19   0.000     .6180393     .661123
                      1#4#Senior, Art  |   .7325831   .0103738    70.62   0.000     .7122508    .7529154
                       1#4#Senior, HR  |    .705343    .012678    55.64   0.000     .6804944    .7301915
               1#4#Senior, Social Sci  |   .6804506   .0077986    87.25   0.000     .6651656    .6957357
                   1#5#Principal, Art  |   .6944533   .0145583    47.70   0.000     .6659195    .7229871
                    1#5#Principal, HR  |   .6648276    .017899    37.14   0.000     .6297463     .699909
            1#5#Principal, Social Sci  |   .6372502   .0113034    56.38   0.000      .615096    .6594044
                      1#5#Senior, Art  |    .729183   .0108715    67.07   0.000     .7078752    .7504908
                       1#5#Senior, HR  |     .70545   .0130121    54.21   0.000     .6799468    .7309533
               1#5#Senior, Social Sci  |   .6777837   .0081535    83.13   0.000     .6618031    .6937643
                   1#6#Principal, Art  |   .6925886   .0151514    45.71   0.000     .6628924    .7222847
                    1#6#Principal, HR  |   .6644512    .018393    36.13   0.000     .6284016    .7005009
            1#6#Principal, Social Sci  |   .6338283    .011899    53.27   0.000     .6105066    .6571499
                      1#6#Senior, Art  |   .7249436   .0116154    62.41   0.000     .7021779    .7477094
                       1#6#Senior, HR  |   .7044437   .0135605    51.95   0.000     .6778655    .7310219
               1#6#Senior, Social Sci  |   .6741162   .0088449    76.22   0.000     .6567806    .6914518
                   2#1#Principal, Art  |    .175149   .0110554    15.84   0.000     .1534807    .1968173
                    2#1#Principal, HR  |   .1773813   .0134333    13.20   0.000     .1510524    .2037101
            2#1#Principal, Social Sci  |   .2211269   .0099466    22.23   0.000      .201632    .2406218
                      2#1#Senior, Art  |   .1765052   .0088592    19.92   0.000     .1591415    .1938688
                       2#1#Senior, HR  |   .1619424   .0100195    16.16   0.000     .1423046    .1815802
               2#1#Senior, Social Sci  |   .2005883   .0075333    26.63   0.000     .1858233    .2153533
                   2#2#Principal, Art  |   .1852574   .0113472    16.33   0.000     .1630174    .2074974
                    2#2#Principal, HR  |   .1882555   .0138436    13.60   0.000     .1611226    .2153884
            2#2#Principal, Social Sci  |   .2334601   .0097708    23.89   0.000     .2143097    .2526105
                      2#2#Senior, Art  |   .1857781   .0089387    20.78   0.000     .1682587    .2032976
                       2#2#Senior, HR  |   .1715046   .0102093    16.80   0.000     .1514947    .1915145
               2#2#Senior, Social Sci  |   .2115326   .0071727    29.49   0.000     .1974743    .2255908
                   2#3#Principal, Art  |   .1955882   .0117739    16.61   0.000     .1725117    .2186646
                    2#3#Principal, HR  |   .1993627   .0143567    13.89   0.000      .171224    .2275013
            2#3#Principal, Social Sci  |   .2459803   .0097742    25.17   0.000     .2268231    .2651374
                      2#3#Senior, Art  |   .1952709   .0091886    21.25   0.000     .1772616    .2132802
                       2#3#Senior, HR  |   .1812946   .0105209    17.23   0.000     .1606741    .2019152
               2#3#Senior, Social Sci  |   .2226828   .0070125    31.76   0.000     .2089385    .2364271
                   2#4#Principal, Art  |   .2061346    .012355    16.68   0.000     .1819193    .2303499
                    2#4#Principal, HR  |   .2106899   .0149893    14.06   0.000     .1813114    .2400684
            2#4#Principal, Social Sci  |   .2586726   .0100062    25.85   0.000     .2390607    .2782845
                      2#4#Senior, Art  |   .2049823    .009637    21.27   0.000     .1860941    .2238705
                       2#4#Senior, HR  |   .1913067   .0109782    17.43   0.000     .1697899    .2128235
               2#4#Senior, Social Sci  |   .2340311   .0071308    32.82   0.000     .2200549    .2480073
                   2#5#Principal, Art  |   .2168903   .0131032    16.55   0.000     .1912084    .2425721
                    2#5#Principal, HR  |   .2222253   .0157547    14.11   0.000     .1913467    .2531038
            2#5#Principal, Social Sci  |    .271523   .0104999    25.86   0.000     .2509436    .2921024
                      2#5#Senior, Art  |   .2149108   .0102991    20.87   0.000     .1947249    .2350967
                       2#5#Senior, HR  |   .2015356   .0115993    17.37   0.000     .1788014    .2242698
               2#5#Senior, Social Sci  |   .2455698   .0075781    32.41   0.000     .2307169    .2604226
                   2#6#Principal, Art  |    .227849   .0140246    16.25   0.000     .2003614    .2553367
                    2#6#Principal, HR  |   .2339575   .0166618    14.04   0.000      .201301    .2666141
            2#6#Principal, Social Sci  |   .2845183   .0112657    25.26   0.000      .262438    .3065986
                      2#6#Senior, Art  |   .2250549   .0111768    20.14   0.000     .2031488    .2469609
                       2#6#Senior, HR  |   .2119763    .012395    17.10   0.000     .1876825    .2362701
               2#6#Senior, Social Sci  |   .2572915   .0083605    30.77   0.000     .2409053    .2736778
                   3#1#Principal, Art  |   .1344362   .0120228    11.18   0.000     .1108719    .1580005
                    3#1#Principal, HR  |   .1692153   .0153947    10.99   0.000     .1390423    .1993883
            3#1#Principal, Social Sci  |   .1395614   .0090152    15.48   0.000     .1218919     .157231
                      3#1#Senior, Art  |   .0862954   .0068023    12.69   0.000     .0729632    .0996276
                       3#1#Senior, HR  |   .1403113   .0105034    13.36   0.000      .119725    .1608975
               3#1#Senior, Social Sci  |   .1176236   .0061717    19.06   0.000     .1055273    .1297199
                   3#2#Principal, Art  |   .1214715    .010956    11.09   0.000     .0999982    .1429449
                    3#2#Principal, HR  |   .1534324   .0143656    10.68   0.000     .1252763    .1815885
            3#2#Principal, Social Sci  |   .1258591   .0081374    15.47   0.000       .10991    .1418081
                      3#2#Senior, Art  |   .0775743   .0061057    12.71   0.000     .0656073    .0895412
                       3#2#Senior, HR  |   .1269476   .0096766    13.12   0.000     .1079819    .1459133
               3#2#Senior, Social Sci  |   .1059494    .005386    19.67   0.000      .095393    .1165058
                   3#3#Principal, Art  |   .1095549   .0100884    10.86   0.000      .089782    .1293279
                    3#3#Principal, HR  |   .1388195   .0135051    10.28   0.000       .11235    .1652891
            3#3#Principal, Social Sci  |   .1132714   .0075119    15.08   0.000     .0985484    .1279944
                      3#3#Senior, Art  |   .0696392   .0055765    12.49   0.000     .0587094     .080569
                       3#3#Senior, HR  |   .1146437   .0090519    12.67   0.000     .0969023    .1323851
               3#3#Senior, Social Sci  |   .0952664   .0048896    19.48   0.000      .085683    .1048499
                   3#4#Principal, Art  |   .0986349   .0093833    10.51   0.000      .080244    .1170259
                    3#4#Principal, HR  |   .1253395    .012776     9.81   0.000      .100299    .1503799
            3#4#Principal, Social Sci  |   .1017463   .0070819    14.37   0.000      .087866    .1156265
                      3#4#Senior, Art  |   .0624346   .0051781    12.06   0.000     .0522856    .0725835
                       3#4#Senior, HR  |   .1033504   .0085803    12.05   0.000     .0865332    .1201675
               3#4#Senior, Social Sci  |   .0855183   .0046211    18.51   0.000      .076461    .0945755
                   3#5#Principal, Art  |   .0886564   .0088039    10.07   0.000      .071401    .1059118
                    3#5#Principal, HR  |   .1129471   .0121433     9.30   0.000     .0891467    .1367476
            3#5#Principal, Social Sci  |   .0912269   .0067881    13.44   0.000     .0779225    .1045312
                      3#5#Senior, Art  |   .0559062   .0048751    11.47   0.000     .0463513    .0654611
                       3#5#Senior, HR  |   .0930144    .008215    11.32   0.000     .0769133    .1091155
               3#5#Senior, Social Sci  |   .0766465   .0045056    17.01   0.000     .0678158    .0854773
                   3#6#Principal, Art  |   .0795624   .0083167     9.57   0.000     .0632619    .0958629
                    3#6#Principal, HR  |   .1015912    .011577     8.78   0.000     .0789007    .1242817
            3#6#Principal, Social Sci  |   .0816534    .006577    12.41   0.000     .0687627    .0945441
                      3#6#Senior, Art  |   .0500015   .0046363    10.78   0.000     .0409146    .0590884
                       3#6#Senior, HR  |     .08358   .0079158    10.56   0.000     .0680653    .0990947
               3#6#Senior, Social Sci  |   .0685923   .0044734    15.33   0.000     .0598246      .07736
    ----------------------------------------------------------------------------------------------------
    
    
    
    .

    Then, I choose one specific posittion_department_n = “Senior, Social Sci” and run a model with just year.


    Code:
    .
    . preserve
    
    . keep if position_department_n==6
    (20,148 observations deleted)
    
    . mlogit gender_n year, rrr vce(cluster person)
    
    Iteration 0:   log pseudolikelihood = -9145.8643  
    Iteration 1:   log pseudolikelihood = -9104.1549  
    Iteration 2:   log pseudolikelihood = -9103.6146  
    Iteration 3:   log pseudolikelihood = -9103.6145  
    
    Multinomial logistic regression                 Number of obs     =     11,158
                                                    Wald chi2(2)      =      83.93
                                                    Prob > chi2       =     0.0000
    Log pseudolikelihood = -9103.6145               Pseudo R2         =     0.0046
    
                                 (Std. Err. adjusted for 5,403 clusters in person)
    ------------------------------------------------------------------------------
                 |               Robust
        gender_n |        RRR   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    F            |  (base outcome)
    -------------+----------------------------------------------------------------
    M            |
            year |   1.034325   .0131964     2.65   0.008     1.008781    1.060515
           _cons |   1.14e-30   2.92e-29    -2.69   0.007     1.67e-52    7.79e-09
    -------------+----------------------------------------------------------------
    U            |
            year |   .8388152    .017835    -8.27   0.000     .8045775    .8745098
           _cons |   3.8e+152   1.6e+154     8.22   0.000     1.6e+116    8.7e+188
    ------------------------------------------------------------------------------
    Note: _cons estimates baseline relative risk for each outcome.
    
    . margins, at(year = (2008(1)2013)) post
    
    Adjusted predictions                            Number of obs     =     11,158
    Model VCE    : Robust
    
    1._predict   : Pr(gender_n==F), predict(pr outcome(1))
    2._predict   : Pr(gender_n==M), predict(pr outcome(2))
    3._predict   : Pr(gender_n==U), predict(pr outcome(3))
    
    1._at        : year            =        2008
    
    2._at        : year            =        2009
    
    3._at        : year            =        2010
    
    4._at        : year            =        2011
    
    5._at        : year            =        2012
    
    6._at        : year            =        2013
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    _predict#_at |
            1 1  |   .6639009   .0097464    68.12   0.000     .6447982    .6830035
            1 2  |   .6735234   .0084356    79.84   0.000     .6569898    .6900569
            1 3  |   .6808553   .0078396    86.85   0.000       .66549    .6962206
            1 4  |   .6861241   .0079737    86.05   0.000     .6704959    .7017522
            1 5  |   .6895562   .0087716    78.61   0.000     .6723643    .7067482
            1 6  |   .6913693   .0101041    68.42   0.000     .6715656    .7111731
            2 1  |   .2040169   .0083203    24.52   0.000     .1877094    .2203245
            2 2  |   .2140783    .007479    28.62   0.000     .1994196    .2287369
            2 3  |   .2238369   .0070453    31.77   0.000     .2100284    .2376454
            2 4  |   .2333116   .0072142    32.34   0.000     .2191722    .2474511
            2 5  |   .2425272   .0080547    30.11   0.000     .2267402    .2583142
            2 6  |   .2515114   .0094775    26.54   0.000     .2329359    .2700869
            3 1  |   .1320822   .0070437    18.75   0.000     .1182767    .1458877
            3 2  |   .1123984   .0055449    20.27   0.000     .1015306    .1232662
            3 3  |   .0953078   .0049427    19.28   0.000     .0856204    .1049953
            3 4  |   .0805643   .0048944    16.46   0.000     .0709715    .0901571
            3 5  |   .0679166    .005036    13.49   0.000     .0580463     .077787
            3 6  |   .0571193   .0051586    11.07   0.000     .0470087    .0672299
    ------------------------------------------------------------------------------


  • #2
    nvm
    Last edited by Tom Scott; 09 Oct 2021, 19:53.

    Comment

    Working...
    X