Reputation:
I run a logistic model for young people and another logistic model with the same prognostic factors for old people. I would like to compare the two ORs for each prognostic factor between the two groups old and young people. I need to test if two odds ratios are significantly different and get a p-value for the difference between the two groups. Can you please give me the Stata commands to do that?
Upvotes: 0
Views: 2639
Reputation: 2694
// data preparation
sysuse auto, clear
gen byte good = (rep78 > 3) if !missing(rep78)
replace price = price / 1000
label var price "price in 1000s dollars"
// ============================= method 1
// estimate the models separately
logit good price mpg if foreign == 0
est store dom
logit good price mpg if foreign == 1
est store for
// combine the models
suest dom for
// test
test [dom_good]mpg = [for_good]mpg
// see the chi^2 value in more detail:
di r(chi2)
// ============================= method 2
// do it all in one model without any
// post-estimation commands
logit good i.foreign##(c.price c.mpg), vce(robust)
// look at the p-value next to the coefficient of
// the interaction term between foreign and mpg
// ============================= bonus
// Show that the two methods are exactly the same
// method 2 reportes the test as a z-statistic, but
// the p-value is the same. we can transform the
// z-statistic and see that method 2 results in
// the exact same chi^2 value:
di (_b[1.foreign#c.mpg]/_se[1.foreign#c.mpg])^2
I personally prefer method 2. However, the current state of the art is that you cannot compare these odds ratios (I disagree, but I am a minority) see, e.g.
Allison, P. D. (1999). Comparing logit and probit coefficients across groups. Sociological Methods & Research 28(2), 186–208. http://dx.doi.org/10.1177/0049124199028002003
Breen, R., Holm, A. and Karlson, K. B. (2014). Correlations and Nonlinear Probability Models. Sociological Methods & Research 43(4), 571-605. http://dx.doi.org/10.1177/0049124114544224
Mood, C. (2010). Logistic regression: Why we cannot do what we think we can do, and what we can do about it. European Sociological Review, 26(1), 67-82. http://dx.doi.org/10.1093/esr/jcp006
Neuhaus, J. M. and N. P. Jewell (1993). A geometric approach to assess bias due to omited covariates in generalized linear models. Biometrika 80(4), 807–815. http://dx.doi.org/10.1093/biomet/80.4.807
Williams, R. (2009). Using heterogenous choice models to compare logit and probit coefficients across groups. Sociological Methods & Research 37(4), 531–559. http://dx.doi.org/10.1177/0049124109335735
Upvotes: 2