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.

# st: Margins after mlogit with survey data

 From "Joao Ricardo F. Lima" To statalist@hsphsun2.harvard.edu Subject st: Margins after mlogit with survey data Date Wed, 8 Sep 2010 12:05:12 -0300

```Dear Statalisters,

I'm using Stata 11.1. I'm trying to use (understand better) the factor
variables and -margins- to estimate the -mlogit- with survey data. The
problem is like this:

*********************begin example**********************
webuse nhanes2f
svyset psuid [pweight=finalwgt], strata(stratid)
svy: mlogit  region sex race c.age##c.age sizplace
margins, dydx(*) predict(outcome(1)) atmeans
**************************end***************************

Here is the output after - margins-

. margins, dydx(*) predict(outcome(1)) atmeans

Conditional marginal effects                      Number of obs   =      10337
Model VCE    : Linearized

Expression   : Pr(region==NE), predict(outcome(1))
dy/dx w.r.t. : sex race age sizplace
at           : sex             =    1.520421 (mean)
race            =    1.146352 (mean)
age             =    42.23732 (mean)
sizplace        =    4.808137 (mean)

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
sex |  (not estimable)
race |  (not estimable)
age |  (not estimable)
sizplace |  (not estimable)
------------------------------------------------------------------------------

Well, first of all I thought that the problem would be with the factor
variables. After some tests I think that I'm doing something wrong
related to the -margins- sintax with survey data.
In the manual I saw that must use vce(unconditional) and with this it
really runs:

. qui svy: mlogit region sex race c.age##c.age sizplace

. margins, vce(unconditional) dydx(*) predict(outcome(1)) atmeans

Conditional marginal effects                    Number of obs      =     10337

Expression   : Pr(region==NE), predict(outcome(1))
dy/dx w.r.t. : sex race age sizplace
at           : sex             =    1.520421 (mean)
race            =    1.146352 (mean)
age             =    42.23732 (mean)
sizplace        =    4.808137 (mean)

------------------------------------------------------------------------------
|             Linearized
|      dy/dx   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
sex |  -.0109646   .0071698    -1.53   0.136    -.0255874    .0036582
race |   -.166159   .0441513    -3.76   0.001    -.2562062   -.0761118
age |   .0006825    .000436     1.57   0.128    -.0002068    .0015718
sizplace |  -.0191915   .0084362    -2.27   0.030    -.0363973   -.0019857
------------------------------------------------------------------------------

.
end of do-file

However, with my data I still have the problem:

. global vars "sit_ocup raca outro filha sit_cen conjuge filho_nasc esc numfam1"
. qui  svy: mlogit \$vars c.exp##c.exp c.esc#c.exp, base(0)
. margins, vce(unconditional) dydx(*) predict(outcome(1)) atmeans

Conditional marginal effects                    Number of obs      =     11425

Expression   : Pr(sit_ocup==1), predict(outcome(1))
dy/dx w.r.t. : raca outro filha sit_cen conjuge filho_nasc esc numfam1 exp
at           : raca            =     .286326 (mean)
outro           =    .0994388 (mean)
filha           =    .5500114 (mean)
sit_cen         =    .7415462 (mean)
conjuge         =    .2493822 (mean)
filho_nasc      =    .2983064 (mean)
esc             =     9.21675 (mean)
numfam1         =    4.074953 (mean)
exp             =     3.36428 (mean)

------------------------------------------------------------------------------
|             Linearized
|      dy/dx   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
raca |  (not estimable)
outro |  (not estimable)
filha |  (not estimable)
sit_cen |  (not estimable)
conjuge |  (not estimable)
filho_nasc |  (not estimable)
esc |  (not estimable)
numfam1 |  (not estimable)
exp |  (not estimable)
------------------------------------------------------------------------------

.
end of do-file

Thanks for who explain what I'm doing wrong.

Best Regards,

--
----------------------------------------
Joao Ricardo Lima, D.Sc.
Professor
UFPB-CCA-DCFS
Fone: +558387264913
Skype: joao_ricardo_lima
----------------------------------------
*
*   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/
```