***=======================================================* * FEM scenario combination - lifetime * Sep 25, 2008 ***=======================================================* clear cap clear mata set more off set mem 500m set linesize 255 ***=============================* global workdir "//zeno/a/DOL/Othercodes_yh" global indata "//zeno/a/DOL/Input_yh" global indata2 "//zeno/a/DOL/Indata_yh" global outdata "//zeno/a/DOL/Output_yh" global tabdata "/zeno/a/DOL/Tables_yh" * For local global workdir "//zeno/zeno_a/DOL/Othercodes_ahg" global indata "//zeno/zeno_a/DOL/Input_yh" global indata2 "//zeno/zeno_a/DOL/Indata_yh" global outdata "//zeno/zeno_a/DOL/Output_yh" global tabdata "//zeno/zeno_a/DOL/Tables_yh" global outdata "//zeno/zeno_a/DOL/Output_yh" global tabdata "//zeno/zeno_a/DOL/Output_yh" capt log close log using "$workdir/lifetime_summary_yh.log", replace global scnr "status_quo04 shareprev04 status_quo30 obese_r30 invobese_r30 nosmoke_r30 shareprev30 status_quo50 obese_r50 invobese_r50 nosmoke_r50 shareprev50 " * global scnr "status_quo04 shareprev04 status_quo30 obese_r30 nosmoke_r30 shareprev30 status_quo50 obese_r50 nosmoke_r50 shareprev50 " global scnr status_quo04 s80 local disrate1 = 0 local disrate2 = 0.03 set trace off local i = 0 foreach x in $scnr { local i = `i' + 1 } matrix matr = J(`i',16,.) matrix rownames matr = $scnr matrix colnames matr = ID LE HEALTH_LE GOVREV GOVEXP LFSPEND ssben ssiben diben caremd caidmd ftax stax ctax hoasi hmed ********************************* * Adjustment factors ********************************* local adj_totmd65l = 1.31 local adj_caremd65l = 1.59 local adj_caidmd65l = 2.53 local adj_totmd65p = 1.14 local adj_caremd65p = 1.11 local adj_caidmd65p = 1.64 local sorder = 1 foreach scr in $scnr { matrix matr[rownumb(matr,"`scr'"), colnumb(matr,"ID")] = `sorder' local sorder = `sorder' + 1 drop _all use "$outdata//5152_s`scr'_c.dta" **************** * Adjust for medical costs **************** foreach v in totmd caremd caidmd { replace ttl_`v'l = ttl_`v'l * `adj_`v'65l' replace ttl_`v'p = ttl_`v'p * `adj_`v'65p' replace ttl_`v' = (ttl_`v'l + ttl_`v'p)/10^9 } gen govexp = ttl_ssben + ttl_ssiben + ttl_diben + ttl_caremd + ttl_caidmd gen govrev = ttl_ftax + ttl_stax + ttl_ctax + ttl_hoasi + ttl_hmed keep year pop pop_healthy govrev govexp ttl_totmd ttl_ssben ttl_ssiben ttl_diben ttl_caremd ttl_caidmd ttl_ftax ttl_stax ttl_ctax ttl_hoasi ttl_hmed * Include odds years qui sum year local myr = r(min) sort year, stable expand 2 sort year, stable gen year_old = year replace year = `myr' + _n-1 gen id = 1 foreach x in pop pop_healthy { gen `x'_old = `x' local k1 = _n+1 local k2 = _n-1 xtset id year sort id year replace `x' = (f.`x' + l.`x')/2 if _n > 1 & _n < _N & mod(year,2) != 0 replace `x' = `x' * ((1/(1+`disrate1'))^(year-2004)) } foreach x in govrev govexp ttl_totmd ttl_ssben ttl_ssiben ttl_diben ttl_caremd ttl_caidmd ttl_ftax ttl_stax ttl_ctax ttl_hoasi ttl_hmed { gen `x'_old = `x' local k1 = _n+1 local k2 = _n-1 xtset id year sort id year replace `x' = (f.`x' + l.`x')/2 if _n > 1 & _n < _N & mod(year,2) != 0 replace `x' = `x' * ((1/(1+`disrate2'))^(year-2004)) } * LE, disable-free LE, lifetime ME qui sum pop if year == `myr' local init_pop = r(mean) qui sum pop local ttlyr = r(sum) matrix matr[rownumb(matr,"`scr'"), colnumb(matr,"LE")] = `ttlyr'/`init_pop' qui sum pop_healthy if year == `myr' local init_pop_hlth = r(mean) qui sum pop_healthy local ttlyr = r(sum) * matrix matr[rownumb(matr,"`scr'"), colnumb(matr,"HEALTH_LE")] = `ttlyr'/`init_pop_hlth' matrix matr[rownumb(matr,"`scr'"), colnumb(matr,"HEALTH_LE")] = `ttlyr'/`init_pop' qui sum ttl_totmd local ttlmd = r(sum) matrix matr[rownumb(matr,"`scr'"), colnumb(matr,"LFSPEND")] = int(`ttlmd'*1000/`init_pop' ) qui sum govrev local ttl = r(sum) matrix matr[rownumb(matr,"`scr'"), colnumb(matr,"GOVREV")] =int( `ttl'*1000/`init_pop') qui sum govexp local ttl = r(sum) matrix matr[rownumb(matr,"`scr'"), colnumb(matr,"GOVEXP")] = int(`ttl'*1000/`init_pop') foreach i in ssben ssiben diben caremd caidmd ftax stax ctax hoasi hmed{ qui sum ttl_`i' local ttl = r(sum) matrix matr[rownumb(matr,"`scr'"), colnumb(matr,"`i'")] = int(`ttl'*1000/`init_pop') } } matrix list matr drop _all svmat matr, names(col) sort ID, stable gen n = _n local sorder = 1 gen scenario = "" foreach scr in $scnr { replace scenario = "`scr'" if `sorder' == n local sorder = `sorder' + 1 } drop ID n outsheet scenario LE HEALTH_LE GOVREV GOVEXP LFSPEND ssben ssiben diben caremd caidmd ftax stax ctax hoasi hmed using "$tabdata//lftime_summary.csv", replace comma nol log close capt log close