File size: 5,306 Bytes
2a8276b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
clear all
set more off
set maxvar 10000
set mem 500m
*Set path
***
*cd ---- specify path to \data_replication\psid\
local procdata "./proc_data/"
local rawdata "./raw_data/"
cd proc_data
*load income data
forval x=2015(2)2017{
use pX`x'.dta, clear
ren aftertax_income_defl_equiv inc`x'
ren age_head age`x'
ren ed_head edu`x'
ren marital_status_head mstat`x'
ren fam_ID_year fam_ID`x'
ren size_fam size_fam`x'
drop fam_ID_1968 year_survey year mstat //drop variables that are not useful
save pkX`x'.dta,replace
}
*Join datasets to form a panel
use pkX2015.dta, clear
forval x=2017(2)2017{
joinby hid using pkX`x'.dta, unmatched(both)
drop if _merge!=3
drop _merge
local i=`x'-2
di "`i'"
gen b=age`x'-age`i'
tab b
drop if b!=2 & b!=1 & b!=3 // drop people that are inconsistent about their age (1/2/3 are consistent due to the differences in month of interview)
drop b
gen a=edu`x'-edu`i'
tab a
drop if a<0 // drop people that are inconsistent about their education (to adjust for any errors, see 2009 family codebook release info)
drop a
}
*Reshape the data for better use
reshape long inc age edu mstat fam_ID size_fam, i(hid) j(year)
drop if inc<0
drop if year<2015
drop if year>2017
drop if age<25
drop if age>85
keep fam_ID year hid inc equiv age
save income_panel1_temp.dta, replace
cd ..
*###############################################################################
*Prepare the refinancing data for each year
*###############################################################################
forval x=2015(2)2017{
clear
*###############################################################################
*Prepare the wealth data
*###############################################################################
*Convert family files to stata format
cd raw_data
do FAM`x'ER.do
*Adjust wealth components
do wealth_comp`x'.do
gen year=`x'
drop ER*
cd ..
joinby fam_ID year using `procdata'income_panel1_temp.dta, unmatched(both)
drop if _merge!=3
drop _merge
save `procdata'ref_temp_`x'.dta,replace
}
cd proc_data
*###############################################################################
*Generate Panel and calculate Share of refinancing
*###############################################################################
use ref_temp_2015.dta, clear
forval x=2017(2)2017{
append using ref_temp_`x'.dta
}
sort hid year
xtset hid year
*sum up both mortgages
gen tot_mtg_debt=m1_principal+m2_principal
*generate difference in mortgage balances between survey waves
gen past_mtg_balance=L2.tot_mtg_debt
gen diff_mtg_balance=tot_mtg_debt-past_mtg_balance
replace diff_mtg_balance=. if past_mtg_balance==0 //make sure to account for people that had no mtg and got one (went from 0 to positive mtg balance)
*generate refinancing dummies
*1. any increase in mtg balance
gen refi_status1=1 if diff_mtg_balance>0 & diff_mtg_balance!=.
replace refi_status1=0 if refi_status1!=1
*2. 5% increase in mtg balance (results are the same in terms of nr of observations between option 1. and option 2.)
gen pct_increase_mtg_balance=diff_mtg_balance/past_mtg_balance
gen refi_status2=1 if diff_mtg_balance>=.05 & diff_mtg_balance!=.
replace refi_status2=0 if refi_status2!=1
****************************************************************************************************************
*compute moments
****************************************************************************************************************
*create moments to be reported
gen liq_assets=(stocks+checking_savings-other_debt)/equiv
gen income = inc //already equivalized
gen liq_assets_to_inc = liq_assets/income
gen h_net_worth_share = (house_val - m1_principal-m2_principal)/wealth
gen wlth = wealth/equiv
gen ltv_m=tot_mtg_debt/house_val
gen h_value=house_val/equiv
*gen age_head=age
gen mtg_payments_total = (mtg_paym1+mtg_paym2)/equiv
gen pti = mtg_payments_total/inc
*save file
save temp_refi_data.dta, replace
*************************************************************************
* OTHER REFI MOMENTS
*************************************************************************
*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*2017
*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
use temp_refi_data, clear
keep if year==2015 | year==2017
*move refi status one step behind
gen refit1=f2.refi_status2
gen refit2=f2.turnover1
gen refit=1 if refit1==1 & refit2!=1
replace refit=0 if refit!=1
*move back increase in mtg balance
gen mtg_delta=f2.pct_increase_mtg_balance
gen mtg_delta1=f2.diff_mtg_balance/house_val
*keep only orginal year
keep if year==2015
*winsorize data
winsor2 liq_assets income liq_assets_to_inc h_net_worth_share wlth ltv_m h_value age_head pti mtg_delta mtg_delta1, replace cuts(1 99)
preserve
collapse (mean) refit
gen res=round(refit, 0.01)/2
replace res=round(res, 0.01)
gen title="fraction of people refinance"
save moment1.dta, replace
restore
forval x=1(1)1{
use moment`x'.dta, clear
keep res title
duplicates drop
save moment`x'.dta, replace
}
use moment1.dta, clear
order title res
cd ..
cd output
outsheet using tabA3_refi.csv, replace c
|