rm(list=ls())
library(data.table)
library(RSQLite)
library(DBI)
library(dplyr)
library(stargazer)
library(lfe)
library(ggplot2)
library(tidyverse)
library(stringr)
tract_zip <- fread("/data/crosswalks/TRACT_ZIP.csv")
tract_zip[,TRACT:=as.character(TRACT)]
tract_zip[,TRACT:= str_pad(TRACT,11,pad="0")]
setorder(tract_zip,TRACT,-RES_RATIO)
tract_zip <- tract_zip[!duplicated(tract_zip$TRACT)]
tract_zip <- tract_zip[,c("TRACT","ZIP")]
dbdir = "/data/hmda.db"
con <- dbConnect(RSQLite::SQLite(),dbdir)
lar <- data.table(dbGetQuery(con,"
SELECT asofdate,respondentid,censustract,conforming_loan_limit,derived_race,derived_ethnicity,typeofpurchaser,typeofloan,purposeofloan,amountofloan,combined_loan_to_value_ratio,interest_rate,total_loan_costs,total_points_and_fees,origination_charges,discount_points,lender_credits,loan_term,property_value,occupancy,applicantincome,debt_to_income_ratio,applicant_age,co_applicant_race_1
FROM lar
where actiontaken=1
and propertytype=1
and lienstatus=1
and business_or_commercial_purpose=2
and hoepastatus in (2,3)
and occupancy=1"))
dbDisconnect(con)
lar <- lar %>% mutate_at(.vars =vars(interest_rate,combined_loan_to_value_ratio,property_value,total_loan_costs,total_points_and_fees,origination_charges,discount_points,loan_term,lender_credits),.funs= as.numeric)
lar[,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)))))))]
lar[,debt_to_income_ratio:=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))))))]
lar[,debt_to_income_ratio:=as.numeric(debt_to_income_ratio)]
lar[,debt_to_income_ratio:=ifelse(debt_to_income_ratio>1,debt_to_income_ratio/100,debt_to_income_ratio)]
lar[,loan_term:=ifelse(loan_term>=100 & loan_term<=120,120,
ifelse(loan_term>120 & loan_term<= 180,180,
ifelse(loan_term>180 & loan_term <= 240,240,
ifelse(loan_term>240 & loan_term<=300,300,
ifelse(loan_term>300 & loan_term<=400,360,loan_term)))))]
lar <- lar[loan_term>=120 & loan_term<=360]
lar[,conforming:=ifelse(conforming_loan_limit %in% c("C","U"),1,0)]
lar[,newpurchase:=ifelse(purposeofloan== 1,1,0)]
lar[,refinance:=ifelse(purposeofloan== 31,1,0)]
lar[,cashoutrefinance:=ifelse(purposeofloan== 32,1,0)]
lar[,white:=ifelse(derived_race=="White",1,0)]
lar[,costfrac:=total_loan_costs/(amountofloan*1000)]
lar[,origfeefrac:=origination_charges/(amountofloan*1000)]
lar[,amt100k:=amountofloan/100]
lar[,county_year:=paste(substr(censustract,1,5),asofdate)]
lar[,tract_year:=paste(censustract,asofdate)]
lar[,tract_bank:=paste(censustract,respondentid)]
lar[,raceethnicity:=ifelse(derived_race %in% c("White") & derived_ethnicity %in% c("Hispanic or Latino"),"Hispanic",
ifelse(derived_race %in% c("Race Not Available","Native Hawaiian or Other Pacific Islander","Joint","Free Form Text Only","American Indian or Alaska Native","2 or more minority races","Asian"),"Asian/other",ifelse(derived_race=="White","0white",derived_race)))]
lar <- merge(lar,tract_zip,by.x="censustract",by.y="TRACT")
lar[,ZIP3:=floor(ZIP/100)*100]
lar[,amountofloan:=floor(amountofloan/10)*10]
lar[,interest_rate_round:=floor(interest_rate*10)/10]
lar[,state_year:=paste(substr(censustract,1,2),asofdate)]
lar[,tract_bank_year:=paste(tract_bank,asofdate)]
lar[,state_year_bank:=paste(state_year,respondentid)]
freddiehmda <- lar[typeofpurchaser==3]
freddiehmda[,matchstring:=paste(asofdate,ZIP3,amountofloan,loan_term,purposeofloan,property_value,interest_rate_round)]
t <- freddiehmda[,.N,by=matchstring]
freddiehmda <- freddiehmda[matchstring %in% t[N==1]$matchstring]
dbdir = "/data/freddie/freddie.db"
fredcon <- dbConnect(RSQLite::SQLite(),dbdir)
freddie <- data.table(dbGetQuery(fredcon,"SELECT Credit_Score,First_Payment_Date,First_Time_Homebuyer_Flag,Occupancy_Status,Original_Combined_LTV,Original_DTI_Ratio,Original_UPB,Original_LTV,Postal_Code,Loan_Purpose,Original_Loan_Term,Original_Interest_Rate,Property_Type FROM acq where First_Payment_Date >201800"))
dbDisconnect(fredcon)
freddie[,property_val:=Original_UPB*100/Original_LTV]
freddie[,property_val:=floor(property_val/10000)*10000+5000]
freddie[,purpose:=ifelse(Loan_Purpose=="P",1,ifelse(Loan_Purpose=="C",32,ifelse(Loan_Purpose=="N",31,0)))]
freddie[,interest_rate_round:=floor(Original_Interest_Rate*10)/10]
freddie[,matchstring:=paste(floor(First_Payment_Date/100),Postal_Code,floor(Original_UPB/10000)*10,Original_Loan_Term,purpose,property_val,interest_rate_round)]
t <- freddie[,.N,by=matchstring]
freddie <- freddie[matchstring %in% t[N==1]$matchstring]
freddie <- merge(freddie,freddiehmda,by="matchstring")
fanniehmda <- lar[typeofpurchaser==1]
fanniehmda[,matchstring:=paste(asofdate,ZIP3,amountofloan,loan_term,purposeofloan,property_value,interest_rate_round)]
t <- fanniehmda[,.N,by=matchstring]
fanniehmda <- fanniehmda[matchstring %in% t[N==1]$matchstring]
dbdir = "/data/fannie/fannie.db"
fanncon <- dbConnect(RSQLite::SQLite(),dbdir)
fannie <- data.table(dbGetQuery(fanncon,"SELECT Credit_Score,First_Payment_Date,First_Time_Homebuyer_Flag,Occupancy_Status,Original_Combined_LTV,Original_DTI_Ratio,Original_UPB,Original_LTV,Postal_Code,Loan_Purpose,Original_Loan_Term,Original_Interest_Rate,Property_Type FROM acq where First_Payment_Date >201800"))
dbDisconnect(fanncon)
fannie[,First_Payment_Date:=as.integer(First_Payment_Date)]
fannie[,Postal_Code:=as.numeric(Postal_Code)*100]
fannie[,property_val:=Original_UPB*100/Original_LTV]
fannie[,property_val:=floor(property_val/10000)*10000+5000]
fannie[,purpose:=ifelse(Loan_Purpose=="P",1,ifelse(Loan_Purpose=="C",32,ifelse(Loan_Purpose=="R",31,0)))]
fannie[,interest_rate_round:=floor(Original_Interest_Rate*10)/10]
fannie[,matchstring:=paste(floor(First_Payment_Date/100),Postal_Code,floor(Original_UPB/10000)*10,Original_Loan_Term,purpose,property_val,interest_rate_round)]
t <- fannie[,.N,by=matchstring]
fannie <- fannie[matchstring %in% t[N==1]$matchstring]
fannie <- merge(fannie,fanniehmda,by="matchstring")
hmdagse <- rbind(freddie,fannie)
hmdagse[,first_time_buyer:=ifelse(First_Time_Homebuyer_Flag=="Y",1,0)]
rm(list=c("con","fredcon","fanncon","fannie","fanniehmda","freddie","freddiehmda","t","tract_zip"))
gc()
## used (Mb) gc trigger (Mb) max used (Mb)
## Ncells 12613746 673.7 22921381 1224.2 22908080 1223.5
## Vcells 657219507 5014.2 1501770510 11457.6 1501725221 11457.3
acs <- fread("/data/acs_2018_educ.csv")
acs[,GEOID:=as.character(GEOID)]
acs[,GEOID:=str_pad(GEOID,11,pad="0")]
lar <- merge(lar,acs,by.x="censustract",by.y="GEOID")
hmdagse <- merge(hmdagse,acs,by.x="censustract",by.y="GEOID")
stargazer(lar[, c("asofdate","conforming","newpurchase","refinance","cashoutrefinance","white","amountofloan","combined_loan_to_value_ratio","interest_rate","total_loan_costs","total_points_and_fees","origination_charges","discount_points","lender_credits","loan_term","property_value","applicantincome","debt_to_income_ratio","applicant_age","costfrac","collegefraction_adults")], type = "text", summary.stat = c("mean", "sd","p25","median","p75","n"),notes = "",digits = 4)
##
## ==========================================================================================================
## Statistic Mean St. Dev. Pctl(25) Median Pctl(75) N
## ----------------------------------------------------------------------------------------------------------
## asofdate 2,018.5630 0.4960 2,018 2,019 2,019 12,296,807
## conforming 0.9411 0.2354 1 1 1 12,296,807
## newpurchase 0.5788 0.4938 0 1 1 12,296,807
## refinance 0.2022 0.4016 0 0 0 12,296,807
## cashoutrefinance 0.1787 0.3831 0 0 0 12,296,807
## white 0.7257 0.4462 0 1 1 12,296,807
## amountofloan 272.5546 243.3246 150 220 330 12,296,807
## combined_loan_to_value_ratio 95.9675 18,858.9500 70.0000 80.0000 95.0000 11,770,009
## interest_rate 4.4919 108.4656 3.8750 4.3750 4.7500 12,256,319
## total_loan_costs 4,990.1240 15,784.8400 2,751.6800 4,082.5000 6,294.2200 11,528,408
## total_points_and_fees 3,301.6870 4,304.0080 1,195.0000 2,196.0000 4,236.5600 57,833
## origination_charges 1,861.6510 2,678.6140 700.0000 1,245.0000 2,311.6900 11,517,881
## discount_points 2,064.6830 2,952.5520 562.4500 1,344.6300 2,765.0000 4,218,005
## lender_credits 2,098.3060 1,919,230.0000 92.5000 455.6300 1,336.9800 4,652,184
## loan_term 336.5462 59.3422 360 360 360 12,296,807
## property_value 389,761.7000 2,176,061.0000 195,000.0000 285,000.0000 435,000.0000 12,095,782
## applicantincome 121.8436 1,457.3520 56.0000 84.0000 128.0000 11,829,570
## debt_to_income_ratio 0.3660 0.1051 0.2500 0.3800 0.4400 11,780,140
## applicant_age 45.9473 14.6154 30.0000 40.0000 60.0000 12,290,747
## costfrac 0.0224 0.0769 0.0105 0.0189 0.0310 11,528,408
## collegefraction_adults 0.2758 0.0717 0.2310 0.2803 0.3252 12,275,496
## ----------------------------------------------------------------------------------------------------------
##
Sample restricted to new purchases, 30 year fixed, loan-to-value=80, and conforming
templar <- lar[applicantincome>0 & newpurchase==1 & typeofloan==1 & loan_term==360 & combined_loan_to_value_ratio==80 & amountofloan>=100 & amountofloan<=400 & conforming==1]
templar[,amountbin:=floor(amountofloan/25)*25]
templar <- templar[raceethnicity %in% c("Hispanic","0white","Black or African American"),.(cost=mean(costfrac,na.rm=T)),by=.(amountbin,raceethnicity)]
templar[,raceethnicity:=ifelse(raceethnicity=="0white","White",raceethnicity)]
ggplot(data=templar,aes(x=amountbin,y=cost,color=raceethnicity))+geom_line()+theme_minimal()+theme(legend.position = "bottom",legend.title = element_blank())+labs(x="Loan amount $'000",y="Closing costs as a % of loan amount")
Sample: 30 year fixed
r <- list()
r[[1]] <-felm(I(costfrac*100)~log(amt100k)+interest_rate+log(applicantincome)+log(applicant_age)+factor(raceethnicity)+combined_loan_to_value_ratio+debt_to_income_ratio+conforming|tract_year|0|censustract,data=lar[applicantincome>0 & newpurchase==1 & typeofloan==1 & loan_term==360])
r[[2]] <-felm(I(costfrac*100)~log(amt100k)+interest_rate+log(applicantincome)+log(applicant_age)+factor(raceethnicity)+combined_loan_to_value_ratio+debt_to_income_ratio+conforming|tract_bank_year|0|censustract,data=lar[applicantincome>0 & newpurchase==1 & typeofloan==1 & loan_term==360])
r[[3]] <-felm(I(costfrac*100)~log(amt100k)+interest_rate+log(applicantincome)+log(applicant_age)+factor(raceethnicity)+combined_loan_to_value_ratio+debt_to_income_ratio+conforming+cashoutrefinance|tract_year|0|censustract,data=lar[applicantincome>0 & newpurchase==0 & typeofloan==1 & loan_term==360])
r[[4]] <-felm(I(costfrac*100)~log(amt100k)+interest_rate+log(applicantincome)+log(applicant_age)+factor(raceethnicity)+combined_loan_to_value_ratio+debt_to_income_ratio+conforming+cashoutrefinance|tract_bank_year|0|censustract,data=lar[applicantincome>0 & newpurchase==0 & typeofloan==1 & loan_term==360])
stargazer(r,no.space = T,align = T,omit.stat=c("ser","f", "adj.rsq"),style = "qje",omit.table.layout = "n", dep.var.labels.include = FALSE,type="text",column.labels = c("New purchases","Refinances"), column.separate = c(2,2),
add.lines = list(c("Censustract*year","Y","N","Y","N"),c("Censustract*bank*Year","N","Y","N","Y")))
##
## ========================================================================================
## New purchases Refinances
## (1) (2) (3) (4)
## ----------------------------------------------------------------------------------------
## log(amt100k) -2.116*** -1.374*** -1.594*** -1.275***
## (0.055) (0.056) (0.034) (0.020)
## interest_rate 0.004 0.003 0.0001 0.0002
## (0.003) (0.002) (0.0001) (0.001)
## log(applicantincome) 0.550*** 0.107** 0.158*** 0.029**
## (0.048) (0.053) (0.022) (0.011)
## log(applicant_age) -0.041** 0.051*** 0.059*** 0.062***
## (0.019) (0.015) (0.011) (0.006)
## factor(raceethnicity)Asian/other 0.070*** 0.054 0.126*** 0.046***
## (0.022) (0.036) (0.004) (0.003)
## factor(raceethnicity)Black or African American 0.115*** 0.072*** 0.179*** 0.129***
## (0.012) (0.017) (0.008) (0.010)
## factor(raceethnicity)Hispanic 0.122*** 0.054*** 0.087*** 0.065***
## (0.011) (0.016) (0.006) (0.006)
## combined_loan_to_value_ratio -0.000*** -0.00000 -0.00000*** 0.00004
## (0.000) (0.00000) (0.00000) (0.00004)
## debt_to_income_ratio 1.459*** 0.058 1.111*** 0.300***
## (0.076) (0.040) (0.067) (0.035)
## conforming -0.607*** -0.452*** -0.620*** -0.520***
## (0.011) (0.007) (0.011) (0.009)
## cashoutrefinance 0.215*** 0.214***
## (0.003) (0.003)
## Censustract*year Y N Y N
## Censustract*bank*Year N Y N Y
## N 4,128,063 4,128,063 2,265,813 2,265,813
## R2 0.038 0.129 0.168 0.941
## ========================================================================================
r <- list()
r[[1]] <-felm(I(costfrac*100)~collegefraction_adults+log(amt100k)+interest_rate+log(applicantincome)+log(applicant_age)+factor(raceethnicity)+combined_loan_to_value_ratio+debt_to_income_ratio+conforming|state_year_bank|0|censustract,data=lar[applicantincome>0 & newpurchase==1 & typeofloan==1 & loan_term==360])
r[[2]] <-felm(I(costfrac*100)~collegefraction_adults+log(amt100k)+interest_rate+log(applicantincome)+log(applicant_age)+factor(raceethnicity)+combined_loan_to_value_ratio+debt_to_income_ratio+conforming+cashoutrefinance|state_year_bank|0|censustract,data=lar[applicantincome>0 & newpurchase==0 & typeofloan==1 & loan_term==360])
stargazer(r,no.space = T,align = T,omit.stat=c("ser","f", "adj.rsq"),style = "qje",omit.table.layout = "n", dep.var.labels.include = FALSE,type="text",column.labels = c("New purchases","Refinances"), add.lines = list(c("State*Year*Bank",rep("Y",2))))
##
## =======================================================================
## New purchases Refinances
## (1) (2)
## -----------------------------------------------------------------------
## collegefraction_adults -0.567*** -0.311***
## (0.030) (0.027)
## log(amt100k) -1.618*** -1.581***
## (0.062) (0.022)
## interest_rate 0.004 0.0001
## (0.003) (0.0001)
## log(applicantincome) 0.232*** 0.176***
## (0.056) (0.015)
## log(applicant_age) 0.053*** 0.011
## (0.005) (0.008)
## factor(raceethnicity)Asian/other 0.063** 0.036***
## (0.028) (0.003)
## factor(raceethnicity)Black or African American 0.100*** 0.151***
## (0.008) (0.007)
## factor(raceethnicity)Hispanic 0.077*** 0.098***
## (0.004) (0.004)
## combined_loan_to_value_ratio -0.00000*** -0.00000
## (0.000) (0.00000)
## debt_to_income_ratio 0.498*** 0.754***
## (0.049) (0.049)
## conforming -0.629*** -0.735***
## (0.012) (0.009)
## cashoutrefinance 0.192***
## (0.004)
## State*Year*Bank Y Y
## N 4,124,798 2,264,864
## R2 0.015 0.201
## =======================================================================
So that we can control for Credit Score
stargazer(hmdagse[, c("asofdate","conforming","newpurchase","refinance","cashoutrefinance","white","amountofloan","combined_loan_to_value_ratio","interest_rate","total_loan_costs","total_points_and_fees","origination_charges","discount_points","lender_credits","loan_term","property_value","applicantincome","debt_to_income_ratio","applicant_age","costfrac","collegefraction_adults","Credit_Score","first_time_buyer")], type = "text", summary.stat = c("mean", "sd","p25","median","p75","n"),notes = "",digits = 4)
##
## =================================================================================================
## Statistic Mean St. Dev. Pctl(25) Median Pctl(75) N
## -------------------------------------------------------------------------------------------------
## asofdate 2,018.5710 0.4949 2,018 2,019 2,019 1,542,055
## conforming 0.9910 0.0943 1 1 1 1,542,055
## newpurchase 0.5216 0.4995 0 1 1 1,542,055
## refinance 0.2098 0.4071 0 0 0 1,542,055
## cashoutrefinance 0.2686 0.4432 0 0 1 1,542,055
## white 0.7287 0.4446 0 1 1 1,542,055
## amountofloan 237.6225 128.3297 140 210 320 1,542,055
## combined_loan_to_value_ratio 76.2615 191.4563 68.0000 80.0000 89.2300 1,533,341
## interest_rate 4.3559 0.5970 3.8750 4.3750 4.7500 1,542,055
## total_loan_costs 4,079.1110 34,705.3700 2,578.6200 3,509.5000 4,919.0950 1,533,635
## total_points_and_fees 3,222.0880 3,094.1550 1,195.0000 2,057.0200 4,391.5230 2,714
## origination_charges 2,001.5430 2,328.8980 895.0000 1,295.0000 2,589.0230 1,529,488
## discount_points 2,060.0280 4,367.9220 562.0000 1,400.0000 2,843.7500 681,593
## lender_credits 1,015.2930 2,595.4410 99.2100 425.0000 1,132.9100 576,843
## loan_term 322.0569 71.3504 360 360 360 1,542,055
## property_value 325,900.4000 173,217.4000 195,000 295,000 415,000 1,542,055
## applicantincome 102.0072 589.0352 58.0000 87.0000 127.0000 1,522,461
## debt_to_income_ratio 0.3519 0.0951 0.2500 0.3600 0.4300 1,536,674
## applicant_age 46.6851 14.2323 40.0000 50.0000 60.0000 1,541,873
## costfrac 0.0206 0.1778 0.0110 0.0175 0.0271 1,533,635
## collegefraction_adults 0.2772 0.0693 0.2327 0.2807 0.3250 1,540,287
## Credit_Score 748.6299 149.6718 713.0000 755.0000 786.0000 1,540,800
## first_time_buyer 0.2313 0.4217 0 0 0 1,542,055
## -------------------------------------------------------------------------------------------------
##
templar <- hmdagse[applicantincome>0 & newpurchase==1 & typeofloan==1 & loan_term==360 & combined_loan_to_value_ratio==80 & amountofloan>=100 & amountofloan<=400 ]
templar[,amountbin:=floor(amountofloan/25)*25]
templar <- templar[raceethnicity %in% c("Hispanic","0white","Black or African American"),.(cost=mean(costfrac,na.rm=T)),by=.(amountbin,raceethnicity)]
templar[,raceethnicity:=ifelse(raceethnicity=="0white","White",raceethnicity)]
ggplot(data=templar,aes(x=amountbin,y=cost,color=raceethnicity))+geom_line()+theme_minimal()+theme(legend.position = "bottom",legend.title = element_blank())+labs(x="Loan amount $'000",y="Closing costs as a % of loan amount")
Sample: 30 year fixed
r <- list()
r[[1]] <-felm(I(costfrac*100)~log(amt100k)+interest_rate+log(applicantincome)+log(applicant_age)+factor(raceethnicity)+combined_loan_to_value_ratio+debt_to_income_ratio+I(Credit_Score/100)+first_time_buyer+factor(typeofpurchaser)|tract_year|0|censustract,data=hmdagse[applicantincome>0 & newpurchase==1 & typeofloan==1 & loan_term==360])
r[[2]] <-felm(I(costfrac*100)~log(amt100k)+interest_rate+log(applicantincome)+log(applicant_age)+factor(raceethnicity)+combined_loan_to_value_ratio+debt_to_income_ratio+I(Credit_Score/100)+first_time_buyer+factor(typeofpurchaser)|county_year+tract_bank|0|censustract,data=hmdagse[applicantincome>0 & newpurchase==1 & typeofloan==1 & loan_term==360])
r[[3]] <-felm(I(costfrac*100)~log(amt100k)+interest_rate+log(applicantincome)+log(applicant_age)+factor(raceethnicity)+combined_loan_to_value_ratio+debt_to_income_ratio+cashoutrefinance+I(Credit_Score/100)+factor(typeofpurchaser)|tract_year|0|censustract,data=hmdagse[applicantincome>0 & newpurchase==0 & typeofloan==1 & loan_term==360])
r[[4]] <-felm(I(costfrac*100)~log(amt100k)+interest_rate+log(applicantincome)+log(applicant_age)+factor(raceethnicity)+combined_loan_to_value_ratio+debt_to_income_ratio+cashoutrefinance+I(Credit_Score/100)+factor(typeofpurchaser)|county_year+tract_bank|0|censustract,data=hmdagse[applicantincome>0 & newpurchase==0 & typeofloan==1 & loan_term==360])
stargazer(r,no.space = T,align = T,omit.stat=c("ser","f","adj.rsq"),style = "qje",omit.table.layout = "n", dep.var.labels.include = FALSE,type="text",column.labels = c("New purchases","Refinances"), column.separate = c(2,2),
add.lines = list(c("Censustract*Year","Y","N","Y","N"),c("Censustract*bank*year","N","Y","N","Y")))
##
## ======================================================================================
## New purchases Refinances
## (1) (2) (3) (4)
## --------------------------------------------------------------------------------------
## log(amt100k) -1.725*** -1.871*** -1.374*** -1.681***
## (0.198) (0.401) (0.017) (0.013)
## interest_rate -0.159*** -0.329*** -0.199*** -0.458***
## (0.051) (0.093) (0.020) (0.021)
## log(applicantincome) 0.326 0.433 -0.076*** -0.035***
## (0.253) (0.339) (0.007) (0.011)
## log(applicant_age) -0.072 -0.140 0.161*** 0.198***
## (0.127) (0.195) (0.024) (0.012)
## factor(raceethnicity)Asian/other 0.222 0.319 0.171*** 0.036***
## (0.149) (0.296) (0.013) (0.007)
## factor(raceethnicity)Black or African American 0.169** 0.262* 0.191*** 0.096***
## (0.072) (0.152) (0.018) (0.021)
## factor(raceethnicity)Hispanic 0.126* 0.193 0.059*** 0.031**
## (0.073) (0.143) (0.011) (0.015)
## combined_loan_to_value_ratio 0.00004 0.00004 0.0002 0.011***
## (0.00005) (0.0001) (0.0002) (0.0003)
## debt_to_income_ratio 0.418*** -0.137 0.123 0.048
## (0.128) (0.344) (0.079) (0.058)
## cashoutrefinance 0.327*** 0.448***
## (0.007) (0.006)
## I(Credit_Score/100) -0.006*** 0.001 -0.213*** -0.326***
## (0.002) (0.011) (0.037) (0.059)
## first_time_buyer -0.029 -0.132
## (0.040) (0.138)
## factor(typeofpurchaser)3 -0.019 -0.065 0.001 -0.014**
## (0.026) (0.063) (0.021) (0.007)
## Censustract*Year Y N Y N
## Censustract*bank*year N Y N Y
## N 689,177 689,177 468,084 468,084
## R2 0.078 0.146 0.194 0.977
## ======================================================================================
r <- list()
r[[1]] <-felm(I(costfrac*100)~collegefraction_adults*I(Credit_Score/100)+log(amt100k)+interest_rate+log(applicantincome)+log(applicant_age)+factor(raceethnicity)+combined_loan_to_value_ratio+debt_to_income_ratio+conforming|state_year_bank|0|censustract,data=hmdagse[applicantincome>0 & newpurchase==1 & typeofloan==1 & loan_term==360])
r[[2]] <-felm(I(costfrac*100)~collegefraction_adults*I(Credit_Score/100)+log(amt100k)+interest_rate+log(applicantincome)+log(applicant_age)+factor(raceethnicity)+combined_loan_to_value_ratio+debt_to_income_ratio+conforming+cashoutrefinance|state_year_bank|0|censustract,data=hmdagse[applicantincome>0 & newpurchase==0 & typeofloan==1 & loan_term==360])
stargazer(r,no.space = T,align = T,omit.stat=c("ser","f", "adj.rsq"),style = "qje",omit.table.layout = "n", dep.var.labels.include = FALSE,type="text",column.labels = c("New purchases","Refinances"), add.lines = list(c("State*Year*Bank",rep("Y",2))))
##
## =======================================================================
## New purchases Refinances
## (1) (2)
## -----------------------------------------------------------------------
## collegefraction_adults -0.636*** -2.350
## (0.222) (2.864)
## I(Credit_Score/100) -0.008*** -0.265**
## (0.003) (0.119)
## log(amt100k) -1.936*** -1.610***
## (0.325) (0.012)
## interest_rate -0.253*** -0.262***
## (0.039) (0.016)
## log(applicantincome) 0.444 -0.004
## (0.313) (0.007)
## log(applicant_age) 0.053*** 0.038
## (0.020) (0.029)
## factor(raceethnicity)Asian/other 0.204 0.034***
## (0.163) (0.008)
## factor(raceethnicity)Black or African American 0.173*** 0.165***
## (0.039) (0.016)
## factor(raceethnicity)Hispanic 0.060*** 0.083***
## (0.023) (0.010)
## combined_loan_to_value_ratio 0.00002 0.0002
## (0.00003) (0.0002)
## debt_to_income_ratio 0.480*** 0.173***
## (0.175) (0.056)
## conforming -0.320*** -0.429***
## (0.034) (0.040)
## cashoutrefinance 0.299***
## (0.006)
## collegefraction_adults:I(Credit_Score/100) 0.006 0.290
## (0.020) (0.387)
## State*Year*Bank Y Y
## N 688,274 467,860
## R2 0.009 0.077
## =======================================================================