Hi,
I am working with data on cost and quality of life to do a cost effectiveness analysis. I have some missing values I need to impute to then derive QALYs from qol and life years. I have the following code:
I then need to bootstrap the coefficients from an sureg and thought about the following:
The problem seems to be that in the mi register passive command, the variable qaly is not found (even though I have 5 variables named _1_qaly _2_qaly _3_qaly _4_qaly _5_qaly in the data according to each imputation). I am not sure what has gone wrong here as I would have thought Stata would pick up the imputations by the variable names.
Grateful for any help with this.
I am working with data on cost and quality of life to do a cost effectiveness analysis. I have some missing values I need to impute to then derive QALYs from qol and life years. I have the following code:
Code:
mi set wide mi stset, clear mi register imputed qol1 qol2 qol3 qol4 qol5 cost1 cost2 cost3 cost4 cost5 mi register regular ID sex treatment age qol0 survival_time censored date0 date1 date2 date3 date4 date5 /// event0 event1 event2 event3 event4 event5 flag obs_to_drop mean_time_exp mean_time_exp_years /// mean_time_logl mean_time_logl_years mean_time_logn mean_time_logn_years med_time_gom med_time_gom_years /// mean_time_wei mean_time_wei_years // impute the missing data mi impute chained (pmm,knn(3)) qol1 qol2 qol3 qol4 qol5 cost1 cost2 cost3 cost4 cost5 = sex age qol0 /// mean_time_logn_years, by(treatment) replace add(5) // calculate qalys for each imputation forval y=1/5 { local _`y'_qol1 "((qol0 + _`y'_qol1)/2 * (date1-date0)/365.25)" * local _`y'_qol1_d "((0 + _`y'_qol1)/2 * (date1-date0)/365.25)" local _`y'_qol2 "((_`y'_qol1 + _`y'_qol2)/2 * (date2-date1)/365.25)" local _`y'_qol2_d "((_`y'_qol1 + 0)/2 * (date2-date1)/365.25)" local _`y'_qol3 "((_`y'_qol2 + _`y'_qol3)/2 * (date3-date2)/365.25)" local _`y'_qol3_d "((_`y'_qol2 + 0)/2 * (date3-date2)/365.25)" local _`y'_qol4 "((_`y'_qol3 + _`y'_qol4)/2 * (date4-date3)/365.25)" local _`y'_qol4_d "((_`y'_qol3 + 0)/2 * (date4-date3)/365.25)" local _`y'_qol5 "((_`y'_qol4 + _`y'_qol5)/2 * (date5-date4)/365.25)" local _`y'_qol5_d "((_`y'_qol4 + 0)/2 * (date5-date4)/365.25)" local _`y'_qol6 "((_`y'_qol5 + 0)/2 * ((mean_time_logn+date0)-date5)/365.25)" gen _`y'_qaly=. // nobody dead at 1. replace _`y'_qaly = `_`y'_qol1' + `_`y'_qol2_d' if event1==0 & event2==1 // dead at 2 replace _`y'_qaly = `_`y'_qol1' + `_`y'_qol2'+ `_`y'_qol3_d' if event2==0 & event3==1 // dead at 3 replace _`y'_qaly = `_`y'_qol1' + `_`y'_qol2' + `_`y'_qol3' + `_`y'_qol4_d' if event3==0 & event4==1 // dead at 4 replace _`y'_qaly = `_`y'_qol1' + `_`y'_qol2' + `_`y'_qol3' + `_`y'_qol4' + `_`y'_qol5_d' if event4==0 & event5==1 // dead at 5 replace _`y'_qaly = `_`y'_qol1' + `_`y'_qol2' + `_`y'_qol3' + `_`y'_qol4' + `_`y'_qol5' + `_`y'_qol6' if event5==0 // censored } // gen total costs forval y=1/5 { egen _`y'_totcost = rowtotal(_`y'_cost1 _`y'_cost2 _`y'_cost3 _`y'_cost4 _`y'_cost5) }
Code:
program define myboot, rclass mi set wide * mi stset, clear mi register passive qaly totcost mi register imputed qol1 qol2 qol3 qol4 qol5 cost1 cost2 cost3 cost4 cost5 mi register regular ID sex treatment age qol0 survival_time censored date0 date1 date2 date3 date4 date5 /// event0 event1 event2 event3 event4 event5 flag obs_to_drop mean_time_exp mean_time_exp_years /// mean_time_logl mean_time_logl_years mean_time_logn mean_time_logn_years med_time_gom med_time_gom_years /// mean_time_wei mean_time_wei_years mi estimate, cmdok: sureg (tot_cost age i.sex i.treatment) (qaly age i.sex i.treatment) return scalar b_q01 = el(e(b_mi),1,1) // still need to specify the exact elements correctly in these few lines... return scalar b_q02 = el(e(b_mi),1,1) return scalar b_c01 = el(e(b_mi),1,1) return scalar b_c02 = el(e(b_mi),1,1) end * Save bootstrapped coefficients bootstrap b_qaly01=r(b_q01) b_qaly02=r(b_q02) b_cost01=r(b_c01) b_cost02=r(b_q02), reps(1000) saving("$working\bootstrap_results.dta", replace): myboot
Grateful for any help with this.
Comment