/* Program to estimate bequests for Costa Rica 2004 The starting point is the person-level data file of the 2004 income and expenditure survey after final figure of asset income has been estimated: "person2004.dta" We use also a file containing the age-specific mortality rates for the year of the estimate: "mortal.dta". Note that we need rates up to the age 90plus If you do not have mortality rates use temporarily these from Costa Rica. There are two series: one for 1988 (life expectancy 76.6 years) and other for 2004 (LE = 78.6 years) */ use person2004,clear keep idho idper age factor hh ya kin lab var idho "Household identifier" lab var idper "Person identifier" lab var factor "Expansion factor to reproduce population figures by age" lab var hh "Household head (1=yes)" lab var ya "Asset income" lab var kin "Relationship with the household head" *note the codes in kinship labelbook kinship sort age merge age using mortal drop if _merge ~=3 drop m88 _merge lab var m04 "Mortality rates for 2004" *check data on ma and Ya graph bar m04,over(age) gen age5=int(age/5)*5 graph bar ya,over(age5) * note I am using unsmoothed Ya. *the estimate of bequests_out (assuming r=8%) gen beqo=m04*ya/.08 graph bar (sum) beqo,over(age5) *and now the percapitas: graph bar (mean) beqo,over(age5) *It follows the estimate of bequest_in *We assume that all bequests stay within the household *First compute amount of bequests in the household, and the number of inheritors sort idho *Inheritance in the household by idho: egen beqhous=sum(beqo) *Number of inheritors in the household when soembody dies by idho: gen inher=_N-1 *compute bequest_in gen beqin=(beqhous - beqo)/inher *note that we substract the bequest that would left the index individual *note that households with one member get missings for bequest_in. We will adjust this later * this is a prelimnary estimate of the age-profile of bequests_in graph bar beqin,over(age5) *Now we get a second estimate with a correction of equivalent inheritors: *spouses and children = 1 and the rest of household members = .2 gen equiv=1 replace equiv=0.2 if kinship==4 sort idho by idho: egen equinher = sum(equiv) gen beqin2=(beqhous - beqo)*(equiv/(equinher-1)) *compare the two estimates graph bar beqin beqin2,over(age5) *for totals graph bar (sum) beqin beqin2,over(age5) sum beq* *the aggregated file by age (we'll keep just the beqin2 estimate): sort age collapse (sum) factor beqo beqin2,by(age) ren factor pop ren beqo beqo_tot ren beqin2 beqin_tot line beqin_tot beqo_tot age gen beqo_pc= beqo_to /pop gen beqin_pc= beqin_tot / pop line beqin_pc beqo_pc age lab var beqin_tot "Total bequests received IN" lab var beqo_tot "Total bequests given OUT" lab var beqin_pc "Per capita bequests received IN" lab var beqo_pc "Per capita bequests given OUT" *smoothing per capitas lowess beqo_pc age, bwidth(0.3) gen(sbeqo_pc) nograph adj graph bar sbeqo_pc,over(age) replace sbeqo_pc =0 if sbeqo_pc<0 lowess beqin_pc age, bwidth(0.3) gen(sbeqin_pc) nograph graph bar sbeqin_pc,over(age) *Balancing bequests *total beq_out must be == total beq_in egen double totbeqo=total(sbeqo_pc *pop) egen double totbeqin=total(sbeqin_pc*pop) gen corr=totbeqo/totbeqin gen beqin_pc_adj=sbeqin_pc*corr drop totbeqo totbeqin corr line sbeqo_pc beqin_pc_adj age *smooth totals gen sbeqo_tot = sbeqo_pc*pop gen sbeqin_tot = beqin_pc_adj*pop line sbeqo_tot sbeqin_tot age lab var sbeqo_pc "Smoothed per capita bequests given OUT" lab var beqin_pc_adj "Smoothed per capita bequests received IN and adjusted to those given out" lab var sbeqin_tot "Smoothed total bequests received IN" lab var sbeqo_tot "Smoothed total bequests given OUT" save bequests-ag,replace