Hello,
I am using data from http://www.stata-press.com/data/heus/heus_mepssample
I am using these sample data from Stata to understand the model before applying the methodology to my data.
I am trying to implement a hurdle model, with the first part being a logit model and the second part being a negative binomial model.
I have implemented the following for the first part:
*create dependent variable for the logit model:
gen pzero = use_off
replace pzero = 1 if use_off >0
logit pzero age i.female
estimates store h1
predict xb1
margins, dydx(age female)
for the second part if have implemented the following:
tnbreg use_off age i.female if use_off >0
predict xb2 if use_off >0
estimates store h2
margins, dydx(age female)
suest h1 h2
I can produce the marginal analysis for both models combined as follows ( based on :Health Econometrics
Using Stata (2017) by Deb Norton & Manning)
local logit "invlogit(predict(eq(h1_any_off)))"
local ey "exp(predict(eq(h2_use_off))) "
local pygt0 "(nbinomialtail(exp(-predict(eq(/h2:lnalpha))),1," ///
"1/(1+exp(predict(eq(h2_use_off)))/exp(-predict(eq(/h2:lnalpha))))))"
margins, dydx(*) expression ("`logit'*`ey'/`pygt0'")
However, when I come to implement this model approach to my data, I will need to predict for all observations, including those observations where use_off ==0. I am not sure how best to do this. Do I just multiple the xb1 by xb2 (but have eb2 predicted across the entire set of observations not just those with use_off >0)?
I am using data from http://www.stata-press.com/data/heus/heus_mepssample
I am using these sample data from Stata to understand the model before applying the methodology to my data.
I am trying to implement a hurdle model, with the first part being a logit model and the second part being a negative binomial model.
I have implemented the following for the first part:
*create dependent variable for the logit model:
gen pzero = use_off
replace pzero = 1 if use_off >0
logit pzero age i.female
estimates store h1
predict xb1
margins, dydx(age female)
for the second part if have implemented the following:
tnbreg use_off age i.female if use_off >0
predict xb2 if use_off >0
estimates store h2
margins, dydx(age female)
suest h1 h2
I can produce the marginal analysis for both models combined as follows ( based on :Health Econometrics
Using Stata (2017) by Deb Norton & Manning)
local logit "invlogit(predict(eq(h1_any_off)))"
local ey "exp(predict(eq(h2_use_off))) "
local pygt0 "(nbinomialtail(exp(-predict(eq(/h2:lnalpha))),1," ///
"1/(1+exp(predict(eq(h2_use_off)))/exp(-predict(eq(/h2:lnalpha))))))"
margins, dydx(*) expression ("`logit'*`ey'/`pygt0'")
However, when I come to implement this model approach to my data, I will need to predict for all observations, including those observations where use_off ==0. I am not sure how best to do this. Do I just multiple the xb1 by xb2 (but have eb2 predicted across the entire set of observations not just those with use_off >0)?