Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: predicted probabilities and marginal effects after xtmelogit and xtlogit

 From "Jason P. Kelly" To "statalist@hsphsun2.harvard.edu" Subject st: predicted probabilities and marginal effects after xtmelogit and xtlogit Date Tue, 8 Feb 2011 18:00:22 +0000

Dear Statalist,

We are trying to generate predicted probabilities and marginal effects after mixed-effects and fixed effects logistical regression models (xtmelogit and xtlogit), but getting some odd results.  Our dependant variable is whether or not an appeals judge votes to uphold a trial court decision, and the controls are types of judicial selection systems and public opinion in the states with those systems.

After xtmelogit, for the predicted probabilities, I follow the direction provided here: http://www.ats.ucla.edu/stat/stata/faq/xtmelogit_prob.htm and run:

. margins party, at(retention=1 retpo3=.75 polappoint=0 nonparelec2=0 papo3=0 partpo3=0) predict(mu fixedonly)

Predictive margins                                Number of obs   =       7014

Expression   : Predicted mean, fixed portion only, predict(mu fixedonly)
at           : polappoint      =        0
retention       =        1
nonparelec2     =        0
papo3           =        0
retpo3          =       .75
partpo3         =        0

------------------------------------------------------------------------------
|            Delta-method
|     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
party |
0  |    .598739   .0488954    12.25   0.000     .5029059    .6945721
1  |    .488338   .0455832    10.71   0.000     .3989966    .5776793
------------------------------------------------------------------------------

These results seam fine to me.  But the only way I can get stata to produce marginal effects after running xtmelogit is:

. margins, predict (mu fixedonly) dydx(*) at(retention=1 retpo3=.5 polappoint=0 nonparelec2=0 papo3=0 partpo3=0)

Average marginal effects                          Number of obs   =       7014

Expression   : Predicted mean, fixed portion only, predict(mu fixedonly)
dy/dx w.r.t. : 1.party copkill rape rob multivic vic_fem grounds polappoint retention
nonparelec2 papo3 retpo3 npartpo3 partpo3
at           : polappoint      =        0
retention       =        1
nonparelec2     =        0
papo3           =        0
retpo3          =       .5
partpo3         =        0

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
1.party |  -.1173236   .0304326    -3.86   0.000    -.1769705   -.0576768
copkill |   .0953764   .0300031     3.18   0.001     .0365714    .1541815
rape |   .0240124   .0160042     1.50   0.134    -.0073552    .0553801
rob |   .0284853   .0124724     2.28   0.022     .0040399    .0529307
multivic |   .0697821   .0135588     5.15   0.000     .0432074    .0963568
vic_fem |   .0184944   .0141448     1.31   0.191    -.0092289    .0462176
grounds |    .030395   .0030072    10.11   0.000      .024501    .0362891
polappoint |  -.3219874   .3974086    -0.81   0.418    -1.100894    .4569191
retention |   .5976574   .2906474     2.06   0.040      .027999    1.167316
nonparelec2 |   1.575365   .2475787     6.36   0.000      1.09012    2.060611
papo3 |   1.758983   .4573814     3.85   0.000     .8625317    2.655434
retpo3 |   .3767294   .2466326     1.53   0.127    -.1066615    .8601203
npartpo3 |  -.8024966   .2529398    -3.17   0.002     -1.29825   -.3067436
partpo3 |   1.260203   .3036206     4.15   0.000      .665117    1.855288
------------------------------------------------------------------------------
Note: dy/dx for factor levels is the discrete change from the base level.

Most of these results also seem fine.  For instance, the marginal effect for party seems to be the difference between party = 0 and party = 1 from the predicted probabilities.  But I'm confused by the values over 1.

Similarly, after xtlogit, I ran the following to generate the predicted probabilities:

. margins party, at(retention=1 retpo3=.75 nonparelec2=0 papo3=0 partpo3=0) predict(pu0)

Predictive margins                                Number of obs   =       6609
Model VCE    : OIM

Expression   : Pr(uphold|fixed effect is 0), predict(pu0)
at           : retention       =           1
nonparelec2     =           0
papo3           =           0
retpo3          =         .75
partpo3         =           0

------------------------------------------------------------------------------
|            Delta-method
|     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
party |
0  |   .9834969   .0268031    36.69   0.000     .9309638     1.03603
1  |   .0003144   .2352597     0.00   0.999    -.4607861    .4614149
------------------------------------------------------------------------------

These results seam way off, so I also ran:
. predict puphold
(option pc1 assumed; probability of success given one success within group)
(255 missing values generated)

. gen puphold2 = exp(puphold)/(1+exp(puphold))
(255 missing values generated)

This produced a column of puphold2 values, which I am led to believe are predicted probabilities, but I'm unsure how to interpret them (I assume they're the probability that a high court will uphold, given values of all the other independent variables for the observation in question)?  Is it possible to produce predicted probabilities for party = 0 and 1, when the other independent variables are set at their mean, or some other stated value, as in the case above?

I also tried to produce marginal effects at xtlogit as follows:

. margins, predict (pu0) dydx(*) at (retention=0 nonparelec2=0 npartpo3=0 retpo3=0 party=1 pa
> rtpo3=0.5)

Average marginal effects                          Number of obs   =       6609
Model VCE    : OIM

Expression   : Pr(uphold|fixed effect is 0), predict(pu0)
dy/dx w.r.t. : party copkill rape rob multivic vic_fem grounds retention nonparelec2 papo3
retpo3 npartpo3 partpo3
at           : party           =          1
retention       =          0
nonparelec2     =          0
retpo3          =          0
npartpo3        =          0
partpo3         =         .5

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
party |  -.2119108   88.65475    -0.00   0.998     -173.972    173.5482
copkill |   .0076088   3.608257     0.00   0.998    -7.064444    7.079662
rape |   .0018991   .9006103     0.00   0.998    -1.763265    1.767063
rob |   .0021728   1.030404     0.00   0.998    -2.017381    2.021727
multivic |   .0053517   2.537873     0.00   0.998    -4.968788    4.979491
vic_fem |   .0017628   .8359773     0.00   0.998    -1.636723    1.640248
grounds |   .0025043   1.187582     0.00   0.998    -2.325114    2.330123
retention |   .0292498    13.8709     0.00   0.998    -27.15722    27.21572
nonparelec2 |    .115432   54.74035     0.00   0.998    -107.1737    107.4045
papo3 |   .1622443   76.93982     0.00   0.998     -150.637    150.9615
retpo3 |   .0536925   25.46213     0.00   0.998    -49.85116    49.95854
npartpo3 |  -.0536713   25.45208    -0.00   0.998    -49.93883    49.83149
partpo3 |   .0982661   46.59992     0.00   0.998     -91.2359    91.43244
------------------------------------------------------------------------------

My questions are many.  First, am I using the correct commands to produce the predicted probabilities and marginal effects for these two models? Second, when both models are run correctly, are the predicted probabilities and marginal effects from the two models comparable (i.e. can they be interpreted in the same way, after taking into account the assumptions and restrictions of the two models)? Third (from above), for the marginal effects in the xtmelogit model, if these marginal effects indicate the change in the predicted probability, how can the value be over 1?  And fourth (also from above), after the xtlogit, is it possible to produce predicted probabilities for party = 0 and 1, when the other independent variables are set at their mean, or some other stated value, as in the case above?

I realize this is a lot to ask (and to sift through), but any assistance is greatly appreciated.

Thanks,
Jason

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/