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]
[no subject]
Second, exchanges on the statalist have suggested that the confidence
intervals calculated by nlcom may not be the what I want:
http://www.stata.com/statalist/archive/2011-12/msg00389.html
I would be grateful to hear recommendations regarding how to calculate
the odds ratios I want.
Is the approach in the code below okay?
Should I use the margins command instead?
When I have seen people use the margins command to get odds and then
calculate odds ratios, they have been working with interactions
between dummy variables and logistic regression.
For example: http://www.stata.com/statalist/archive/2011-05/msg00776.html
I am not sure how to use margins with a dummy X continuous interaction
and a mlogit model where I must specify which outcome I want. The use
of expression(exp(xb())) for getting the odds seems to preclude the
use of the predict() option that is used to specify which outcome to
use.
Thanks,
Jeremy
******************
*mlogit with binary by continuous interaction
*slightly modified from example posted at
http://www.stata.com/statalist/archive/2010-10/msg00149.html
*****************
sysuse auto, clear
// create an indicator variable that is
// 1 when an observation has valid values
// on mpg, price, and rep78, and 0 otherwise
gen byte touse = !missing(mpg, price, rep78)
// center mpg
sum mpg if touse, meanonly
gen c_mpg = mpg - r(mean)
// center price and change unit to 1000s of $
sum price if touse, meanonly
*recode price so cheapest car =0
gen c_price = (price - r(min))/1000 // I have changed this line to
subtract the min rather than the mean
sum c_price
// see the example FAQ
recode rep78 1/2 = 3
gen byte baseline = 1
// add value labels to rep78
label define rep78 3 "Average" ///
4 "Good" ///
5 "Excellent"
label value rep78 rep78
// the model
mlogit rep78 foreign##c.c_price c_mpg baseline, rrr nocons // the
original post had an interaction between c_mpg and c_price
*calculate odds ratio for foreign (outcome=Good) with 1,000-9,000
increases in price
sum c_price if e(sample)
foreach x of numlist 1/9 {
di "Odds Ratio for foreign with a `x' thousand dollar increase in price."
nlcom exp(_b[Good:1.foreign])*exp(_b[Good:1.foreign#c.c_price])^`x' - 1
}
--
********************
Dr. Jeremy Reynolds
Associate Professor
Undergraduate Coordinator
Department of Sociology
117 Baldwin Hall
University of Georgia
Athens, GA 30602-1611
Phone: (706) 583-8072
Web: http://uga.edu/soc/people/faculty/reynolds_jeremy.php
Fax: (706) 542-4320
*
* 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/