Bookmark and Share

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

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

st: Stata list example - use of the margins command

From   Maarten Buis <>
Subject   st: Stata list example - use of the margins command
Date   Thu, 8 Dec 2011 10:20:58 +0100

--- Peter Baade wrote me privately:
> I noticed that you posted the following example on the Stata list in May this year. <>
> I was wondering if I could ask you one question

You can, but convention on Statalist is that these questions are asked
on the list rather than privately. If you found something strange than
odds are that others will also find that to be the case, and would
thus appreciate an answer as well. It also has advantages for you,
because it regularly happens that others participate in the discussion
contributing another point of view or pointing out mistakes or
ommisions in my answer. This is discussed in the Statalist FAQ:
<> So I
forwarded this messages to statalist.

> when you used the “di” command below, could I use the nlcom command to get confidence intervals? I’ve used this and get very wide intervals, inconsistent with the p-value.

Below is an adaptation of the example you refer to, replacing -di-
with -nlcom-. The p-value in -nlcom- is in this case useless as it
tests the hypothesis that the odds ratio is 0 rather than the
meaningfull hypothesis that the odds ratio is 1.

You can also see the confidence interval produced by -nlcom- is
somewhat different from the confidence interval produced by -logit-
even though the coefficient and the standard error match exactly. The
reason for that is explained here:

*------------------------ begin example ------------------------------------
sysuse nlsw88, clear
gen byte high_occ = occupation < 3 if occupation < .
gen byte black = race == 2 if race < .
drop if race == 3
gen byte baseline = 1

sum ttl_exp
gen c_ttl_exp = ttl_exp - r(mean)

// fix at average ttl_exp (12.5 years)

logit high_occ black##collgrad c_ttl_exp baseline, or nocons

margins, over(black collgrad) expression(exp(xb())) ///
         at(c_ttl_exp = 0) post

nlcom (_b[] / _b[] ) / ///
      (_b[] / _b[])
*-------------------------- end example ------------------------------------
(For more on examples I sent to the Statalist see: )

Hope this helps,

Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index