We have to do a duration model with ens_dur.dta to look for spell to quit smoking, and what covariates affects its duration and how to reduce it. We have made this code, but we dont know what hazard function to specify (weibull, log logistic...) , or to use a cox hazard. We are just beginners and we have written that, can you help us? Have we to test for Proporitonal Hazard?
Dataset: https://gofile.io/?c=SL3Jow
Dataset: https://gofile.io/?c=SL3Jow
Code:
use ens_dur.dta /*Descriptive Statistics */ des sum tab smoker tab physical_act tab bmi tab health_q tab d_compl_init tab d_compl_quit /* Drop observations for Ceuta and Melilla */ drop if ccaa>=18 /* Create binary dummies */ gen native=0 replace native=1 if Spanish==1 gen female=0 replace female=1 if sex==2 gen chrill=0 replace chrill=1 if chronic==1 /* Setting the duration and the censoring variables */ stset dur_quit, failure(d_compl_quit) /* Empirical hazard */ sts graph, hazard /* Estimation of continuous time duration models */ /* Basic models */ streg, dist(exponential) nohr streg, dist(weibull) nohr streg, dist(loglogistic) streg, dist(lognormal) streg, dist(ggamma) streg, dist(gompertz) stcox, estimate /* Complete model */ streg c.age##c.age female native i.ccaa i.size_mun i.marital_st /* */ i.health_q chrill i.bmi i.physical_act, dist(exponential) nohr streg c.age##c.age female native i.ccaa i.size_mun i.marital_st /* */ i.health_q chrill i.bmi i.physical_act, dist(weibull) nohr streg c.age##c.age female native i.ccaa i.size_mun i.marital_st /* */ i.health_q chrill i.bmi i.physical_act, dist(loglogistic) streg c.age##c.age female native i.ccaa i.size_mun i.marital_st /* */ i.health_q chrill i.bmi i.physical_act, dist(lognormal) streg c.age##c.age female native i.ccaa i.size_mun i.marital_st /* */ i.health_q chrill i.bmi i.physical_act, dist(ggamma) streg c.age##c.age female native i.ccaa i.size_mun i.marital_st /* */ i.health_q chrill i.bmi i.physical_act, dist(gompertz) nohr stcox c.age##c.age female native i.ccaa i.size_mun i.marital_st /* */ i.health_q chrill i.bmi i.physical_act, nohr estat phtest
Comment