From: <Saved by Windows Internet Explorer 7>
Subject: 
Date: Wed, 9 Dec 2009 11:38:36 -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_death.do
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.6000.16915" name=3DGENERATOR></HEAD>
<BODY><PRE># delimit ;=20
clear;=20
set mem 300m;=09
set more 1 ; =20
drop _all;
program drop _all;
log using "C:\research\hrs\wealth\death.log", replace;=20
use "c:\research\hrs\wealth\dataprep2";
gen FullModel=3D1;


sort wave;

*keep PI and lagged health around;
gen PIholder=3DPI;
gen lhealage=3Dage1*lheal;
gen maleage=3Dage1*male;
gen surv=3D1-died;

***********************GENERATE SOME PROGRAMS HERE****************;
program define genvals;
  local i =3D 70;
  while `i' &lt;=3D100 { ;
    quietly sum _UNCOND if age =3D=3D `i';
    scalar UNCONDITIONAL`i' =3D r(mean);
    quietly sum _20th_percentile if age =3D=3D `i';
    scalar _20p`i' =3D r(mean);
    quietly sum _40th_percentile if age =3D=3D `i';
    scalar _40p`i' =3D r(mean);
    quietly sum _60th_percentile if age =3D=3D `i';
    scalar _60p`i' =3D r(mean);
    quietly sum _80th_percentile if age =3D=3D `i';
    scalar _80p`i' =3D r(mean);
    local i =3D `i'+1;
  } ;
end;

program define genexpect;
  gen i =3D 70;
  gen i2 =3D 71;
  gen probUNCONDITIONAL=3D1;
  gen prob20 =3D 1;
  gen prob40 =3D 1;
  gen prob60 =3D 1;
  gen prob80 =3D 1;
  gen probUNCONDITIONALh=3D1;=20
  gen prob20h =3D 1;
  gen prob40h =3D 1;
  gen prob60h =3D 1;
  gen prob80h =3D 1;
  gen cprobUNCONDITIONAL=3D0;
  gen cprob20 =3D 0;
  gen cprob40 =3D 0;
  gen cprob60 =3D 0;
  gen cprob80 =3D 0;

  local i =3D 70;
  while `i' &lt;=3D100 { ;
	replace probUNCONDITIONAL=3DprobUNCONDITIONALh*(1-UNCONDITIONAL`i');
	replace cprobUNCONDITIONAL=3DcprobUNCONDITIONAL+probUNCONDITIONAL;
	replace probUNCONDITIONALh=3DprobUNCONDITIONAL;

	replace prob20=3Dprob20h*(1-_20p`i');
	replace cprob20=3Dcprob20+prob20;
	replace prob20h=3Dprob20;

	replace prob40=3Dprob40h*(1-_40p`i');
	replace cprob40=3Dcprob40+prob40;
	replace prob40h=3Dprob40;

	replace prob60=3Dprob60h*(1-_60p`i');
	replace cprob60=3Dcprob60+prob60;
	replace prob60h=3Dprob60;

	replace prob80=3Dprob80h*(1-_80p`i');
	replace cprob80=3Dcprob80+prob80;
	replace prob80h=3Dprob80;

    local i =3D `i' + 1;
  } ;
* procedure above kills people at the start of the time period -- i want =
to kill tham at the end;
* this means add another year to their life;
replace cprob20=3Dcprob20+1;
replace cprob40=3Dcprob40+1;
replace cprob60=3Dcprob60+1;
replace cprob80=3Dcprob80+1;
end;


*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;


program define genPIshift;
	version 3.1;
* now generate percentiles of the distribution;
	replace PI=3DPip1;
	makedist;
	gen bp1=3Dageshift+(PI*bPI1)+(PI2*bPI2)+(PIage*bPIage);
	gen ebp1=3Dexp(bp1);
	gen survp1=3Debp1/(1+ebp1);
	replace PI=3DPip2;
	makedist;
	gen bp2=3Dageshift+(PI*bPI1)+(PI2*bPI2)+(PIage*bPIage);
	gen ebp2=3Dexp(bp2);
	gen survp2=3Debp2/(1+ebp2);
	replace PI=3DPip3;
	makedist;
	gen bp3=3Dageshift+(PI*bPI1)+(PI2*bPI2)+(PIage*bPIage);
	gen ebp3=3Dexp(bp3);
	gen survp3=3Debp3/(1+ebp3);
	replace PI=3DPip4;
	makedist;
	gen bp4=3Dageshift+(PI*bPI1)+(PI2*bPI2)+(PIage*bPIage);
	gen ebp4=3Dexp(bp4);
	gen survp4=3Debp4/(1+ebp4);

gen _20th_percentile=3D1-sqrt(survp1);
gen _40th_percentile=3D1-sqrt(survp2);
gen _60th_percentile=3D1-sqrt(survp3);
gen _80th_percentile=3D1-sqrt(survp4);

drop bp1 bp2 bp3 bp4 ebp1 ebp2 ebp3 ebp4 survp1 survp2 survp3 survp4; * =
drops intermediate output from genPIshift;

end;


*****************;
* UNCONDITIONAL ESTIMATIONS;
***not conditioning on anything (other than age);
*****************;
* ALL WOMEN FIRST;

logit surv age1 age2 age3 age4 if male=3D=3D0;
predict survpf;

*****************;
* NOW MEN        ;

*reg surv age1 age2 age3 age4 if male=3D=3D1;
logit surv age1 age2 age3 age4 if male=3D=3D1;
predict survpm;

gen survpfo=3Dsqrt(survpf);
gen survpmo=3Dsqrt(survpm);
gen diedpmo=3D1-survpmo;
gen diedpfo=3D1-survpfo;





******************************************;
* NOW THE FULL MODEL                      ;
******************************************;
replace PI=3DPIholder; makedist;

if FullModel=3D=3D1{;
logit surv age1 age2 age3 PI PI2 PIage lheal lhealage male maleage;

gen ageshift=3D_b[_cons]+(_b[age1]*age1)+(_b[age2]*age2) =
+(_b[age3]*age3);=20
gen ageshiftFINAL=3Dageshift; * output ageshifter;
gen healshift=3D_b[lheal]+_b[lhealage]*age1;
gen maleshift=3D_b[male]+_b[maleage]*age1;
gen PIshift=3D_b[PI]+_b[PIage]*age1;
gen bPI1 =3D_b[PI];
gen bPI2=3D_b[PI2];
gen bPIage=3D_b[PIage];
};

if FullModel=3D=3D0{;
logit surv age1 age2 age3 male maleage;

gen ageshift=3D_b[_cons]+(_b[age1]*age1)+(_b[age2]*age2) =
+(_b[age3]*age3);=20
gen ageshiftFINAL=3Dageshift; * output ageshifter;
gen healshift=3D0;
gen maleshift=3D_b[male]+_b[maleage]*age1;
gen PIshift=3D0;
gen bPI1 =3D0;
gen bPI2=3D0;
gen bPIage=3D0;
};


drop if age1&lt;70|age1&gt;102;
sort age;
drop if age=3D=3Dage[_n-1];
save c:\research\hrs\wealth\death, replace;
use c:\research\hrs\wealth\death, replace;
drop if age&gt;100;

***********************************;
* GRAPHS                           ;
***********************************;

set scheme s1mono;

* check out mortality rates, by age;
* women versus men;

twoway connected diedpmo diedpfo age,ysc(r(0 .5)) ylabel(0(.1).5) =
msymbol(T O) lpattern (solid dash) ti("Probability of Death, Women and =
Men", size(medsmall)) ytitle("") saving(menandwomendeath, replace);

/*Command msymbol(T O) determines the shape of the marker, where T =
stands for a big triange and O stands for a big circle, (small t and o =
would
stand for small triangle and circle, respectively);*/

graph use menandwomendeath.gph;
graph display, ysize(6) xsize(8.25);*this command changes the size of =
the graph, delete it in order to get a default size;

graph export c:\research\papers\wealth\menandwomendeath.eps, replace;


**********************************************;
* generate predictions for healthy women;
**********************************************;
genPIshift;
gen _UNCOND=3D1-sqrt(survpf);

twoway connected _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age, ysc(r(0 .5)) ylabel(0(.1).5) msymbol(T D S O) =
lpattern(solid longdash shortdash longdash_dot) ti("Probability of =
Death, by Permanent Income Percentile, Women in Good Health", =
size(medsmall)) ytitle("") saving(womendeathg, replace);
graph use womendeathg.gph;
graph display, ysize(6) xsize(8.25);

graph export c:\research\papers\wealth\womendeathg.eps, replace;
graph export c:\research\papers\wealth\womendeathg.emf, replace;
**********numbers behind the graphs****************;
sort age;
by age: sum _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age;

genvals;
genexpect;
sum cprob*;
drop cprob* prob* i* ;
drop _*;
**********************************************;
* now generate predictions for unhealthy women;
**********************************************;
replace ageshift=3Dageshift+healshift; * use this to generate profiles =
for bad health;
genPIshift;
replace ageshift=3Dageshift-healshift; * use this to generate profiles =
for bad health;
gen _UNCOND=3D1-sqrt(survpf);

twoway connected _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age, legend(off) ysc(r(0 .5)) ylabel(0(.1).5) msymbol(T =
S D O) lpattern(solid longdash shortdash longdash_dot) ti("Probability =
of Death, by Permanent Income Percentile, Women in Bad Health", =
size(medsmall)) ytitle("") saving(womendeathb, replace);
graph use womendeathb.gph;
graph display, ysize(6) xsize(8.25);
graph export c:\research\papers\wealth\womendeathb.eps, replace;
graph export c:\research\papers\wealth\womendeathb.emf, replace;
**********numbers behind the graphs****************;
sort age;
by age: sum _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age;

genvals;
genexpect;
sum cprob*;
drop cprob* prob* i* ;
drop _*;
**********************************************;
* generate predictions for healthy men;
**********************************************;
replace ageshift=3Dageshift+maleshift; * use this to generate profiles =
for bad health;
genPIshift;
replace ageshift=3Dageshift-maleshift; * use this to generate profiles =
for bad health;
gen _UNCOND=3D1-sqrt(survpm);

twoway connected _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age, legend(off) ysc(r(0 .5)) ylabel(0(.1).5) msymbol(T =
S D O) lpattern(solid longdash shortdash longdash_dot) ti("Probability =
of Death, by Permanent Income Percentile, Men, Good Health", =
size(medsmall)) ytitle("") saving(mendeathg, replace);
graph use mendeathg.gph;
graph display, ysize(6) xsize(8.25);
graph export c:\research\papers\wealth\mendeathg.eps, replace;
graph export c:\research\papers\wealth\mendeathg.emf, replace;
**********numbers behind the graphs****************;
sort age;
by age: sum _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age;

genvals;
genexpect;
sum cprob*;
drop cprob* prob* i* ;
drop _*;
**********************************************;
* now generate predictions for unhealthy men;
**********************************************;
replace ageshift=3Dageshift+maleshift+healshift; * use this to generate =
profiles for bad health;
genPIshift;
replace ageshift=3Dageshift-maleshift-maleshift; * use this to generate =
profiles for bad health;
gen _UNCOND=3D1-sqrt(survpm);

twoway connected _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age, legend(off) ysc(r(0 .5)) ylabel(0(.1).5) msymbol(T =
S D O) lpattern(solid longdash shortdash longdash_dot) ti("Probability =
of Death, by Permanent Income Percentile, Men, Bad Health", =
size(medsmall)) ytitle("") saving(mendeathb, replace);
graph use mendeathb.gph;
graph display, ysize(6) xsize(8.25);
graph export c:\research\papers\wealth\mendeathb.eps, replace;
graph export c:\research\papers\wealth\mendeathb.emf, replace;
**********numbers behind the graphs****************;
sort age;
by age: sum _20th_percentile _40th_percentile _60th_percentile =
_80th_percentile age;

genvals;
genexpect;
sum cprob*;
drop cprob* prob* i* ;
drop _*;

use c:\research\hrs\wealth\death, replace;

* output for DP model;
keep age ageshiftFINAL healshift maleshift PIshift bPI2;
order age ageshiftFINAL healshift maleshift PIshift bPI2;
outsheet using c:\research\hrs\wealth\deathprof,nonames replace;

*save c:\research\hrs\wealth\death, replace;
program drop _all;
log close;
</PRE></BODY></HTML>
