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

# Re: st: margins after logit model

 From Haiyong Xu To Subject Re: st: margins after logit model Date Wed, 29 Dec 2010 15:53:30 -0800

```Great! This is perfectly what I need. Thanks!

--------------------------------------------------
From: "Tirthankar Chakravarty" <tirthankar.chakravarty@gmail.com>
Sent: Wednesday, December 29, 2010 3:42 PM
To: <statalist@hsphsun2.harvard.edu>
Subject: Re: st: margins after logit model

```
```One way to do this is to re-estimate with the group you want omitted
set as the base group in the logit regression:

*****************************************
webuse lbw, clear
logit low age lwt i.race smoke ptl ht ui
margins, dydx(race)
logit low age lwt b2.race smoke ptl ht ui
margins, dydx(race)
*****************************************

T

On Wed, Dec 29, 2010 at 3:36 PM, Haiyong Xu <hxu@mednet.ucla.edu> wrote:
```
```
Hi,
Wish you all have wonderful holidays!

My logit model and the output are as follows:

logit psydrgnobzn i.female age i.year, vce(cluster cluster_id)

Logistic regression                               Number of obs   =
40284
Wald chi2(4)    =
422.81
Prob > chi2     =
0.0000
Log pseudolikelihood = -26350.649                 Pseudo R2       =
0.0127

(Std. Err. adjusted for 13428 clusters in
cluster_id)
------------------------------------------------------------------------------
|               Robust
psydrgnobzn |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
Interval]
-------------+----------------------------------------------------------------
1.female |   .5114119   .0357798    14.29   0.000     .4412848
.5815389
age |  -.0191765   .0023834    -8.05
0.000    -.0238479   -.0145051
|
year |
2006  |    .154101   .0147308    10.46   0.000     .1252292
.1829728
2007  |   .2495566   .0171274    14.57   0.000     .2159875
.2831257
|
_cons |   .5000495   .1866511     2.68   0.007       .13422
.865879
------------------------------------------------------------------------------

After the logit model, I run margins command to get the marginal effect.
. margins, dydx(year)

Average marginal effects                          Number of obs   =
40284
Model VCE    : Robust

Expression   : Pr(psydrgnobzn), predict()
dy/dx w.r.t. : 2006.year 2007.year

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf.
Interval]
-------------+----------------------------------------------------------------
year |
2006  |   .0351202   .0033485    10.49   0.000     .0285573
.0416832
2007  |   .0575292   .0039259    14.65   0.000     .0498345
.0652239
------------------------------------------------------------------------------
Note: dy/dx for factor levels is the discrete change from the base level.

The year variables has three values 2005, 2006 and 2007. Stata
automatically
set 2005 as the omit group. I wonder if I can set 2006 as the reference
group so that I can get the margin effect between 2006 and 2007.

Thanks.
Haiyong

IMPORTANT WARNING:  This email (and any attachments) is only intended for
the use of the person or entity to which it is addressed, and may contain
information that is privileged and confidential.  You, the recipient, are
obligated to maintain it in a safe, secure and confidential manner.
Unauthorized redisclosure or failure to maintain confidentiality may
subject you to federal and state penalties. If you are not the intended
recipient, please immediately notify us by return email, and delete this

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

--
To every ω-consistent recursive class κ of formulae there correspond
recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
belongs to Flg(κ) (where v is the free variable of r).

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

```
```
IMPORTANT WARNING:  This email (and any attachments) is only intended for the use of the person or entity to which it is addressed, and may contain information that is privileged and confidential.  You, the recipient, are obligated to maintain it in a safe, secure and confidential manner.  Unauthorized redisclosure or failure to maintain confidentiality may subject you to federal and state penalties. If you are not the intended recipient, please immediately notify us by return email, and delete this message from your computer.

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