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.

# Re: st: odds ratios and confidence intervals after mlogit with a dummy X

 From Jeremy Reynolds To "statalist@hsphsun2.harvard.edu" Subject Re: st: odds ratios and confidence intervals after mlogit with a dummy X Date Tue, 5 Mar 2013 20:48:32 -0500

```Thank you very much, Maarten.  Your solution works beautifully.

If I want to get the odds ratio of foreign for values of price (rather
than the odds ratios of price for foreign cars), I think I can use the
code below.

mlogit rep78 c.price##i.foreign weight, rrr
lincom _b[4:1.foreign] + _b[4:1.foreign#c.price], rrr // OR of foreign
for 1 unit increase in price
di 27.88998 *  1.788271 // same result as lincom 49.874842
lincom _b[4:1.foreign] + 2*_b[4:1.foreign#c.price], rrr // OR of
foreign for 2 unit increase in price
di 27.88998 *  1.788271^2 // same result as lincom 89.189734

I'm not sure, however, how to replicate these results (primarily the
first one)  with mlogit.  Can you show me how to specify that model?

Thanks,

Jeremy

On Tue, Mar 5, 2013 at 2:25 PM, Maarten Buis <maartenlbuis@gmail.com> wrote:
>
> The fact that mathematically equivalent null hypotheses do not
> necessarily lead to the same test outcome with non-linear Wald tests
> is documented in -help testnl-. I would use -lincom- with the -rrr-
> option. That will exactly reproduce the results as returned by
> -mlogit-:
>
> *------------------- begin example --------------------
> sysuse auto, clear
> recode rep78 1/2=3
> replace weight = (weight -3000) / 2000
> replace price = (price - 6000) / 1000
>
> // regular interaction effect
> mlogit rep78 c.price##i.foreign weight, rrr
>
> // create the odds ratios of price for foreign cars
> // using lincom
> lincom _b[4:price] + _b[4:1.foreign#c.price], rrr
>
> // check against -mlogit- without reference category
> // the results are the same
> mlogit rep78 c.price#ibn.foreign ibn.foreign weight, nocons rrr
> *-------------------- end example ---------------------
>
> Hope this helps,
> Maarten
>
> On Tue, Mar 5, 2013 at 7:07 PM, Jeremy Reynolds <jeremyr@uga.edu> wrote:
> > Dear Statalist,
> >
> > I would like to calculate odds ratios and associated confidence
> > intervals after a multinomial logit that involves an interaction
> > between a dummy variable and a continuous variable along with other
> > covariates.  The confidence intervals for the different levels of the
> > continuous variable are important because the dummy variable has a
> > negative sign and the interaction a positive sign.  I would like to
> > determine when the dummy variable decreases and and when it increases
> > the odds of one outcome in the mlogit.
> >
> > Drawing on posts to the statalist and Martin Buis' website
> > (http://www.maartenbuis.nl/publications/interactions.html
> > ), I have written code to calculate the odds ratios associated with
> > the dummy variable for different levels of the continuous variable
> >
> > However, there appear to be two potential problems with this approach.
> >
> > First, nlcom tests whether the odds ratios are different from zero. I
> > have subtracted 1 from the odds ratio to get the equivalent of testing
> > whether it is different from 1, but the help file for nlcom makes me
> > wonder if this procedure is appropriate.
> >
> > From the help file for nlcom:
> > "For instance, the two hypotheses
> >         H0: coefficient = 0
> >         H0: exp(coefficient) - 1 = 0
> > are mathematically equivalent expressions but do not yield the same
> > test statistic and p-value."
> >
> > 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
> > 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/
>
>
>
> --
> ---------------------------------
> Maarten L. Buis
> WZB
> Reichpietschufer 50
> 10785 Berlin
> Germany
>
> http://www.maartenbuis.nl
> ---------------------------------
> *
> *   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/
>
>

--
********************
Dr. Jeremy Reynolds
Associate Professor
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/
```