From: Subject: Date: Wed, 9 Dec 2009 11:39:47 -0600 MIME-Version: 1.0 Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Content-Location: http://www.chicagofed.org/economic_research_and_data/research_resources/files/rr_french_medex.do X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350
# delimit ;=20
clear;=20
set mem 300m;=09
set more 1 ; =20
drop _all;
program drop _all;
log using c:\research\hrs\wealth\medex.log, replace ;=20


use c:\research\hrs\wealth\dataprep2;

* log medcost;
gen lmedcost=3Dln(medcost);
gen healage=3Dheal*age1;
*gen PIage=3Dheal*age1;
gen maleage=3Dmale*age1;


* drop married women;
sort HHID female realyear;
drop if HHID=3D=3DHHID[_n-1] & realyear=3D=3Drealyear[_n-1];

sort wave;
by wave: sum age1 dead medcost;

*this program generates a polynomial in adist;
program define makedist;
        version 3.1;
	drop PI2 PI3 PIage;
	gen PI2=3DPI*PI;
	gen PI3=3D PI2*PI;
	gen PIage=3DPI*age1;
end;
set trace off ;
makedist;


sum P*;



*this program generates a polynomial in adist;
program define genPIshift;
        version 3.1;
	replace PI=3DPip1;
	makedist;
	gen lmedcostp1=3Dageshiftvarc+PI*bPI+PI2*bPI2+(PIage*bPIage);
	replace PI=3DPip2;
	makedist;
	gen lmedcostp2=3Dageshiftvarc+PI*bPI+PI2*bPI2+(PIage*bPIage);
	replace PI=3DPip3;
	makedist;
	gen lmedcostp3=3Dageshiftvarc+PI*bPI+PI2*bPI2+(PIage*bPIage);
	replace PI=3DPip4;
	makedist;
	gen lmedcostp4=3Dageshiftvarc+PI*bPI+PI2*bPI2+(PIage*bPIage);


	gen _20th_percentile=3Dexp(lmedcostp1);
	gen _40th_percentile=3Dexp(lmedcostp2);
	gen _60th_percentile=3Dexp(lmedcostp3);
	gen _80th_percentile=3Dexp(lmedcostp4);
drop lmedcostp*;
end;



* OLS VERSUS FIXED EFFECTS;
* OLS is not consistent with what JOHN, Cristina and I have decided =
on--it is only descriptive;
if FE=3D=3D0{;
reg medcost age1 age2 age3 age4 if male=3D=3D0 & aa1=3D=3D1;
predict medpf1;

reg medcost age1 age2 age3 age4 if male=3D=3D0 & aa2=3D=3D1;
predict medpf2;

reg medcost age1 age2 age3 age4 if male=3D=3D0 & aa3=3D=3D1;
predict medpf3;

reg medcost age1 age2 age3 age4 if male=3D=3D0 & aa4=3D=3D1;
predict medpf4;
};

if FE=3D=3D1{;
* fixed effects ;
*xtreg lmedcost age1 age2 age3 age4 age5, fe i(HHID);
*xtreg lmedcost age1 age2 age3 age4 age5 heal, fe i(HHID);

xtreg lmedcost age1 age2 age3  heal healage maleage PIage, fe i(HHID);
predict lmedcostp;
* get predictions;
gen lmedcostres=3Dlmedcost-lmedcostp;
gen ageshift=3D_b[_cons]+(_b[age1]*age1)+(_b[age2]*age2) =
+(_b[age3]*age3);
gen healshift=3D_b[heal]+_b[healage]*age1;
gen maleshift=3D_b[maleage]*age1;
gen PIshift=3D_b[PIage]*age1;
gen bPIage=3D_b[PIage];
* now run an OLS regression on the residuals;
reg lmedcostres PI PI2 male;
predict respred;
gen b=3D_b[_cons];
replace ageshift=3Dageshift+_b[_cons];
gen ageshiftFINAL=3Dageshift;
gen bPI =3D_b[PI];
gen bPI2=3D_b[PI2];
gen bmale=3D_b[male];
replace maleshift=3Dmaleshift+_b[male];
replace PIshift=3DPIshift+_b[PI]; * do not add in quadratic term, as we =
keep track of that separately;
* see if cohort effects are important to worry about (as it turns out, =
they are);
reg lmedcostres PI PI2 cohort2 cohort3 cohort4 cohort5 cohort6 cohort7; =
* now generate percentiles of the distribution;

* figure out variance of residual;
gen resres=3Dlmedcostres-respred;
egen sdres=3Dsd(resres);
gen varc=3D(sdres*sdres);

/*
gen varc1=3Dresres*resres;
reg varc1 age1 ;
reg varc1 age1 age2 male heal PI;
sum varc*;
*/


gen ageshiftvarc=3Dageshift+(varc/2);

* gen medcostp=3Dexp(lmedcostp); * this term is meaningless, in the =
aggregate;
};


*rename age1 age;
sort age HHID;

drop if age>100|age<70;
drop if age=3D=3Dage[_n-1];

* WOMEN, GOOD HEALTH;

*In order to take off a blue or pink background delete =
"plotregion(ifcolor(pink*0.08))" in a line below;

genPIshift;
twoway connected _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age, ylabel(0(5000)25000) msymbol(T S D O) =
lpattern(solid longdash shortdash longdash_dot) =
plotregion(ifcolor(pink*0.08)) ti("Medical Expenses, by Permanent Income =
Percentile, Women in Good Health", size(medsmall)) l1(1998 dollars) =
ytitle("") saving(medex, replace);
graph use medex.gph;
graph display, ysize(6) xsize(8.25);
graph export c:\research\papers\wealth\medexgw.eps, replace;
graph export c:\research\papers\wealth\medexgw.emf, replace;
**********numbers behind the graphs****************;
sort age;
by age: sum _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age;
drop _*;

* WOMEN, BAD HEALTH;

replace ageshiftvarc =3Dageshiftvarc+healshift;
genPIshift;
replace ageshiftvarc =3Dageshiftvarc-healshift;

twoway connected _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age, ylabel(0(5000)25000) msymbol(T S D O) =
lpattern(solid longdash shortdash longdash_dot) =
plotregion(ifcolor(pink*0.08)) ti("Medical Expenses, by Permanent Income =
Percentile, Women in Bad Health",size(medsmall)) l1(1998 dollars) =
ytitle("") saving(medex, replace);
graph use medex.gph;
graph display, ysize(6) xsize(8.25);
graph export c:\research\papers\wealth\medexbw.eps, replace;
graph export c:\research\papers\wealth\medexbw.emf, replace;
**********numbers behind the graphs****************;
sort age;
by age: sum _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age;
drop _*;

* MEN, GOOD HEALTH;

replace ageshiftvarc =3Dageshiftvarc+maleshift;
genPIshift;
replace ageshiftvarc =3Dageshiftvarc-maleshift;

twoway connected _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age, ylabel(0(5000)25000) msymbol(T S D O) =
lpattern(solid longdash shortdash longdash_dot) =
plotregion(ifcolor(blue*0.08)) ti("Medical Expenses, by Permanent Income =
Percentile, Men in Good Health", size(medsmall)) l1(1998 dollars) =
ytitle("") saving(medex, replace);
graph use medex.gph;
graph display, ysize(6) xsize(8.25);
graph export c:\research\papers\wealth\medexgm.eps, replace;
graph export c:\research\papers\wealth\medexgm.emf, replace;
**********numbers behind the graphs****************;
sort age;
by age: sum _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age;
drop _*;

* MEN, BAD HEALTH;

replace ageshiftvarc =3Dageshiftvarc+maleshift+healshift;
genPIshift;
replace ageshiftvarc =3Dageshiftvarc-maleshift-healshift;

twoway connected _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age, ylabel(0(5000)25000) msymbol(T S D O) =
lpattern(solid longdash shortdash longdash_dot) =
plotregion(ifcolor(blue*0.08)) ti("Medical Expenses, by Permanent Income =
Percentile, Men in Bad Health", size(medsmall)) l1(1998 dollars) =
ytitle("") saving(medex, replace);
graph use medex.gph;
graph display, ysize(6) xsize(8.25);
graph export c:\research\papers\wealth\medexbm.eps, replace;
graph export c:\research\papers\wealth\medexbm.emf, replace;
**********numbers behind the graphs****************;
sort age;
by age: sum _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age;


keep age ageshiftFINAL healshift maleshift PIshift bPI2;
order age ageshiftFINAL healshift maleshift PIshift bPI2;

*keep age ageshift healshift bPI bPI2 bmale;
*order age ageshift healshift bPI bPI2 bmale;
sum;

outsheet using c:\research\hrs\wealth\medexprof,nonames replace;
drop _all;
program drop _all;
log close;