********************************************************************************
************************************
cd "F:\Intergenerational_Health_12_9_2021\Replication_EHB_12_20_2021\progs\Figures"
clear all
set more on 
set matsize 11000
#delimit ;
graph set window fontface Century;
use .\..\..\data\output\natality_1969_2004_clean_collapsed_merged_cohort_var_def , clear ;
keep if ymcaid==1966;
gen age_exp=ymcaid-birth_cohort;
replace age_exp=0 if age_exp<0;
gen b=45-age_exp;
egen t0=min(birth_cohort);
egen t3=max(birth_cohort);
gen t1=1948;
gen t2=1966;
gen U=45*_n/_N;
*tab U;
replace U=0 if U<0;
replace U=45 if U>45;
gen xl=18;
gen c=0;
gen B = age_exp + b ;
gen C = age_exp + b + c ;
gen year=_n*80/_N+1970;
su year;
replace year=1970 if year<1970;
replace year=2004 if year>2004;

gen date=birth_cohort;
gen Y1=year-20.1;
gen Y2=year-44;

gen R1=year-28;
gen R2=year-44;

replace Y1=. if birth_cohort<1936;
replace Y2=. if Y2<1936;
replace R2=. if R2<1936;
replace R1=. if R1<1936;
replace Y1=. if Y1>1976;

gen Z1=1950 if year<=1980;
gen Z2=1936 if year<=1980;

gen I1=1968 if year>=1996 & year<=2004;
gen I2=1976 if year>=1996 & year<=2004;

gen X1=1936 if year>=1970 & year<=1981;
gen X2=1937 if year>=1970 & year<=1982;

twoway (rarea Y1 Y2 year,   color("57 229 163") lwidth(none)  fintensity(90)) || 
(rarea Z1 Z2 year,   color("57 229 163") lwidth(none) fintensity(90) ) || 
(rarea R1 R2 year,   color("57 229 163")  lwidth(none) fintensity(90) ) || 
(rarea I1 I2 year,   color("57 229 163") lwidth(none)  fintensity(90)  ) || 
(scatteri 1957 1988 "Cohort-Years Included in the Sample", msymbol(i) mlabpos(0) legend(off) mlabangle(32) mlabcolor("0 0 0") mlabsize(4))
,
ytitle("Birth Cohorts",size(vsmall))
xtitle("Periods of Natalaity Data",size(vsmall))
xscale(range(1970 2004))
xlabel(1970(2)2004 , labsize(tiny) grid  )
yscale(range(1936 1976))
ylabel(1936(1)1976 , labsize(tiny) angle(0) grid  )
legend(off)
;

	graph save .\..\..\figs\figure_4.gph , replace ;
	graph export .\..\..\figs\figure_4.emf , replace ;
	

       






/*
coefplot  , keep( `I' ) xline(13,lcolor(dkgreen))  xline(32,lcolor(dkgreen) lwidth(thin))  yline(0) omitted  vertical ciopts(recast(rcap))
	level(90) xlabel( ,  labsize(small) angle(vertical))  
	text( 0.08 7 "Unexposed:""[-30,-19]",  size(small))
	text( 0.08 22 "Partially Exposed:" "[-18,-1]",  size(small))
	text( 0.08 37 "Fully Exposed:" "[0,+10]",  size(small))
	
	ytitle("Any Prenatal Visits X100", size(medium)) 
	xtitle("Birth Year - Year of Medicaid Implementation" , size(medium))
	title("Whites")
    name(second);
	graph save .\..\..\figs\any_pren_care_w.gph , replace ;
	graph export .\..\..\figs\any_pren_care_w.emf , replace ;
	
