Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: Bug in margins
From
Richard Williams <[email protected]>
To
[email protected], "[email protected]" <[email protected]>
Subject
RE: st: Bug in margins
Date
Fri, 30 Aug 2013 12:23:45 -0500
At 10:58 AM 8/30/2013, Joe Canner wrote:
Roland,
The requirement that the original model be specified including "i."
is also buried deep in the PDF documentation for -margins- (page
1063 of r.pdf). The original model runs fine because binary
variables don't need the "i.", but for whatever reason -margins- requires it.
With the margins command, the vars to the left of the comma must be a
"list of factor variables or interactions that appear in the current
estimation results." The i. notation in the estimation command tells
Stata the variable is categorical; otherwise it assumes it is
continuous. When you put a factor variable on the left hand side of
the margins command, Stata is going to do things like give you
predicted values for men and women. You don't want to put a
continuous variable on the left hand side because continuos variables
potentially have an infinite number of values.
The continuous /categorical distinction is also important because
marginal effects are computed differently for continuous and categorical vars.
Of course, you might say, if a variable is coded 0/1, why doesn't
Stata just assume it is categorical rather than continuous? After
all, that is what the old -mfx- command does. I believe Nick Cox made
the point once that a variable coded 0/1 could actually be
continuous, but only the values of 0 and 1 were observed in the
sample. Plus I suppose it makes it easier for coding if Stata
requires you to be explicit about whether or not a variable is categorical.
Joe Canner
Johns Hopkins University School of Medicine
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Richard Williams
Sent: Friday, August 30, 2013 12:51 PM
To: [email protected]; [email protected]
Subject: Re: st: Bug in margins
First off, your 2 logistic commands look identical to me. I'm
guessing that when you ran it the first time and got the error, you
did not have the i.
Assuming that is the case, this is no error. The i. tells Stata that
the variable is categorical rather than continuous. See the help for
margins. Or, for some highlights on the margins command, see
http://www3.nd.edu/~rwilliam/stats/Margins01.pdf
At 10:39 AM 8/30/2013, roland andersson wrote:
>I am analysing a logistic regression model, binary outcome. I want to
>analyse the adjusted proportion of the outcome for a binary (0/1)
>covariate.
>
>I run the logistic model followed by margins . logistic dod30dgr
>i.lapscopiintent alder aldersq........
>. margins lapscopiintent
>
>I get an error
>'lapscopiintent' not found in list of covariates r(322);
>
>If I put i. before the binary variable I am interested in
>
>. logistic dod30dgr i.lapscopiintent alder aldersq................
>. margins lapscopiintent
>
>Predictive margins Number of obs = 166811
>Model VCE : OIM
>
>Expression : Pr(dod30dgr), predict()
>
>Delta-method
>Margin Std. Err. z P>z [95% Conf. Interval]
>lapscopiin~t
>0 .0015466 .0000985 15.70 0.000 .0013535 .0017397
>1 .0011487 .0002518 4.56 0.000 .0006552 .0016421
>
>I assume this is a bug?
>
>Roland Andersson
-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME: (574)289-5227
EMAIL: [email protected]
WWW: http://www.nd.edu/~rwilliam
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/