# st: RE: CIs for the ratio of two adjusted predictions after logistic?

 From "Maarten Buis" To Subject st: RE: CIs for the ratio of two adjusted predictions after logistic? Date Wed, 1 Aug 2007 17:08:41 +0200

```--- Daniel Waxman wrote:
> I have a logistic model with two terms (one continuous and one dichotomous)
> and an interaction term, and would like to calculate the relative risks
> (ratio of predicted probabilities) for the two possible values of the
> dichotomous variable, at each value of the continuous variable.  The
> question is:  How do I construct confidence intervals for this proportion?

The trick is to do the entire computation in one -predictnl- command, and
than use the -se()- option, see the example below:

*---------- begin example ------------------
sysuse auto, clear
gen good = rep78 >3 if rep78 < .
gen foreignXmpg = foreign*mpg
logit good mpg foreign foreignXmpg

#delim ;
local xb_for "_b[_cons] + _b[foreign] +
_b[mpg]*mpg + _b[foreignXmpg]*mpg" ;
#delim cr

local xb_dom "_b[_cons] + _b[mpg]*mpg"

predictnl rr = invlogit(`xb_for')/ /*
*/ invlogit(`xb_dom'), se(se_rr)

gen ub = rr + 1.96*se_rr
gen lb = rr - 1.96*se_rr

sort mpg
twoway rarea ub lb mpg, astyle(ci) || /*
*/ line rr mpg, clstyle(solid) /*
*/ legend(order(2 1) /*
*/  label(1 "95% confidence" "interval") /*
*/  label(2 "risk ratio")) /*
*/  yline(1)
*----------- end example -------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Notice that interaction terms in -logit- (or any glm with a
link function other than the identity and I believe the log)
is a tricky issue, see for instance (Allison 1999).

Allison, Paul D. 1999. "Comparing Logit and Probit
Coefficients Across Groups." Sociological Methods &
Research 28(2):186-208.

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```