Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: margins option in Stata10?


From   Richard Williams <richardwilliams.ndu@gmail.com>
To   statalist@hsphsun2.harvard.edu, statalist@hsphsun2.harvard.edu
Subject   Re: st: margins option in Stata10?
Date   Thu, 11 Aug 2011 14:10:29 -0500

At 11:51 AM 8/11/2011, Andreas Fagereng wrote:
Dear Listers,

I have the following question:


On the server where my data are stored, there is only installed Stata10.

I want to estimate the probability of being a participant (0 or 1) as
a function of age, and some other characteristics. I therefore run

-probit participant a18-a70 + control variables+ year fixed effects-,

where a18-50 are age dummies from age 18 to 70 .


I now want to plot the estimated probabilities of being a participant
over the life cycle.  The coefficients of the probit are not
interpretable.


In Stata11, on which i cannot run the data these two lines would give
me my answer


-probit participant i.age + control + year fixed effects-
-margins age, atmeans-



Is there a way to get exactly this in Stata10, maybe using mfx?

First off, you are wise to be careful. I show how old commands like mfx can give incorrect results in my Stata Conference talk

http://www.stata.com/meeting/chicago11/materials/chi11_williams.pptx

But, if you are careful, it can be done. First, here is sample code:

webuse nhanes2f
tab1 agegrp, gen(agegrp)
* Easy way if you have Stata 11+
probit diabetes i.agegrp weight
margins , atmeans dydx(agegrp)
* Hard way if you only have Stata 10
probit diabetes agegrp2-agegrp6 weight
mfx , at(agegrp2 = 0, agegrp3 = 0, agegrp4 = 0, agegrp5 = 0, agegrp6 = 0)

Since you don't have Stata 11, I'll also show the output:

. clear all

. webuse nhanes2f

. tab1 agegrp, gen(agegrp)

-> tabulation of agegrp

 Age groups |
        1-6 |      Freq.     Percent        Cum.
------------+-----------------------------------
   age20-29 |      2,320       22.44       22.44
   age30-39 |      1,621       15.68       38.13
   age40-49 |      1,270       12.29       50.41
   age50-59 |      1,289       12.47       62.88
   age60-69 |      2,852       27.59       90.47
    age 70+ |        985        9.53      100.00
------------+-----------------------------------
      Total |     10,337      100.00

. * Easy way if you have Stata 11+

. probit diabetes i.agegrp weight

Iteration 0:   log likelihood = -1999.0668
Iteration 1:   log likelihood = -1822.6588
Iteration 2:   log likelihood = -1807.9974
Iteration 3:   log likelihood = -1807.7631
Iteration 4:   log likelihood = -1807.7625
Iteration 5:   log likelihood = -1807.7625

Probit regression                                 Number of obs   =      10335
                                                  LR chi2(6)      =     382.61
                                                  Prob > chi2     =     0.0000
Log likelihood = -1807.7625                       Pseudo R2       =     0.0957

------------------------------------------------------------------------------
    diabetes |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      agegrp |
          2  |   .2206309    .125082     1.76   0.078    -.0245252    .4657871
          3  |   .5985311    .114849     5.21   0.000     .3734311    .8236311
          4  |   .8427783   .1085646     7.76   0.000     .6299957    1.055561
          5  |   1.081819   .0980249    11.04   0.000     .8896939    1.273945
          6  |   1.274717   .1061677    12.01   0.000     1.066632    1.482802
             |
      weight |   .0095574   .0014072     6.79   0.000     .0067994    .0123154
       _cons |  -3.166968   .1385273   -22.86   0.000    -3.438476   -2.895459
------------------------------------------------------------------------------

. margins , atmeans dydx(agegrp)

Conditional marginal effects                      Number of obs   =      10335
Model VCE    : OIM

Expression   : Pr(diabetes), predict()
dy/dx w.r.t. : 2.agegrp 3.agegrp 4.agegrp 5.agegrp 6.agegrp
at           : 1.agegrp        =    .2244799 (mean)
               2.agegrp        =    .1567489 (mean)
               3.agegrp        =    .1227866 (mean)
               4.agegrp        =    .1247218 (mean)
               5.agegrp        =    .2759555 (mean)
               6.agegrp        =    .0953072 (mean)
               weight          =    71.90313 (mean)

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      agegrp |
          2  |   .0053641   .0031363     1.71   0.087    -.0007828    .0115111
          3  |   .0233968   .0049879     4.69   0.000     .0136206    .0331729
          4  |   .0442435   .0062888     7.04   0.000     .0319176    .0565693
          5  |   .0744917   .0053948    13.81   0.000      .063918    .0850653
          6  |   .1075195   .0103715    10.37   0.000     .0871918    .1278472
------------------------------------------------------------------------------
Note: dy/dx for factor levels is the discrete change from the base level.

. * Hard way if you only have Stata 10

. probit diabetes agegrp2-agegrp6 weight

[Output deleted]

. mfx , at(agegrp2 = 0, agegrp3 = 0, agegrp4 = 0, agegrp5 = 0, agegrp6 = 0)

warning: no value assigned in at() for variables weight;
   means used for weight

Marginal effects after probit
      y  = Pr(diabetes) (predict)
         =  .00657351
------------------------------------------------------------------------------
variable |      dy/dx    Std. Err.     z    P>|z|  [    95% C.I.   ]      X
---------+--------------------------------------------------------------------
 agegrp2*|   .0053641      .00314    1.71   0.087  -.000783  .011511         0
 agegrp3*|   .0233968      .00499    4.69   0.000   .013621  .033173         0
 agegrp4*|   .0442435      .00629    7.04   0.000   .031918  .056569         0
 agegrp5*|   .0744917      .00539   13.81   0.000   .063918  .085065         0
 agegrp6*|   .1075195      .01037   10.37   0.000   .087192  .127847         0
  weight |   .0001762      .00005    3.73   0.000   .000084  .000269   71.9031
------------------------------------------------------------------------------
(*) dy/dx is for discrete change of dummy variable from 0 to 1

This kind of stuff is very error prone; life will be much simpler if you can get Stata 11 or 12. Plus, you could then use AMES instead of MEMs or some of the other options that margins offers.


-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  Richard.A.Williams.5@ND.Edu
WWW:    http://www.nd.edu/~rwilliam

*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index