Hi Statalisters,
Suppose I am interested in examining two outcomes within my data set. And suppose these two outcomes represent related concepts. If I run two separate outcome models for a given set of explanatory variables, I am wondering if there is a way to compare whether estimates are consistent across models?
For example, say I am interested in looking at length and weight as my two outcomes. I could run the models with the same set of explanatory variables and compare whether the estimates are in the same direction or magnitude.
However, this would be very subjective. Is there a way to generate a statistical test of heterogeneity similar to what a Q-statistic would give in a meta-analysis?
Would it be possible to incorporate an interaction term in the models? For example, if we considered the two outcome models as being "stratified" models from some pseudo population that contains duplicate observations for each individual. Ignoring the fact that the observations are correlated, would something similar to the below code work?
Suppose I am interested in examining two outcomes within my data set. And suppose these two outcomes represent related concepts. If I run two separate outcome models for a given set of explanatory variables, I am wondering if there is a way to compare whether estimates are consistent across models?
For example, say I am interested in looking at length and weight as my two outcomes. I could run the models with the same set of explanatory variables and compare whether the estimates are in the same direction or magnitude.
Code:
sysuse auto, clear
/* dichotomize at median to generate binary outcome 1 */
generate largeyn=1 if length>=192.5 & length!=.
replace largeyn=0 if length<192.5
tab largeyn, missing
/* dichotomize at median to generate binary outcome 2 */
generate heavyyn=1 if weight>=3190 & weight!=.
replace heavyyn=0 if weight<3190
tab heavyyn, missing
/* manually compare estimates from each model */
logistic largeyn trunk turn headroom
logistic heavyyn trunk turn headroom
. logistic largeyn trunk turn headroom
Logistic regression Number of obs = 74
LR chi2(3) = 76.12
Prob > chi2 = 0.0000
Log likelihood = -13.231694 Pseudo R2 = 0.7420
------------------------------------------------------------------------------
largeyn | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
trunk | 1.825171 .4418256 2.49 0.013 1.135665 2.933303
turn | 1.956289 .3878218 3.38 0.001 1.32644 2.885215
headroom | 1.163899 .9530395 0.19 0.853 .2338425 5.793053
_cons | 6.51e-16 5.88e-15 -3.87 0.000 1.31e-23 3.23e-08
------------------------------------------------------------------------------
. logistic heavyyn trunk turn headroom
Logistic regression Number of obs = 74
LR chi2(3) = 71.06
Prob > chi2 = 0.0000
Log likelihood = -15.762918 Pseudo R2 = 0.6927
------------------------------------------------------------------------------
heavyyn | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
trunk | 1.286904 .2192673 1.48 0.139 .9215427 1.797119
turn | 2.036741 .3769406 3.84 0.000 1.41711 2.927306
headroom | 1.690922 1.260841 0.70 0.481 .3921233 7.291629
_cons | 4.56e-15 3.56e-14 -4.24 0.000 1.07e-21 1.95e-08
------------------------------------------------------------------------------
/*
COMPARE ESTIMATES ACROSS MODELS:
for trunk: 1.83 versus 1.29
for turn: 1.96 versus 2.04
for headroom: 1.16 versus 1.69
*/
Would it be possible to incorporate an interaction term in the models? For example, if we considered the two outcome models as being "stratified" models from some pseudo population that contains duplicate observations for each individual. Ignoring the fact that the observations are correlated, would something similar to the below code work?
Code:
sysuse auto, clear
/* dichotomize at median to generate binary outcome 1 */
generate largeyn=1 if length>=192.5 & length!=.
replace largeyn=0 if length<192.5
tab largeyn, missing
/* dichotomize at median to generate binary outcome 2 */
generate heavyyn=1 if weight>=3190 & weight!=.
replace heavyyn=0 if weight<3190
tab heavyyn, missing
/* manually compare estimates from each model */
logistic largeyn trunk turn headroom
logistic heavyyn trunk turn headroom
/* create pseudo dataset */
preserve
generate model=0
generate outcome=largeyn
count
save pseudo1.dta, replace
restore
preserve
generate model=1
generate outcome=heavyyn
count
save pseudo2.dta, replace
restore
/* append the two datasets */
clear
use pseudo1.dta, clear
append using pseudo2.dta
count
/* run stratified models using psuedo data, should be same as above */
logistic outcome trunk turn headroom if model==0
logistic outcome trunk turn headroom if model==1
/* instead of running stratified models, compare estimates using statistical interaction test */
logistic outcome c.trunk##i.model c.turn##i.model c.headroom##i.model
. logistic outcome c.trunk##i.model c.turn##i.model c.headroom##i.model
Logistic regression Number of obs = 148
LR chi2(7) = 147.18
Prob > chi2 = 0.0000
Log likelihood = -28.994612 Pseudo R2 = 0.7174
----------------------------------------------------------------------------------
outcome | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-----------------+----------------------------------------------------------------
trunk | 1.825171 .4418256 2.49 0.013 1.135665 2.933303
1.model | 7.014033 83.71004 0.16 0.870 4.87e-10 1.01e+11
|
model#c.trunk |
1 | .7050868 .2087225 -1.18 0.238 .3946996 1.259559
|
turn | 1.956289 .3878218 3.38 0.001 1.32644 2.885215
|
model#c.turn |
1 | 1.041125 .2823573 0.15 0.882 .6118622 1.771545
|
headroom | 1.163899 .9530395 0.19 0.853 .2338425 5.793053
|
model#c.headroom |
1 | 1.452808 1.608938 0.34 0.736 .1657789 12.73171
|
_cons | 6.51e-16 5.88e-15 -3.87 0.000 1.31e-23 3.23e-08
----------------------------------------------------------------------------------
/* display stratum-specific estimates for largeyn outcome*/
lincom _b[trunk]
lincom _b[turn]
lincom _b[headroom]
. lincom _b[trunk]
( 1) [outcome]trunk = 0
------------------------------------------------------------------------------
outcome | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
(1) | 1.825171 .4418256 2.49 0.013 1.135665 2.933303
------------------------------------------------------------------------------
. lincom _b[turn]
( 1) [outcome]turn = 0
------------------------------------------------------------------------------
outcome | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
(1) | 1.956289 .3878218 3.38 0.001 1.32644 2.885215
------------------------------------------------------------------------------
. lincom _b[headroom]
( 1) [outcome]headroom = 0
------------------------------------------------------------------------------
outcome | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
(1) | 1.163899 .9530395 0.19 0.853 .2338425 5.793053
------------------------------------------------------------------------------
/* display stratum-specific estimates for heavyyn outcome */
lincom _b[trunk]+_b[1.model#c.trunk]
lincom _b[turn]+_b[1.model#c.turn]
lincom _b[headroom]+_b[1.model#c.headroom]
. lincom _b[trunk]+_b[1.model#c.trunk]
( 1) [outcome]trunk + [outcome]1.model#c.trunk = 0
------------------------------------------------------------------------------
outcome | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
(1) | 1.286904 .2192673 1.48 0.139 .9215427 1.797119
------------------------------------------------------------------------------
. lincom _b[turn]+_b[1.model#c.turn]
( 1) [outcome]turn + [outcome]1.model#c.turn = 0
------------------------------------------------------------------------------
outcome | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
(1) | 2.036741 .3769406 3.84 0.000 1.41711 2.927306
------------------------------------------------------------------------------
. lincom _b[headroom]+_b[1.model#c.headroom]
( 1) [outcome]headroom + [outcome]1.model#c.headroom = 0
------------------------------------------------------------------------------
outcome | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
(1) | 1.690922 1.260841 0.70 0.481 .3921233 7.291629
------------------------------------------------------------------------------
/*
now, comparing the stratum-specific estimates calculated using the interaction term (same values as the stratified models):
for trunk: 1.83 versus 1.29
for turn: 1.96 versus 2.04
for headroom: 1.16 versus 1.69
but now we have a statistical test of heterogeneity (the p-value associated with the interaction term):
trunk estimates not significantly different across outcome models (interaction p-value 0.238)
turn estimates not significantly different across outcome models (interaction p-value 0.882)
headroom estimates not significantly different across outcome models (interaction p-value 0.736)
*/
/* remove data */
rm pseudo1.dta
rm pseudo2.dta

Comment