slr_tracts <- read.dbf(file = "C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Projects/Climate Change Mortgage/slr_tracts_orgslr.dbf",as.is = TRUE)
slr_counties <- unique(substr(slr_tracts$FIPS,1,5))
slr_states <- unique(substr(slr_counties,1,2))
files <- NULL
files <- c(files,list.files(pattern="*.fst",path = "C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/HMDA/OO_NP/",full.names = TRUE))
files <- c(files,list.files(pattern="*.fst",path = "C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/HMDA/OO_RF/",full.names = TRUE))
files <- files[substr(files,100,103) %in% c("2018","2019")] #c("2014","2015","2016","2017","2018")
hmda = lapply(files, read_fst, as.data.table = TRUE,
columns=c("asofdate","respondentid","actiontaken","censustract","typeofloan","purposeofloan","amountofloan",
"combined_loan_to_value_ratio","interest_rate","applicantincome","debt_to_income_ratio",
"applicantrace1","state","countycode","ratespread","discount_points","total_loan_costs",
"total_points_and_fees","loan_term","intro_rate_period","lender_credits","origination_charges",
"typeofpurchaser","conforming_loan_limit","applicant_age","co_applicant_race_1","applicantethnicity",
"co_applicant_age","construction_method","applicantsex","co_applicant_sex","msa"))
hmda <- do.call(rbind , hmda)
hmda[,countycode:=substr(censustract,1,5)]
hmda[,msa:=str_pad(msa,width = 5,pad="0")]
hmda[,interest_rate:=as.numeric(interest_rate)]
hmda[,jumbo:=ifelse(conforming_loan_limit=="NC",1,0)]
hmda[,applicant_age:=ifelse(applicant_age %in% c("<25"),20,
ifelse(applicant_age %in% c("25-34"),30,
ifelse(applicant_age %in% c("35-44"),40,
ifelse(applicant_age %in% c("45-54"),50,
ifelse(applicant_age %in% c("55-64"),60,
ifelse(applicant_age %in% c("65-74"),70,
ifelse(applicant_age %in% c(">74"),80,NA)))))))]
hmda[,dti:=ifelse(debt_to_income_ratio %in% c("<20%"),0.15,
ifelse(debt_to_income_ratio %in% c("20%-<30%"),0.25,
ifelse(debt_to_income_ratio %in% c("30%-<36%"),0.33,
ifelse(debt_to_income_ratio %in% c("50%-60%"),0.55,
ifelse(debt_to_income_ratio %in% c(">60%"),0.65,
ifelse(debt_to_income_ratio %in% c("Exempt"),NA,debt_to_income_ratio))))))]
hmda[,dti:=as.numeric(dti)]
hmda[,dti:=ifelse(dti>1,dti/100,dti)]
hmda[,cltv:=as.numeric(combined_loan_to_value_ratio)]
hmda[,denied:=ifelse(actiontaken==3,1,ifelse(actiontaken %in% c(1,2),0,NA))]
hmda[,slrstate:=ifelse(state %in% slr_states,1,0 )]
hmda[,slrcounty:=ifelse(countycode %in% slr_counties,1,0)]
hmda[,county_year:=paste(countycode,asofdate)]
hmda[,lender_county_year:=paste(respondentid,countycode,asofdate)]
hmda[,censustract_year:=paste(censustract,asofdate)]
hmda[,term:=ifelse(loan_term==120,10,ifelse(loan_term==180,15,ifelse(loan_term==240,20,ifelse(loan_term==360,30,NA))))]
hmda[,retained:=ifelse(typeofpurchaser==0,1,0)]
nyt <- fread("C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/NYT Flood Insurance/nyt_fema_fs_2.csv")
nyt[,fips:=str_pad(fips,width=5,pad = "0")]
nyt[,fspct:=as.numeric(fspct)/100]
nyt[,femapct:=as.numeric(femapct)/100]
nyt <- nyt[,c("fips","fspct")]
hmda <- merge(hmda,nyt,by.x="countycode",by.y="fips")
hmda[,fsbin:=floor(fspct*100/10)*10]
hmda[,fsbin:=ifelse(fsbin>40,40,fsbin)]
hmda[,highfs:=ifelse(fspct>0.133,1,0)]
hmda[,highrisk:=ifelse(highfs==1 & slrcounty==1,1,0)]
hmda[,highriskfs:=ifelse(highfs==1 & slrcounty==1,1,0)]
Counties identified as ‘high risk’ are colored in blue.
us_counties <- readOGR("C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/Shapefiles/US Counties/cb_2013_us_county_20m","cb_2013_us_county_20m")
## OGR data source with driver: ESRI Shapefile
## Source: "C:\Users\dratnadiwakara2\Documents\OneDrive - Louisiana State University\Raw Data\Shapefiles\US Counties\cb_2013_us_county_20m", layer: "cb_2013_us_county_20m"
## with 3221 features
## It has 9 fields
## Integer64 fields read as strings: ALAND AWATER
us_counties <- fortify(us_counties,region="GEOID")
us_counties <- data.table(us_counties)
us_counties[,state:=as.numeric(substr(id,1,2))]
cnty <- hmda[,c("countycode","highrisk","slrstate","slrcounty")]
cnty <- cnty[!duplicated(cnty$countycode)]
us_counties <- merge(us_counties,cnty,by.x="id",by.y="countycode",all.x=T)
us_states <- readOGR("C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/Shapefiles/US States","cb_2014_us_state_20m")
## OGR data source with driver: ESRI Shapefile
## Source: "C:\Users\dratnadiwakara2\Documents\OneDrive - Louisiana State University\Raw Data\Shapefiles\US States", layer: "cb_2014_us_state_20m"
## with 52 features
## It has 9 fields
## Integer64 fields read as strings: ALAND AWATER
us_states <- data.table(fortify(us_states,region="GEOID"))
us_states[,id:=as.numeric(id)]
ggplot()+
geom_polygon(data=us_counties[! us_counties$state %in% c(2,15,72) & highrisk==1],aes(x=long,y=lat,group=group),color="dodgerblue4",fill="dodgerblue4")+ geom_polygon(data=us_states[! us_states$id %in% c(2,15,72)], aes(x=long,y=lat,group=group),fill=NA,color="gray50")+theme_minimal()+ theme(axis.title=element_blank(),
axis.text=element_blank(),
axis.ticks=element_blank(),panel.grid = element_blank())
Blue counties: Treatment – High risk counties
Orange counties: Control counties
ggplot()+geom_polygon(data=us_counties[! us_counties$state %in% c(2,15,72) & highrisk==0 & slrcounty==1],aes(x=long,y=lat,group=group),color="tan1",fill="tan1")+
geom_polygon(data=us_counties[! us_counties$state %in% c(2,15,72) & highrisk==1],aes(x=long,y=lat,group=group),color="dodgerblue4",fill="dodgerblue4")+
geom_polygon(data=us_states[! us_states$id %in% c(2,15,72)], aes(x=long,y=lat,group=group),fill=NA,color="gray50")+theme_minimal()+ theme(axis.title=element_blank(),
axis.text=element_blank(),
axis.ticks=element_blank(),panel.grid = element_blank())
ggplot()+
geom_polygon(data=us_counties[! us_counties$state %in% c(2,15,72) & highrisk==0 & slrstate==1],aes(x=long,y=lat,group=group),color="tan1",fill="tan1")+
geom_polygon(data=us_counties[! us_counties$state %in% c(2,15,72) & highrisk==1],aes(x=long,y=lat,group=group),color="dodgerblue4",fill="dodgerblue4")+
geom_polygon(data=us_states[! us_states$id %in% c(2,15,72)], aes(x=long,y=lat,group=group),fill=NA,color="gray50")+theme_minimal()+ theme(axis.title=element_blank(),
axis.text=element_blank(),
axis.ticks=element_blank(),panel.grid = element_blank())
Note: Sample is restricted to 30 year mortgates.â™
This section looks at whether interest rates on jumbo loans are higher in high risk areas.
\[ Interest rate = \alpha + \beta HighRisk \times Jumbo + \delta X \times Jumbo + Lender \times County \times Year FE\]
Column (1): Sample: Refinance mortgages, Control sample: SLR counties
Column (2): Sample: Refinance mortgages, Control sample: SLR states
Column (3): Sample: New purchase mortgages, Control sample: SLR counties
Column (4): Sample: New purchase mortgages, Control sample: SLR states
Interest rate is about 5 to 7bp higher for jumbo loans in high risk areas
minloan = 100
maxloan = 1000
lt = 360
formula1 <- as.formula("interest_rate~highrisk*jumbo+log(1+applicantincome)*jumbo+log(1+amountofloan)+dti*jumbo+factor(purposeofloan)+applicant_age*jumbo+cltv*jumbo+factor(typeofloan)|lender_county_year|0|countycode")
formula2 <- as.formula("interest_rate~highrisk*jumbo+log(1+applicantincome)*jumbo+log(1+amountofloan)+dti*jumbo+applicant_age*jumbo+cltv*jumbo+factor(typeofloan)|lender_county_year|0|countycode")
regs <- list()
regs[[1]] <- felm(formula1,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan!=1 & slrcounty==1 & typeofloan<=2])
regs[[2]] <- felm(formula1,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan!=1 & slrstate==1 & typeofloan<=2])
regs[[3]] <- felm(formula2,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan==1 & slrcounty==1 & typeofloan<=2])
regs[[4]] <- felm(formula2,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan==1 & slrstate==1 & typeofloan<=2])
.printtable(regs)
##
## ======================================================================
## Dependent variable:
## ---------------------------------------
## (1) (2) (3) (4)
## ----------------------------------------------------------------------
## highrisk
## (0.000) (0.000) (0.000) (0.000)
## jumbo -0.356*** 0.316** -0.476*** -0.564***
## (0.087) (0.129) (0.108) (0.077)
## log(1 + applicantincome) 0.169*** 0.176*** 0.164*** 0.156***
## (0.005) (0.004) (0.005) (0.003)
## log(1 + amountofloan) -0.320*** -0.337*** -0.311*** -0.309***
## (0.009) (0.008) (0.009) (0.007)
## dti 0.819*** 0.853*** 0.690*** 0.684***
## (0.027) (0.020) (0.019) (0.013)
## factor(purposeofloan)32 0.288*** 0.317***
## (0.008) (0.009)
## applicant_age -0.001*** -0.001*** -0.001*** -0.001***
## (0.0001) (0.0001) (0.0001) (0.0001)
## cltv 0.0001 0.00002** -0.000 -0.000
## (0.0001) (0.00001) (0.000) (0.000)
## factor(typeofloan)2 -0.313*** -0.334*** -0.116*** -0.085***
## (0.007) (0.006) (0.014) (0.009)
## highrisk:jumbo 0.042*** 0.035*** 0.048*** 0.036***
## (0.013) (0.011) (0.009) (0.009)
## jumbo:log(1 + applicantincome) -0.057*** -0.080*** -0.057*** -0.041***
## (0.011) (0.011) (0.010) (0.007)
## jumbo:dti 0.223*** 0.131** -0.048 -0.010
## (0.075) (0.060) (0.038) (0.034)
## jumbo:applicant_age 0.001*** -0.001 0.001*** 0.002***
## (0.0004) (0.0004) (0.0004) (0.0003)
## jumbo:cltv 0.007*** 0.001 0.009*** 0.009***
## (0.0003) (0.001) (0.001) (0.001)
## ----------------------------------------------------------------------
##
## Observations 487,971 805,929 1,256,792 2,295,848
## Adjusted R2 0.454 0.461 0.431 0.424
## ======================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
lt = 180
regs <- list()
regs[[1]] <- felm(formula1,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan!=1 & slrcounty==1 & typeofloan<=2])
regs[[2]] <- felm(formula1,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan!=1 & slrstate==1 & typeofloan<=2])
regs[[3]] <- felm(formula2,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan==1 & slrcounty==1 & typeofloan<=2])
regs[[4]] <- felm(formula2,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan==1 & slrstate==1 & typeofloan<=2])
.printtable(regs)
##
## ======================================================================
## Dependent variable:
## ---------------------------------------
## (1) (2) (3) (4)
## ----------------------------------------------------------------------
## highrisk
## (0.000) (0.000) (0.000) (0.000)
## jumbo -0.052 -0.335* 0.097 -0.068
## (0.188) (0.184) (0.209) (0.202)
## log(1 + applicantincome) 0.200*** 0.190*** 0.113*** 0.120***
## (0.013) (0.008) (0.016) (0.011)
## log(1 + amountofloan) -0.423*** -0.440*** -0.293*** -0.271***
## (0.012) (0.009) (0.022) (0.014)
## dti 0.892*** 0.878*** 0.421*** 0.497***
## (0.045) (0.031) (0.061) (0.041)
## factor(purposeofloan)32 0.257*** 0.289***
## (0.014) (0.011)
## applicant_age 0.002*** 0.002*** 0.001*** 0.0003**
## (0.0002) (0.0001) (0.0002) (0.0002)
## cltv 0.00001 0.00002* 0.002*** 0.00000
## (0.00002) (0.00001) (0.0002) (0.00000)
## factor(typeofloan)2 -0.095*** -0.139*** 0.117*** 0.136***
## (0.011) (0.009) (0.032) (0.025)
## highrisk:jumbo 0.013 0.017 0.052* 0.028
## (0.021) (0.020) (0.030) (0.028)
## jumbo:log(1 + applicantincome) -0.026 0.014 -0.028 -0.021
## (0.026) (0.024) (0.024) (0.025)
## jumbo:dti -0.016 0.111 0.052 -0.036
## (0.154) (0.123) (0.155) (0.118)
## jumbo:applicant_age 0.0002 0.001 -0.002 0.001
## (0.001) (0.001) (0.001) (0.001)
## jumbo:cltv 0.005*** 0.006*** 0.004*** 0.004***
## (0.001) (0.001) (0.001) (0.001)
## ----------------------------------------------------------------------
##
## Observations 110,442 208,706 43,565 95,106
## Adjusted R2 0.480 0.505 0.521 0.601
## ======================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
formula1 <- as.formula("interest_rate~highrisk*log(amountofloan)+log(1+applicantincome)+log(1+amountofloan)+dti+factor(purposeofloan)+applicant_age+cltv+factor(typeofloan)|lender_county_year|0|countycode")
formula2 <- as.formula("interest_rate~highrisk*log(amountofloan)+log(1+applicantincome)+log(1+amountofloan)+dti+applicant_age+cltv+factor(typeofloan)|lender_county_year|0|countycode")
maxloan = 3000
lt = 360
regs <- list()
regs[[1]] <- felm(formula1,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan!=1 & slrcounty==1 & typeofloan<=2 & jumbo==1])
regs[[2]] <- felm(formula1,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan!=1 & slrstate==1 & typeofloan<=2 & jumbo==1])
regs[[3]] <- felm(formula2,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan==1 & slrcounty==1 & typeofloan<=2 & jumbo==1])
regs[[4]] <- felm(formula2,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan==1 & slrstate==1 & typeofloan<=2 & jumbo==1])
.printtable(regs)
##
## ======================================================================
## Dependent variable:
## -------------------------------------------
## (1) (2) (3) (4)
## ----------------------------------------------------------------------
## highrisk
## (0.000) (0.000) (0.000) (0.000)
## log(amountofloan) -148.569*** -146.301*** 35.262 64.153*
## (43.027) (33.158) (51.057) (36.146)
## log(1 + applicantincome) 0.076*** 0.075*** 0.057*** 0.069***
## (0.014) (0.014) (0.008) (0.007)
## log(1 + amountofloan) 148.343*** 146.132*** -35.563 -64.465*
## (43.066) (33.192) (51.106) (36.187)
## dti 0.710*** 0.722*** 0.404*** 0.469***
## (0.056) (0.052) (0.040) (0.033)
## factor(purposeofloan)32 0.116*** 0.130***
## (0.008) (0.010)
## applicant_age 0.001 -0.0004 0.0002 0.0003
## (0.001) (0.001) (0.0004) (0.0003)
## cltv 0.005*** 0.001 0.008*** 0.008***
## (0.0004) (0.001) (0.001) (0.001)
## factor(typeofloan)2 -0.137 -0.122 -0.187*** -0.173***
## (0.090) (0.084) (0.035) (0.033)
## highrisk:log(amountofloan) 0.163*** 0.094** 0.060*** 0.025
## (0.043) (0.042) (0.022) (0.019)
## ----------------------------------------------------------------------
##
## Observations 41,634 60,378 88,167 135,143
## Adjusted R2 0.571 0.534 0.589 0.571
## ======================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
This section looks at whether mortgage applications for jumbo loans in high risk areas are more likely to be denied
\[ Denied = \alpha + \beta HighRisk \times Jumbo + \delta X \times Jumbo + Lender \times County \times Year FE\]
Column (1): Sample: Refinance mortgages, Control sample: SLR counties
Column (2): Sample: Refinance mortgages, Control sample: SLR states
Column (3): Sample: New purchase mortgages, Control sample: SLR counties
Column (4): Sample: New purchase mortgages, Control sample: SLR states
Jumbo loans are 1 to 2% more likely to be denied in high risk areas
minloan = 100
maxloan = 1000
lt = 360
formula1 <- as.formula("denied~highrisk*jumbo+log(1+applicantincome)*jumbo+log(1+amountofloan)+dti*jumbo+factor(purposeofloan)+applicant_age*jumbo+cltv*jumbo+factor(typeofloan)|lender_county_year|0|countycode")
formula2 <- as.formula("denied~highrisk*jumbo+log(1+applicantincome)*jumbo+log(1+amountofloan)+dti*jumbo+applicant_age*jumbo+cltv*jumbo+factor(typeofloan)|lender_county_year|0|countycode")
regs <- list()
regs[[1]] <- felm(formula1,data=hmda[ loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan!=1 & slrcounty==1 & typeofloan<=2])
regs[[2]] <- felm(formula1,data=hmda[ loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan!=1 & slrstate==1 & typeofloan<=2])
regs[[3]] <- felm(formula2,data=hmda[ loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan==1 & slrcounty==1 & typeofloan<=2 ])
regs[[4]] <- felm(formula2,data=hmda[ loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan==1 & slrstate==1 & typeofloan<=2 ])
.printtable(regs )
##
## ======================================================================
## Dependent variable:
## ---------------------------------------
## (1) (2) (3) (4)
## ----------------------------------------------------------------------
## highrisk
## (0.000) (0.000) (0.000) (0.000)
## jumbo -0.431*** -0.213*** -0.159*** -0.167***
## (0.043) (0.062) (0.028) (0.022)
## log(1 + applicantincome) 0.002 -0.003 -0.002 -0.007***
## (0.003) (0.002) (0.002) (0.001)
## log(1 + amountofloan) -0.034*** -0.029*** -0.035*** -0.026***
## (0.004) (0.003) (0.004) (0.003)
## dti 1.093*** 1.032*** 0.628*** 0.568***
## (0.024) (0.018) (0.016) (0.012)
## factor(purposeofloan)32 -0.031*** -0.030***
## (0.002) (0.002)
## applicant_age 0.0005*** 0.0004*** 0.001*** 0.0005***
## (0.0001) (0.00005) (0.00004) (0.00003)
## cltv 0.00000** 0.00000** -0.000 -0.000
## (0.00000) (0.00000) (0.000) (0.000)
## factor(typeofloan)2 0.067*** 0.067*** 0.008*** 0.011***
## (0.003) (0.002) (0.003) (0.002)
## highrisk:jumbo 0.032*** 0.021*** 0.011** 0.003
## (0.006) (0.007) (0.005) (0.004)
## jumbo:log(1 + applicantincome) 0.018*** 0.013*** 0.005 0.006**
## (0.005) (0.004) (0.004) (0.003)
## jumbo:dti 0.261*** 0.259*** 0.305*** 0.307***
## (0.024) (0.019) (0.031) (0.023)
## jumbo:applicant_age 0.002*** 0.001*** 0.001*** 0.001***
## (0.0002) (0.0002) (0.0001) (0.0001)
## jumbo:cltv 0.003*** 0.001 0.001*** 0.001***
## (0.0002) (0.001) (0.0001) (0.0001)
## ----------------------------------------------------------------------
##
## Observations 709,287 1,156,324 1,442,737 2,613,744
## Adjusted R2 0.259 0.255 0.121 0.125
## ======================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
lt = 180
regs <- list()
regs[[1]] <- felm(formula1,data=hmda[ loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan!=1 & slrcounty==1 & typeofloan<=2])
regs[[2]] <- felm(formula1,data=hmda[ loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan!=1 & slrstate==1 & typeofloan<=2])
regs[[3]] <- felm(formula2,data=hmda[ loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan==1 & slrcounty==1 & typeofloan<=2 ])
regs[[4]] <- felm(formula2,data=hmda[ loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan==1 & slrstate==1 & typeofloan<=2 ])
.printtable(regs )
##
## ========================================================================
## Dependent variable:
## -----------------------------------------
## (1) (2) (3) (4)
## ------------------------------------------------------------------------
## highrisk
## (0.000) (0.000) (0.000) (0.000)
## jumbo -0.451*** -0.492*** -0.062 0.016
## (0.137) (0.094) (0.110) (0.079)
## log(1 + applicantincome) -0.014** -0.020*** -0.009** -0.007**
## (0.005) (0.003) (0.004) (0.003)
## log(1 + amountofloan) -0.006 0.0004 -0.024*** -0.021***
## (0.005) (0.003) (0.005) (0.003)
## dti 0.833*** 0.796*** 0.435*** 0.413***
## (0.018) (0.014) (0.021) (0.015)
## factor(purposeofloan)32 -0.040*** -0.040***
## (0.003) (0.002)
## applicant_age 0.0003** 0.0003*** 0.0001 0.00001
## (0.0001) (0.0001) (0.0001) (0.0001)
## cltv 0.00001 0.00000*** 0.00001*** 0.00001**
## (0.00001) (0.000) (0.00000) (0.00000)
## factor(typeofloan)2 0.132*** 0.127*** 0.150*** 0.114***
## (0.009) (0.007) (0.027) (0.018)
## highrisk:jumbo 0.013 0.020 0.005 0.002
## (0.015) (0.013) (0.017) (0.014)
## jumbo:log(1 + applicantincome) 0.026 0.035*** -0.013 -0.005
## (0.017) (0.012) (0.013) (0.011)
## jumbo:dti 0.226*** 0.199*** 0.150* 0.199***
## (0.067) (0.056) (0.087) (0.076)
## jumbo:applicant_age 0.002*** 0.002*** 0.0004 -0.0002
## (0.001) (0.001) (0.001) (0.0005)
## jumbo:cltv 0.003*** 0.003*** 0.002*** -0.00000
## (0.0005) (0.0003) (0.0005) (0.00000)
## ------------------------------------------------------------------------
##
## Observations 139,253 261,198 48,556 105,525
## Adjusted R2 0.181 0.181 0.114 0.123
## ========================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
formula1 <- as.formula("denied~highrisk*log(amountofloan)+log(1+applicantincome)+log(1+amountofloan)+dti+factor(purposeofloan)+applicant_age+cltv+factor(typeofloan)|lender_county_year|0|countycode")
formula2 <- as.formula("denied~highrisk*log(amountofloan)+log(1+applicantincome)+log(1+amountofloan)+dti+applicant_age+cltv+factor(typeofloan)|lender_county_year|0|countycode")
maxloan = 3000
lt = 360
regs <- list()
regs[[1]] <- felm(formula1,data=hmda[loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan!=1 & slrcounty==1 & typeofloan<=2 & jumbo==1])
regs[[2]] <- felm(formula1,data=hmda[loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan!=1 & slrstate==1 & typeofloan<=2 & jumbo==1])
regs[[3]] <- felm(formula2,data=hmda[loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan==1 & slrcounty==1 & typeofloan<=2 & jumbo==1])
regs[[4]] <- felm(formula2,data=hmda[loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan< maxloan & purposeofloan==1 & slrstate==1 & typeofloan<=2 & jumbo==1])
.printtable(regs)
##
## =====================================================================
## Dependent variable:
## ------------------------------------------
## (1) (2) (3) (4)
## ---------------------------------------------------------------------
## highrisk
## (0.000) (0.000) (0.000) (0.000)
## log(amountofloan) -20.898* -35.421*** -110.329*** -96.022***
## (11.873) (10.581) (12.873) (9.406)
## log(1 + applicantincome) 0.045*** 0.039*** 0.005 0.001
## (0.005) (0.004) (0.004) (0.003)
## log(1 + amountofloan) 20.887* 35.439*** 110.435*** 96.134***
## (11.889) (10.597) (12.884) (9.417)
## dti 1.434*** 1.382*** 0.925*** 0.881***
## (0.030) (0.026) (0.039) (0.030)
## factor(purposeofloan)32 0.005 0.007*
## (0.004) (0.004)
## applicant_age 0.002*** 0.001*** 0.001*** 0.001***
## (0.0002) (0.0003) (0.0001) (0.0001)
## cltv 0.003*** 0.001* 0.001*** 0.001***
## (0.0003) (0.001) (0.0001) (0.0001)
## factor(typeofloan)2 -0.032 0.014 -0.065*** -0.047***
## (0.039) (0.035) (0.016) (0.014)
## highrisk:log(amountofloan) 0.004 -0.003 0.035*** 0.014
## (0.012) (0.011) (0.012) (0.011)
## ---------------------------------------------------------------------
##
## Observations 57,992 83,487 103,399 158,236
## Adjusted R2 0.294 0.284 0.181 0.174
## =====================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
This section looks at whether jumbo mortgages in high risk areas are more likely to be retained on balance sheet.
\[ Denied = \alpha + \beta HighRisk \times Jumbo + \delta X \times Jumbo + Lender \times County \times Year FE\]
Column (1): Sample: Refinance mortgages, Control sample: SLR counties
Column (2): Sample: Refinance mortgages, Control sample: SLR states
Column (3): Sample: New purchase mortgages, Control sample: SLR counties
Column (4): Sample: New purchase mortgages, Control sample: SLR states
Jumbo loans are 2 to 3% more likely to be retained in high risk areas
minloan = 100
maxloan = 1000
lt = 360
formula1 <- as.formula("retained~highrisk*jumbo+log(1+applicantincome)*jumbo+log(1+amountofloan)+dti*jumbo+factor(purposeofloan)+applicant_age*jumbo+cltv*jumbo+factor(typeofloan)|lender_county_year|0|countycode")
formula2 <- as.formula("retained~highrisk*jumbo+log(1+applicantincome)*jumbo+log(1+amountofloan)+dti*jumbo+applicant_age*jumbo+cltv*jumbo+factor(typeofloan)|lender_county_year|0|countycode")
regs <- list()
regs[[1]] <- felm(formula1,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan!=1 & slrcounty==1 & typeofloan<=2])
regs[[2]] <- felm(formula1,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan!=1 & slrstate==1 & typeofloan<=2])
regs[[3]] <- felm(formula2,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan==1 & slrcounty==1 & typeofloan<=2])
regs[[4]] <- felm(formula2,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan==1 & slrstate==1 & typeofloan<=2])
.printtable(regs)
##
## ==========================================================================
## Dependent variable:
## -------------------------------------------
## (1) (2) (3) (4)
## --------------------------------------------------------------------------
## highrisk
## (0.000) (0.000) (0.000) (0.000)
## jumbo 0.395*** 0.244*** 0.216*** 0.122***
## (0.061) (0.046) (0.056) (0.037)
## log(1 + applicantincome) 0.061*** 0.050*** 0.007*** 0.002
## (0.004) (0.003) (0.002) (0.001)
## log(1 + amountofloan) -0.032*** -0.032*** 0.034*** 0.024***
## (0.004) (0.003) (0.006) (0.004)
## dti 0.108*** 0.089*** -0.020*** -0.009*
## (0.011) (0.009) (0.007) (0.005)
## factor(purposeofloan)32 -0.038*** -0.035***
## (0.003) (0.002)
## applicant_age 0.001*** 0.001*** 0.0002*** 0.0001***
## (0.00005) (0.00004) (0.00003) (0.00002)
## cltv -0.00001*** -0.00000*** -0.000 -0.000
## (0.00000) (0.00000) (0.000) (0.000)
## factor(typeofloan)2 -0.001 0.0003 -0.001 -0.002
## (0.002) (0.001) (0.002) (0.002)
## highrisk:jumbo 0.021 0.009 0.028 0.016
## (0.014) (0.013) (0.018) (0.015)
## jumbo:log(1 + applicantincome) -0.021** 0.005 0.026*** 0.044***
## (0.009) (0.008) (0.006) (0.005)
## jumbo:dti -0.160*** -0.136*** -0.175*** -0.169***
## (0.028) (0.026) (0.032) (0.025)
## jumbo:applicant_age 0.0002 0.0001 0.001*** 0.001***
## (0.0003) (0.0002) (0.0002) (0.0002)
## jumbo:cltv -0.0005** -0.0001** -0.001*** -0.001***
## (0.0002) (0.00004) (0.0002) (0.0002)
## --------------------------------------------------------------------------
##
## Observations 487,971 805,929 1,256,792 2,295,848
## Adjusted R2 0.630 0.618 0.554 0.541
## ==========================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
lt = 180
regs <- list()
regs[[1]] <- felm(formula1,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan!=1 & slrcounty==1 & typeofloan<=2])
regs[[2]] <- felm(formula1,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan!=1 & slrstate==1 & typeofloan<=2])
regs[[3]] <- felm(formula2,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan==1 & slrcounty==1 & typeofloan<=2])
regs[[4]] <- felm(formula2,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & loan_term==lt & applicantincome>0 & amountofloan>minloan & amountofloan<maxloan & purposeofloan==1 & slrstate==1 & typeofloan<=2])
.printtable(regs)
##
## =====================================================================
## Dependent variable:
## --------------------------------------
## (1) (2) (3) (4)
## ---------------------------------------------------------------------
## highrisk
## (0.000) (0.000) (0.000) (0.000)
## jumbo -0.070 -0.183* 0.218 0.244*
## (0.151) (0.108) (0.196) (0.132)
## log(1 + applicantincome) 0.028*** 0.027*** 0.020*** 0.021***
## (0.005) (0.004) (0.005) (0.003)
## log(1 + amountofloan) -0.023*** -0.026*** 0.020** 0.007
## (0.005) (0.004) (0.008) (0.005)
## dti 0.047*** 0.059*** 0.029 0.050***
## (0.016) (0.015) (0.022) (0.018)
## factor(purposeofloan)32 -0.022*** -0.022***
## (0.003) (0.003)
## applicant_age 0.001*** 0.001*** 0.0002 0.0001
## (0.0001) (0.0001) (0.0001) (0.0001)
## cltv 0.00000 0.00000** 0.00002 -0.00000
## (0.00000) (0.00000) (0.0001) (0.00000)
## factor(typeofloan)2 0.0001 0.002 -0.027 -0.027*
## (0.005) (0.004) (0.021) (0.014)
## highrisk:jumbo 0.020 0.023 0.052* 0.062**
## (0.020) (0.017) (0.030) (0.026)
## jumbo:log(1 + applicantincome) 0.060*** 0.075*** 0.021 0.025
## (0.022) (0.015) (0.025) (0.016)
## jumbo:dti 0.036 0.062 -0.074 -0.192**
## (0.104) (0.072) (0.111) (0.089)
## jumbo:applicant_age 0.00001 -0.0001 -0.0002 -0.0002
## (0.001) (0.001) (0.001) (0.001)
## jumbo:cltv -0.0005 -0.0001 -0.0004 -0.001
## (0.001) (0.0004) (0.001) (0.001)
## ---------------------------------------------------------------------
##
## Observations 110,442 208,706 43,565 95,106
## Adjusted R2 0.614 0.618 0.607 0.626
## =====================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
This section looks at the difference in interest rate for 30 year mortgages relative to 15 year jumbo mortgaegs in high risk areas, relative to low risk areas. Not enough mortgages with other maturities.
\[ InterestRate = \alpha + \beta HighRisk \times Jumbo \times 30yr + \delta X \times Jumbo + Lender \times County \times Year FE\]
Column (1): Sample: Refinance mortgages, Control sample: SLR counties
Column (2): Sample: New purchase mortgages, Control sample: SLR counties
Interest rate of 30 year jumbo mortgages is 6 to 15bps higher in high risk areas relative to 15 year mortgages.
regs <- list()
regs[[1]] <- felm(interest_rate~highrisk*jumbo*factor(term)+log(1+applicantincome)*jumbo+log(1+amountofloan)+dti*jumbo+factor(purposeofloan)+applicant_age*jumbo+cltv*jumbo+factor(typeofloan)|lender_county_year|0|countycode,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & applicantincome>0 & amountofloan>0 & purposeofloan!=1 & slrcounty==1 & term %in% c(15,30) & typeofloan <= 2])
regs[[2]] <- felm(interest_rate~highrisk*jumbo*factor(term)+log(1+applicantincome)*jumbo+log(1+amountofloan)+dti*jumbo+applicant_age*jumbo+cltv*jumbo+factor(typeofloan)|lender_county_year|0|countycode,data=hmda[interest_rate>0 & interest_rate<10 & actiontaken==1 & applicantincome>0 & amountofloan>0 & purposeofloan==1 & slrcounty==1 & term %in% c(15,30) & typeofloan <= 2])
.printtable(regs)
##
## ===========================================================
## Dependent variable:
## ----------------------------
## (1) (2)
## -----------------------------------------------------------
## highrisk
## (0.000) (0.000)
## jumbo 0.217*** -0.024
## (0.079) (0.103)
## factor(term)30 0.606*** 0.686***
## (0.009) (0.041)
## log(1 + applicantincome) 0.232*** 0.069***
## (0.008) (0.011)
## log(1 + amountofloan) -0.484*** -0.128***
## (0.013) (0.024)
## dti 1.012*** 0.448***
## (0.029) (0.032)
## factor(purposeofloan)32 0.265***
## (0.009)
## applicant_age -0.001*** -0.0002*
## (0.0001) (0.0001)
## cltv 0.0001 0.000**
## (0.00005) (0.000)
## factor(typeofloan)2 -0.299*** -0.098***
## (0.007) (0.015)
## highrisk:jumbo -0.002 -0.093**
## (0.034) (0.047)
## highrisk:factor(term)30 0.016 -0.087*
## (0.013) (0.044)
## jumbo:factor(term)30 -0.271*** -0.402***
## (0.028) (0.042)
## jumbo:log(1 + applicantincome) -0.077*** -0.070***
## (0.010) (0.010)
## jumbo:dti 0.069 -0.108**
## (0.047) (0.044)
## jumbo:applicant_age 0.002*** 0.001*
## (0.001) (0.0004)
## jumbo:cltv 0.006*** 0.008***
## (0.001) (0.001)
## highrisk:jumbo:factor(term)30 0.051 0.143***
## (0.036) (0.050)
## -----------------------------------------------------------
##
## Observations 673,055 1,394,838
## Adjusted R2 0.489 0.441
## ===========================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
This section looks at the difference in denial rate for 30 year mortgages relative to 15 year jumbo mortgaegs in high risk areas, relative to low risk areas. Not enough mortgages with other maturities.
\[ Denied = \alpha + \beta HighRisk \times Jumbo \times 30yr + \delta X \times Jumbo + Lender \times County \times Year FE\]
Column (1): Sample: Refinance mortgages, Control sample: SLR counties
Column (2): Sample: New purchase mortgages, Control sample: SLR counties
Denial rate of 30 year jumbo mortgages is 2 to 16% higher in high risk areas relative to 15 year mortgages.
regs <- list()
regs[[1]] <- felm(denied~highrisk*jumbo*factor(term)+log(1+applicantincome)*jumbo+log(1+amountofloan)+dti*jumbo+factor(purposeofloan)+applicant_age*jumbo+cltv*jumbo+factor(typeofloan)|lender_county_year|0|countycode,data=hmda[ applicantincome>0 & amountofloan>0 & purposeofloan!=1 & slrcounty==1 & term %in% c(15,30) & typeofloan <= 2])
regs[[2]] <- felm(interest_rate~highrisk*jumbo*factor(term)+log(1+applicantincome)*jumbo+log(1+amountofloan)+dti*jumbo+applicant_age*jumbo+cltv*jumbo+factor(typeofloan)|lender_county_year|0|countycode,data=hmda[applicantincome>0 & amountofloan>0 & purposeofloan==1 & slrcounty==1 & term %in% c(15,30) & typeofloan <= 2])
.printtable(regs)
##
## ===========================================================
## Dependent variable:
## ----------------------------
## (1) (2)
## -----------------------------------------------------------
## highrisk
## (0.000) (0.000)
## jumbo -0.256*** 0.469**
## (0.063) (0.229)
## factor(term)30 0.067*** 0.653***
## (0.004) (0.064)
## log(1 + applicantincome) 0.013*** 0.089**
## (0.002) (0.043)
## log(1 + amountofloan) -0.066*** -0.104
## (0.002) (0.065)
## dti 1.082*** 1.319***
## (0.018) (0.345)
## factor(purposeofloan)32 -0.031***
## (0.002)
## applicant_age 0.0002*** 0.0003
## (0.0001) (0.001)
## cltv 0.00000** 0.000*
## (0.00000) (0.000)
## factor(typeofloan)2 0.073*** -0.138***
## (0.003) (0.034)
## highrisk:jumbo 0.001 -0.081
## (0.014) (0.053)
## highrisk:factor(term)30 -0.0002 -0.076
## (0.005) (0.053)
## jumbo:factor(term)30 -0.051*** -0.365***
## (0.010) (0.054)
## jumbo:log(1 + applicantincome) 0.017*** -0.104***
## (0.004) (0.028)
## jumbo:dti 0.271*** -0.964***
## (0.021) (0.291)
## jumbo:applicant_age 0.002*** 0.0005
## (0.0002) (0.001)
## jumbo:cltv 0.002*** 0.008***
## (0.001) (0.001)
## highrisk:jumbo:factor(term)30 0.029** 0.140**
## (0.014) (0.058)
## -----------------------------------------------------------
##
## Observations 973,727 1,438,930
## Adjusted R2 0.255 0.221
## ===========================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
slr_tracts <- read.dbf(file = "C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Projects/Climate Change Mortgage/slr_tracts_orgslr.dbf",as.is = TRUE)
slr_counties <- unique(substr(slr_tracts$FIPS,1,5))
slr_states <- unique(substr(slr_counties,1,2))
files <- NULL
files <- list.files(pattern="*.fst",path = "C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/HMDA/pre2004/OO_NP/",full.names = TRUE)
# files <- c(files,list.files(pattern="*.fst",path = "C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/HMDA/pre2004/OO_RF/",full.names = TRUE))
files <- c(files,list.files(pattern="*.fst",path = "C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/HMDA/OO_NP/",full.names = TRUE))
# files <- c(files,list.files(pattern="*.fst",path = "C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/HMDA/OO_RF/",full.names = TRUE))
files <- files[11:length(files)]
# files <- files[substr(files,100,103) %in% as.character(2000:2019)] #c("2014","2015","2016","2017","2018")
hmda = lapply(files, read_fst, as.data.table = TRUE,
columns=c("asofdate","state","countycode","actiontaken","applicantincome","amountofloan","typeofloan"))#,"msa","applicantrace1","typeofpurchaser","applicantethnicity""respondentid","agencycode",,"typeofloan"
hmda <- do.call(rbind , hmda)
# hmda <- hmda[asofdate>=2000 & asofdate<2017]
hmda <- hmda[typeofloan=="1"]
# hmda[,lender:=paste0(agencycode,"-",respondentid)]
hmda[,countycode:=paste0(state,countycode)]
hmda[,applicantincome := as.numeric(applicantincome)]
hmda[,amountofloan := as.numeric(amountofloan)]
hmda[,jumbo:=ifelse(asofdate==2000 & amountofloan>253,1,
ifelse(asofdate %in% 2001:2002 & amountofloan>275,1,
ifelse(asofdate==2003 & amountofloan>322.7,1,
ifelse(asofdate==2004 & amountofloan>333.7,1,
ifelse(asofdate==2005 & amountofloan>359.7,1,
ifelse(asofdate %in% 2006:2016 & amountofloan>417,1,
ifelse(asofdate==2017 & amountofloan>424.1,1,
ifelse(asofdate==2018 & amountofloan>453.1,1,
ifelse(asofdate==2019 & amountofloan>484.3,1,0)))))))))]
hmda[,denied:=ifelse(actiontaken=="3",1,ifelse(actiontaken %in% c("1","2"),0,NA))]
hmda[,slrstate:=ifelse(state %in% slr_states,1,0 )]
hmda[,slrcounty:=ifelse(countycode %in% slr_counties,1,0)]
hmda[,county_year:=paste(countycode,asofdate)]
# hmda[,lender_county_year:=paste(lender,countycode,asofdate)]
nyt <- fread("C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/NYT Flood Insurance/nyt_fema_fs_2.csv")
nyt[,fips:=str_pad(fips,width=5,pad = "0")]
nyt[,fspct:=as.numeric(fspct)/100]
nyt[,femapct:=as.numeric(femapct)/100]
nyt <- nyt[,c("fips","fspct")]
hmda <- merge(hmda,nyt,by.x="countycode",by.y="fips")
hmda[,fsbin:=floor(fspct*100/10)*10]
hmda[,fsbin:=ifelse(fsbin>40,40,fsbin)]
hmda[,highfs:=ifelse(fspct>0.133,1,0)]
hmda[,highrisk:=ifelse(highfs==1 & slrcounty==1,1,0)]
regs <- list()
regs[[1]] <- felm(denied~highrisk*jumbo*factor(asofdate)+log(1+applicantincome)*jumbo+log(1+amountofloan)|county_year|0|countycode,data=hmda[applicantincome>0 & amountofloan>0 & slrcounty==1 & asofdate %in% 2000:2019 & amountofloan<700 & amountofloan>100])
regs[[2]] <- felm(denied~highrisk*jumbo*factor(asofdate)+log(1+applicantincome)*jumbo+log(1+amountofloan)|county_year|0|countycode,data=hmda[applicantincome>0 & amountofloan>0 & slrstate==1 & asofdate %in% 2000:2019 & amountofloan<700 & amountofloan>100])
.coef_plot_2reg(regs[[1]],"Control: SLR County",regs[[2]],"Control: SLR State","highrisk:jumbo:factor(asofdate)",2000)+labs(title = "New Purchases")
slr_tracts <- read.dbf(file = "C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Projects/Climate Change Mortgage/slr_tracts_orgslr.dbf",as.is = TRUE)
slr_counties <- unique(substr(slr_tracts$FIPS,1,5))
slr_states <- unique(substr(slr_counties,1,2))
files <- NULL
files <- list.files(pattern="*.fst",path = "C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/HMDA/pre2004/OO_RF/",full.names = TRUE)
# files <- c(files,list.files(pattern="*.fst",path = "C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/HMDA/pre2004/OO_RF/",full.names = TRUE))
files <- c(files,list.files(pattern="*.fst",path = "C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/HMDA/OO_RF/",full.names = TRUE))
# files <- c(files,list.files(pattern="*.fst",path = "C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/HMDA/OO_RF/",full.names = TRUE))
files <- files[11:length(files)]
# files <- files[substr(files,100,103) %in% as.character(2000:2019)] #c("2014","2015","2016","2017","2018")
hmda = lapply(files, read_fst, as.data.table = TRUE,
columns=c("asofdate","state","countycode","actiontaken","applicantincome","amountofloan","typeofloan"))#,"msa","applicantrace1","typeofpurchaser","applicantethnicity""respondentid","agencycode",,"typeofloan"
hmda <- do.call(rbind , hmda)
hmda <- hmda[typeofloan=="1"]
hmda[,countycode:=paste0(state,countycode)]
hmda[,applicantincome := as.numeric(applicantincome)]
hmda[,amountofloan := as.numeric(amountofloan)]
hmda[,jumbo:=ifelse(asofdate==2000 & amountofloan>253,1,
ifelse(asofdate %in% 2001:2002 & amountofloan>275,1,
ifelse(asofdate==2003 & amountofloan>322.7,1,
ifelse(asofdate==2004 & amountofloan>333.7,1,
ifelse(asofdate==2005 & amountofloan>359.7,1,
ifelse(asofdate %in% 2006:2016 & amountofloan>417,1,
ifelse(asofdate==2017 & amountofloan>424.1,1,
ifelse(asofdate==2018 & amountofloan>453.1,1,
ifelse(asofdate==2019 & amountofloan>484.3,1,0)))))))))]
hmda[,denied:=ifelse(actiontaken=="3",1,ifelse(actiontaken %in% c("1","2"),0,NA))]
hmda[,slrstate:=ifelse(state %in% slr_states,1,0 )]
hmda[,slrcounty:=ifelse(countycode %in% slr_counties,1,0)]
hmda[,county_year:=paste(countycode,asofdate)]
# hmda[,lender_county_year:=paste(lender,countycode,asofdate)]
nyt <- fread("C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/NYT Flood Insurance/nyt_fema_fs_2.csv")
nyt[,fips:=str_pad(fips,width=5,pad = "0")]
nyt[,fspct:=as.numeric(fspct)/100]
nyt[,femapct:=as.numeric(femapct)/100]
nyt <- nyt[,c("fips","fspct")]
hmda <- merge(hmda,nyt,by.x="countycode",by.y="fips")
hmda[,fsbin:=floor(fspct*100/10)*10]
hmda[,fsbin:=ifelse(fsbin>40,40,fsbin)]
hmda[,highfs:=ifelse(fspct>0.133,1,0)]
hmda[,highrisk:=ifelse(highfs==1 & slrcounty==1,1,0)]
gc()
## used (Mb) gc trigger (Mb) max used (Mb)
## Ncells 2815861 150.4 7997568 427.2 9996960 533.9
## Vcells 5440252465 41505.9 9648198190 73610.0 9628295290 73458.1
regs <- list()
regs[[1]] <- felm(denied~highrisk*jumbo*factor(asofdate)+log(1+applicantincome)*jumbo+log(1+amountofloan)|county_year|0|countycode,data=hmda[applicantincome>0 & amountofloan>0 & slrcounty==1 & asofdate %in% 2000:2019 & amountofloan<700 & amountofloan>100])
gc()
## used (Mb) gc trigger (Mb) max used (Mb)
## Ncells 2815918 150.4 7997568 427.2 9996960 533.9
## Vcells 7208007111 54992.8 11577917828 88332.6 9628295290 73458.1
regs[[2]] <- felm(denied~highrisk*jumbo*factor(asofdate)+log(1+applicantincome)*jumbo+log(1+amountofloan)|county_year|0|countycode,data=hmda[applicantincome>0 & amountofloan>0 & slrstate==1 & asofdate %in% 2000:2019 & amountofloan<700 & amountofloan>100])
.coef_plot_2reg(regs[[1]],"Control: SLR County",regs[[2]],"Control: SLR State","highrisk:jumbo:factor(asofdate)",2000)+labs(title = "Refinances")