rm(list=ls())
library(stargazer)
library(data.table)
library(ggplot2)
library(lfe)
library(rgdal)
library(rgeos)
library(gridExtra)
library(scales)
library(zoo)
library(foreign)
library(fst)
‘Policies_Nov2019.fst’ is available here
Script used to create ‘Policies_Nov2019.fst’ is available here
policies <- read_fst("C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/NFIP/policies/Policies_Nov2019.fst",
as.data.table = TRUE,
columns = c("reportedzipcode","effectivemonth","basefloodelevation","censustract","condominiumindicator","construction","countycode","crsdiscount","deductibleamountinbuildingcoverage","deductibleamountincontentscoverage","elevatedbuildingindicator","elevationdifference","floodzone","latitude","longitude","numberoffloorsininsuredbuilding","occupancytype","originalconstructiondate","originalnbdate","policycount","postfirmconstructionindicator","primaryresidenceindicator","propertystate","reportedcity","totalbuildinginsurancecoverage","totalcontentsinsurancecoverage","policycost","censustract11","policyduration","policyCost1dollarcov","floodzone_cat","SFHA","construction_year","house_age","zhvi","effectiveyear","totalcoverage"))
policies[,year:=as.factor(policies$effectiveyear)]
policies[,censustract:=policies$censustract11]
policies[,countycode:=substr(policies$censustract,1,5)]
policies[,contentscovered:=ifelse(policies$totalcontentsinsurancecoverage>0,1,0)]
deductible <- data.frame(deductibleamountinbuildingcoverage = c("0","1","2","3","4","5","9","A","B","C","D","E","F","G"), buildingdeductible
= c(500,1000,2000,3000,4000,5000,750,10000,15000,20000,25000,50000,1250,1500),stringsAsFactors = FALSE)
deductible <- data.table(deductible)
policies <- merge(policies,deductible,by="deductibleamountinbuildingcoverage")
policies[,maxdeductible:=ifelse((policies$policyeffectivedate<"2015-04-01" & policies$buildingdeductible==5000)| (policies$policyeffectivedate>="2015-04-01" & policies$buildingdeductible==10000),1,0)]
policies[,maxdeductible5000:=ifelse(policies$buildingdeductible>=5000,1,0)]
policies[,nbyear:=year(policies$originalnbdate)]
‘countypres_2000-2016.RData’ is available here
Raw data is available here
load(file="C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/Presidential Election/countypres_2000-2016.RData")
election <- x
rm(x)
election <- data.table(election)
election <- election[election$year %in% c(2012,2016)& election$party=="republican"]
election <- election[,c("year","FIPS","candidatevotes","totalvotes")]
election[,rep_pct:=election$candidatevotes/election$totalvotes]
e_2012 <- election[election$year==2012,c("FIPS","rep_pct")]
names(e_2012) <- c("countycode","rep_pct_2012")
e_2016 <- election[election$year==2016,c("FIPS","rep_pct")]
names(e_2016) <- c("countycode","rep_pct_2016")
election <- merge(e_2012,e_2016,by="countycode")
election <- election[!is.na(election$countycode)]
election[,rep_gain:=log(election$rep_pct_2016/election$rep_pct_2012)]
election$countycode <- as.character(election$countycode)
election$countycode <- ifelse(nchar(election$countycode)<5,paste("0",election$countycode,sep=""),election$countycode)
rm(list=c("e_2012","e_2016"))
‘yale.fst’ is available here
Script used to create ‘yale.fst’ is available here
yale <- read_fst("C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/NFIP/yale.fst",as.data.table = TRUE)
‘DisasterDeclarationsSummaries.csv’ from: https://www.fema.gov/openfema-dataset-disaster-declarations-summaries-v1
disaster_dec <- read.csv(file="C:/Users/dratnadiwakara2/Downloads/DisasterDeclarationsSummaries.csv",stringsAsFactors = FALSE)
disaster_dec <- disaster_dec[disaster_dec$paProgramDeclared==1 & disaster_dec$hmProgramDeclared==1 & disaster_dec$disasterType %in% c("DR","EM"),]
disaster_dec['flooding'] <- sapply(disaster_dec$title,function(x) as.numeric(regexpr("FLOODING",x)>0 |regexpr("FLOOD",x)>0 | regexpr("HURRICANE",x)>0 | regexpr("STORM",x)>0) )
disaster_dec <- disaster_dec[disaster_dec$flooding==1 | disaster_dec$incidentType=="Flood",]
disaster_dec <- disaster_dec[,c("disasterNumber","state","incidentType","title","fyDeclared","declaredCountyArea")]
disaster_dec$declaredCountyArea <- gsub('[[:punct:]]', '', disaster_dec$declaredCountyArea)
disaster_dec$declaredCountyArea <- paste(disaster_dec$declaredCountyArea,disaster_dec$state,sep=", ")
disaster_dec$declaredCountyArea <- tolower(disaster_dec$declaredCountyArea)
county_fips <- read.csv(file="C:/Users/dratnadiwakara2/Downloads/county_fips_master.csv",stringsAsFactors = FALSE)
county_fips$declaredCountyArea <- paste(county_fips$county_name,county_fips$state_abbr,sep=", ")
county_fips <- county_fips[,c("fips","declaredCountyArea")]
county_fips$declaredCountyArea <- tolower(county_fips$declaredCountyArea)
disaster_dec <- merge(disaster_dec,county_fips,by="declaredCountyArea",all.x=TRUE)
disaster_dec['countycode']<-as.character(disaster_dec$fips)
disaster_dec['countycode'] <- ifelse(nchar(disaster_dec$countycode)==4,paste("0",disaster_dec$countycode,sep=""),disaster_dec$countycode)
disaster_dec <- disaster_dec[!is.na(disaster_dec$countycode),c("fyDeclared","countycode")]
names(disaster_dec) <- c("year","countycode")
disaster_dec['disaster_1'] <- 1
disaster_dec$year <- disaster_dec$year+1
disaster_dec <- disaster_dec[!duplicated(disaster_dec),]
disaster_sum <- data.table(disaster_dec)
disaster_sum <- disaster_sum[,.(disasters=sum(disaster_1)),by=.(countycode)]
us_state <- 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_state <- fortify(us_state,region="STATEFP")
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
counties <- fortify(counties,region="GEOID")
t <- data.frame(counties[,"id"],stringsAsFactors = FALSE)
names(t) <- "countycode"
t2 <- merge(t,disaster_sum,by="countycode",all.x=TRUE)
counties <- cbind(counties,t2)
col_list <- c("gray90","gray85","gray80","gray75","gray60","gray50","gray40","gray20","gray10")
gr <- ggplot()+
geom_polygon(data = counties[!substr(counties$id,1,2) %in% c("02","15","72"),],aes(x = long, y = lat, group = group,fill=disasters),color="gray20")+
geom_polygon(data = us_state[!us_state$id %in% c("02","15","72"),],aes(x = long, y = lat, group = group),color="black",fill=NA)+
# scale_color_manual(values=c("bisque3","midnightblue"))+
# scale_fill_manual(values=c("bisque3","midnightblue"))+
theme_minimal()+
theme(legend.position = "bottom",panel.grid = element_blank(),axis.text = element_blank(),legend.title = element_blank())+
xlab("")+
ylab("")+
scale_fill_gradient(low="gray",high="black",na.value = "white")
# scale_color_manual(values = col_list,na.value="white") +
# scale_fill_manual(values = col_list,na.value="white")
# ggtitle("Fraction of homes with A and V policies")
gr
‘acs.fst’ is available here
Script used to create ‘acs.fst’ is available here
acs <- read_fst("C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/NFIP/acs.fst",as.data.table = TRUE)
# temp <- policies[policies$effectiveyear<= policies$nbyear]
policies_count <- policies[,.(count=.N,policycost=median(policyCost1dollarcov,na.rm=TRUE),crsdiscount=mean(crsdiscount,na.rm=TRUE)),by=.(censustract,SFHA,effectiveyear)]#,deductible=median(buildingdeductible,na.rm=TRUE)
policies_count <- policies_count[!is.na(policies_count$censustract)]
policies_count <- data.table::dcast(policies_count,censustract+effectiveyear~SFHA,value.var = c("count","policycost","crsdiscount")) #,"deductible"
names(policies_count) <- c("censustract","year","lr_policies","hr_policies","lr_cost","hr_cost","crsdiscount_lr","crsdiscount_hr") #,"deductible_lr","deductible_hr"
policies_count <- merge(acs,policies_count,by=c("censustract","year"),all.x=TRUE) #[substr(acs$censustract,1,2) %in% coastal_states_fips]
policies_count[is.na(policies_count)] <- 0
policies_count[,total_policies:=policies_count$lr_policies+policies_count$hr_policies]
policies_count[,policies_fraction:=policies_count$total_policies/policies_count$no_of_homes]
policies_count[,policies_fraction:=ifelse(!is.finite(policies_count$policies_fraction) | policies_count$policies_fraction>1,1,policies_count$policies_fraction)]
policies_count[,policies_fraction_cat:=ifelse(policies_count$policies_fraction<0.01,"1. less than 1%",
ifelse(policies_count$policies_fraction<0.025,"2. 1% to 2.5%",
ifelse(policies_count$policies_fraction<0.1,"3. 2.5% to 10%",
ifelse(policies_count$policies_fraction<0.25,"4. 10% pct to 25%",
ifelse(policies_count$policies_fraction<0.5,"5. 25% to 50%","6. More than 50%")))))]
policies_count[,hr_fraction:=policies_count$hr_policies/policies_count$no_of_homes]
policies_count[,hr_fraction:=ifelse(!is.finite(policies_count$hr_fraction) | policies_count$hr_fraction>1,1,policies_count$hr_fraction)]
policies_count[,hr_fraction_cat:=ifelse(policies_count$hr_fraction<0.01,"1. less than 1%",
ifelse(policies_count$hr_fraction<0.025,"2. 1% to 2.5%",
ifelse(policies_count$hr_fraction<0.1,"3. 2.5% to 10%",
ifelse(policies_count$hr_fraction<0.25,"4. 10% pct to 25%",
ifelse(policies_count$hr_fraction<0.5,"5. 25% to 50%","6. More than 50%")))))]
policies_count[,hr_lr:=policies_count$hr_policies/policies_count$total_policies]
policies_count[,lr_cost:=ifelse(policies_count$lr_cost==0,NA,policies_count$lr_cost)]
policies_count[,lr_cost_cat:=ifelse(policies_count$lr_cost<100,"1. less than $100",
ifelse(policies_count$lr_cost<200,"2. $100 to $200",
ifelse(policies_count$lr_cost<300,"3. $200 to $300","4. More than $300")))]
policies_count[,hr_cost:=ifelse(policies_count$hr_cost==0,NA,policies_count$hr_cost)]
policies_count[,hr_cost_cat:=ifelse(policies_count$hr_cost<200,"1. less than $200",
ifelse(policies_count$hr_cost<400,"2. $200 to $400",
ifelse(policies_count$hr_cost<600,"3. $400 to $600","4. More than $600")))]
policies_count[,crsdiscount_hr_cat:=ifelse(policies_count$crsdiscount_hr<=0,"1. 0",
ifelse(policies_count$crsdiscount_hr<0.05,"2. Less than 5%",
ifelse(policies_count$crsdiscount_hr<0.15,"3. 5% to 15%","4. More than 15%")))]
policies_count <- policies_count[policies_count$no_of_homes>0]
policies_count[,countycode:=substr(policies_count$censustract,1,5)]
policies_count[,white_frac:=policies_count$white_population/policies_count$total_population]
policies_count[,college_frac:=policies_count$college_degree_popu/policies_count$total_population]
policies_count[,state:=substr(policies_count$countycode,1,2)]
policies_count[,climate_cat:=as.factor(floor(policies_count$climatechangereal/10)*10)]
policies_count[,owner_frac:=policies_count$owner_occ_units/(policies_count$owner_occ_units+policies_count$renter_occ_units)]
policies_count[,post:=ifelse(policies_count$year>=2017,1,0)]
policies_count[,policies_fraction_pop:=policies_count$total_policies/policies_count$total_population]
policies_count[,fraction_no_health_insurance:=policies_count$no_health_insurance/(policies_count$no_health_insurance+policies_count$with_health_insurance)]
policies_count <- merge(policies_count,yale,by=c("countycode","year"),all.x=TRUE)
policies_count <- merge(policies_count,election,by=c("countycode"),all.x=TRUE)
policies_count <- merge(policies_count,disaster_dec,by=c("countycode","year"),all.x=TRUE)
policies_count[,disaster_1:=ifelse(is.na(policies_count$disaster_1),0,policies_count$disaster_1)]
disaster_dec$year <- disaster_dec$year+1
names(disaster_dec) <- c("year","countycode","disaster_2")
policies_count <- merge(policies_count,disaster_dec,by=c("countycode","year"),all.x=TRUE)
policies_count[,disaster_2:=ifelse(is.na(policies_count$disaster_2),0,policies_count$disaster_2)]
disaster_dec$year <- disaster_dec$year+1
names(disaster_dec) <- c("year","countycode","disaster_3")
policies_count <- merge(policies_count,disaster_dec,by=c("countycode","year"),all.x=TRUE)
policies_count[,disaster_3:=ifelse(is.na(policies_count$disaster_3),0,policies_count$disaster_3)]
house_price <- policies[,.(house_price=mean(zhvi,na.rm=TRUE)),by=.(censustract,effectiveyear)]
policies_count <- merge(policies_count,house_price,by.x=c("censustract","year"),by.y=c("censustract","effectiveyear"),all.x=TRUE)
sfhasummary <- policies[policies$floodzone_cat=="A",.(contentscovered=mean(contentscovered,na.rm=TRUE),sfha_a_count=.N,maxdeductible=mean(maxdeductible,na.rm=TRUE),maxdeductible5000=mean(maxdeductible5000,na.rm=TRUE)),by=.(censustract,effectiveyear)]
policies_count <- merge(policies_count,sfhasummary,by.x=c("censustract","year"),by.y=c("censustract","effectiveyear"),all.x=TRUE)
policies_count[,median_house_age:=policies_count$year-policies_count$median_year_structure_built]
policies_count[,climatechangereal:=policies_count$climatechangereal/100]
policies_count[,worriedaboutclimatechange:=policies_count$worriedaboutclimatechange/100]
policies_count[,climatechangeimpactpersonal:=policies_count$climatechangeimpactpersonal/100]
policies_count[,republican:=ifelse(policies_count$dem_pct_cnty<0.5,1,0)]
policies_count[,instrument:= policies_count$rep_gain*policies_count$post]
dep_takeup = "policies_fraction~"
dep_content = "contentscovered~"
dep_deductible = "maxdeductible5000~"
controls_nonsfha = "log(median_hh_income)+log(median_age)+log(white_frac)+log(college_frac)+log(total_population)+log(no_of_homes)+log(owner_frac)+log(lr_cost)+log(median_house_age)+log(house_price)+disaster_1+disaster_2+disaster_3"#
controls_sfha = "log(median_hh_income)+log(median_age)+log(white_frac)+log(college_frac)+log(total_population)+log(no_of_homes)+log(owner_frac)+log(hr_cost)+log(median_house_age)+log(house_price)+disaster_1+disaster_2+disaster_3"#
controls_sfha_content = "log(median_hh_income)+log(median_age)+log(white_frac)+log(college_frac)+log(total_population)+log(no_of_homes)+log(owner_frac)+contentprem+log(median_house_age)+log(house_price)+disaster_1+disaster_2+disaster_3"#
controls_sfha_deductible = "log(median_hh_income)+log(median_age)+log(white_frac)+log(college_frac)+log(total_population)+log(no_of_homes)+log(owner_frac)+deductibleprem+log(median_house_age)+log(house_price)+disaster_1+disaster_2+disaster_3"#
fixed_effects = "|censustract+year"
cluster = "|censustract"
endo_variable_1 = "log(climatechangereal)"
endo_variable_1_cat ="factor(climatechangereal_cat)"
endo_variable_2 = "log(worriedaboutclimatechange)"
endo_variable_2_cat ="factor(worriedaboutclimatechange_cat)"
endo_variable_3 = "log(climatechangeimpactpersonal)"
endo_variable_3_cat ="factor(climatechangeimpactpersonal_cat)"
instrument = "rep_gain*post"
time_period <- 2013:2019
nonsfha_sample <- policies_count[policies_count$median_hh_income>0 & policies_count$median_age>0 & policies_count$hr_fraction<0.05 & policies_count$white_frac>0 & policies_count$college_frac>0 & policies_count$censustract %in% unique(policies_count[policies_count$total_policies>30]$censustract) & policies_count$no_of_homes>100 ]
sfha_sample <- policies_count[policies_count$sfha_a_count>10 & policies_count$median_hh_income>0 & policies_count$median_age>0 & policies_count$white_frac>0 & policies_count$college_frac>0 ]
hr_cost_nocontent<-policies[policies$floodzone=="AE" & policies$contentscovered==0 & policies$totalbuildinginsurancecoverage==250000,.(hrcost_nocontent=mean(policyCost1dollarcov)),by=.(censustract,effectiveyear)]
hr_cost_content<-policies[policies$floodzone=="AE" & policies$contentscovered==1 & policies$totalbuildinginsurancecoverage==250000,.(hrcost_content=mean(policyCost1dollarcov)),by=.(censustract,effectiveyear)]
hr_cost <- merge(hr_cost_content,hr_cost_nocontent,by=c("censustract","effectiveyear"))
hr_cost[,contentprem:=hr_cost$hrcost_content-hr_cost$hrcost_nocontent]
hr_cost[,c("hrcost_content","hrcost_nocontent")]<-list(NULL)
rm(list=c("hr_cost_nocontent","hr_cost_content"))
sfha_sample <- merge(sfha_sample,hr_cost,by.x=c("censustract","year"),by.y=c("censustract","effectiveyear"),all.x=TRUE)
hr_cost_noded<-policies[policies$floodzone=="AE" & policies$maxdeductible5000==0 & policies$totalbuildinginsurancecoverage==250000,.(hrcost_nocontent=mean(policyCost1dollarcov)),by=.(censustract,effectiveyear)]
hr_cost_ded<-policies[policies$floodzone=="AE" & policies$maxdeductible5000==1 & policies$totalbuildinginsurancecoverage==250000,.(hrcost_content=mean(policyCost1dollarcov)),by=.(censustract,effectiveyear)]
hr_cost <- merge(hr_cost_ded,hr_cost_noded,by=c("censustract","effectiveyear"))
hr_cost[,deductibleprem:=hr_cost$hrcost_nocontent-hr_cost$hrcost_content]
hr_cost[,c("hrcost_content","hrcost_nocontent")]<-list(NULL)
rm(list=c("hr_cost_ded","hr_cost_noded"))
sfha_sample <- merge(sfha_sample,hr_cost,by.x=c("censustract","year"),by.y=c("censustract","effectiveyear"),all.x=TRUE)
us_state <- 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_state <- fortify(us_state,region="STATEFP")
us_state <- us_state[!us_state$id %in% c("02","15","72","60","03","81","07","64","14","84","86","67","89","71","76","95","69","70","43","74","52","78","79"),]
tracts <- readOGR("C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/Shapefiles/US Censustracts","tracts_complete")
## OGR data source with driver: ESRI Shapefile
## Source: "C:\Users\dratnadiwakara2\Documents\OneDrive - Louisiana State University\Raw Data\Shapefiles\US Censustracts", layer: "tracts_complete"
## with 73682 features
## It has 52 fields
## Integer64 fields read as strings: OBJECTID POPULATION POP2010 WHITE BLACK AMERI_ES ASIAN HAWN_PI HISPANIC OTHER MULT_RACE MALES FEMALES AGE_UNDER5 AGE_5_9 AGE_10_14 AGE_15_19 AGE_20_24 AGE_25_34 AGE_35_44 AGE_45_54 AGE_55_64 AGE_65_74 AGE_75_84 AGE_85_UP HOUSEHOLDS HSEHLD_1_M HSEHLD_1_F MARHH_CHD MARHH_NO_C MHH_CHILD FHH_CHILD FAMILIES HSE_UNITS VACANT OWNER_OCC RENTER_OCC
tracts@data$GEOID <- paste(tracts$STATE_FIPS,tracts$CNTY_FIPS,tracts$TRACT,sep="")
tracts <- fortify(tracts,region="GEOID")
tracts <- tracts[!substr(tracts$id,1,2) %in% c("02","15","72","60","03","81","07","64","14","84","86","67","89","71","76","95","69","70","43","74","52","78","79"),]
tracts['nonsfhasample'] <- ifelse(tracts$id %in% unique(nonsfha_sample$censustract),1,0)
tracts['sfhasample'] <- ifelse(tracts$id %in% unique(sfha_sample$censustract),1,0)
t <- data.frame(tracts[,"id"],stringsAsFactors = FALSE)
names(t) <- "censustract"
t$censustract <- substr(t$censustract,1,11)
t <- data.table(t)
t2 <- merge(t,nonsfha_sample[nonsfha_sample$year==2016,c("censustract","policies_fraction")],by="censustract",all.x=TRUE)
t2 <- merge(t2,sfha_sample[sfha_sample$year==2016,c("censustract","contentscovered","maxdeductible5000")],by="censustract",all.x=TRUE)
t2[,policies_fraction_cat:=ifelse(t2$policies_fraction<0.01,"1 Less than 1%",ifelse(t2$policies_fraction<0.03,"2 1% to 3%","3 More than 3%"))]
t2[,content_cat:=ifelse(t2$contentscovered<0.25,"1 Less than 25%",ifelse(t2$contentscovered<0.5,"2 25% to 50%","3 More than 50%"))]
t2[,deductible_cat:=ifelse(t2$maxdeductible5000<0.25,"1 Less than 25%",ifelse(t2$maxdeductible5000<0.5,"2 25% to 50%","3 More than 50%"))]
tracts <- cbind(tracts,t2)
col_list <- c("gray70","gray30","gray10")
gr <- ggplot()+
geom_polygon(data = tracts[tracts$nonsfhasample==1,],aes(x = long, y = lat, group = group,fill=factor(policies_fraction_cat)),color=NA)+
geom_polygon(data = us_state,aes(x = long, y = lat, group = group),color="black",fill=NA)+
theme_minimal()+
theme(legend.position = "bottom",panel.grid = element_blank(),axis.text = element_blank(),legend.title = element_blank())+
xlab("")+
ylab("")+
scale_color_manual(values = col_list) +
scale_fill_manual(values = col_list) +
ggtitle("Fraction of homes with flood insurance (Non-SFHA Censustracts)")
gr
gr <- ggplot()+
geom_polygon(data = tracts[tracts$sfhasample==1,],aes(x = long, y = lat, group = group,fill=factor(content_cat)),color=NA)+
geom_polygon(data = us_state,aes(x = long, y = lat, group = group),color="black",fill=NA)+
theme_minimal()+
theme(legend.position = "bottom",panel.grid = element_blank(),axis.text = element_blank(),legend.title = element_blank())+
xlab("")+
ylab("")+
scale_color_manual(values = col_list) +
scale_fill_manual(values = col_list) +
ggtitle("Fraction of SFHA Policies with Contents Coverage")
gr
gr <- ggplot()+
geom_polygon(data = tracts[tracts$sfhasample==1,],aes(x = long, y = lat, group = group,fill=factor(deductible_cat)),color=NA)+
geom_polygon(data = us_state,aes(x = long, y = lat, group = group),color="black",fill=NA)+
theme_minimal()+
theme(legend.position = "bottom",panel.grid = element_blank(),axis.text = element_blank(),legend.title = element_blank())+
xlab("")+
ylab("")+
scale_color_manual(values = col_list) +
scale_fill_manual(values = col_list) +
ggtitle("Fraction of SFHA Policies with Maximum Deductible")
gr
stargazer(nonsfha_sample[nonsfha_sample$year==2016, c("policies_fraction","policies_fraction_pop","climatechangereal","worriedaboutclimatechange","climatechangeimpactpersonal","rep_gain","median_hh_income","median_age","white_frac","college_frac","total_population","no_of_homes","owner_frac","lr_cost","median_house_age","house_price")], type = "text", summary.stat = c("mean", "sd","p25","median","p75","n"),notes = "",digits = 4)
##
## ===================================================================================================
## Statistic Mean St. Dev. Pctl(25) Median Pctl(75) N
## ---------------------------------------------------------------------------------------------------
## policies_fraction 0.0446 0.0622 0.0162 0.0264 0.0467 16,735
## policies_fraction_pop 0.0203 0.0306 0.0069 0.0116 0.0208 16,735
## climatechangereal 0.6962 0.0581 0.6548 0.6976 0.7417 16,735
## worriedaboutclimatechange 0.5737 0.0677 0.5229 0.5744 0.6250 16,735
## climatechangeimpactpersonal 0.3971 0.0526 0.3552 0.3892 0.4382 16,735
## rep_gain -0.0315 0.1257 -0.1213 -0.0273 0.0502 16,709
## median_hh_income 76,102.1500 35,205.3100 51,957.5 67,108 91,174 16,735
## median_age 40.6639 7.8075 35.3000 40.4000 45.2000 16,735
## white_frac 0.7746 0.2113 0.6937 0.8431 0.9295 16,735
## college_frac 0.2022 0.0563 0.1655 0.2042 0.2398 16,735
## total_population 5,212.9160 2,588.4100 3,570 4,801 6,334 16,735
## no_of_homes 2,242.0080 999.3207 1,597.5 2,097 2,702 16,735
## owner_frac 0.6768 0.1909 0.5633 0.7169 0.8236 16,735
## lr_cost 230.7317 189.5796 139.4286 181.9048 232.2500 16,671
## median_house_age 53.1115 165.4379 28 38 50 16,735
## house_price 270,985.5000 379,706.7000 122,354.0000 176,270.0000 285,151.6000 13,907
## ---------------------------------------------------------------------------------------------------
##
stargazer(sfha_sample[sfha_sample$year==2016, c("policies_fraction","policies_fraction_pop","climatechangereal","worriedaboutclimatechange","climatechangeimpactpersonal","hr_cost","median_hh_income","house_price","total_population","no_of_homes","median_house_age","median_age","white_frac","college_frac","owner_frac","contentscovered","maxdeductible5000")], type = "text", summary.stat = c("mean", "sd","p25","median","p75","n"),notes = "",digits = 4)
##
## ===================================================================================================
## Statistic Mean St. Dev. Pctl(25) Median Pctl(75) N
## ---------------------------------------------------------------------------------------------------
## policies_fraction 0.0969 0.1500 0.0174 0.0350 0.0999 18,642
## policies_fraction_pop 0.0525 0.1751 0.0076 0.0155 0.0447 18,642
## climatechangereal 0.6915 0.0597 0.6472 0.6928 0.7357 18,642
## worriedaboutclimatechange 0.5684 0.0686 0.5166 0.5609 0.6213 18,642
## climatechangeimpactpersonal 0.3922 0.0529 0.3497 0.3817 0.4270 18,642
## hr_cost 867.3781 592.3778 384.3348 885.6000 1,240.0000 18,642
## median_hh_income 69,870.0600 29,901.2100 50,091.5 63,064 82,430.5 18,642
## house_price 243,952.9000 343,146.2000 116,342.9000 164,115.1000 256,340.6000 15,007
## total_population 4,767.8330 2,386.1510 3,208.2 4,442 5,919 18,642
## no_of_homes 2,118.1280 983.2881 1,479.2 1,985 2,584.8 18,642
## median_house_age 48.4091 119.1528 30 40 51 18,642
## median_age 40.9458 8.0128 35.5000 40.7000 45.4000 18,642
## white_frac 0.7814 0.2215 0.6994 0.8611 0.9424 18,642
## college_frac 0.2032 0.0547 0.1676 0.2045 0.2393 18,642
## owner_frac 0.6660 0.1924 0.5515 0.7080 0.8135 18,642
## contentscovered 0.3811 0.2352 0.1860 0.3445 0.5551 18,642
## maxdeductible5000 0.3370 0.2037 0.1749 0.3077 0.4737 18,642
## ---------------------------------------------------------------------------------------------------
##
endo = endo_variable_1_cat
regs <- list()
regs[[1]] <- felm(as.formula(paste(dep_takeup,endo,fixed_effects,"|0",cluster,sep="")),data=nonsfha_sample[nonsfha_sample$year %in% time_period])
regs[[2]] <- felm(as.formula(paste(dep_takeup,endo,"+",controls_nonsfha,fixed_effects,"|0",cluster,sep="")),data=nonsfha_sample[nonsfha_sample$year %in% time_period])
regs[[3]] <- felm(as.formula(paste(dep_content,endo,fixed_effects,"|0",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
regs[[4]] <- felm(as.formula(paste(dep_content,endo,"+",controls_sfha,fixed_effects,"|0",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
regs[[5]] <- felm(as.formula(paste(dep_deductible,endo,fixed_effects,"|0",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
regs[[6]] <- felm(as.formula(paste(dep_deductible,endo,"+",controls_sfha,fixed_effects,"|0",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
.printtable(regs,lines = list(c("Fixed Effects","Tract, Year","Tract, Year","Tract, Year","Tract, Year","Tract, Year","Tract, Year")))
##
## =======================================================================================================
## Dependent variable:
## -----------------------------------------------------------------------
## (1) (2) (3) (4) (5) (6)
## -------------------------------------------------------------------------------------------------------
## factor(climatechangereal_cat)50 0.002** 0.001 0.010 0.008 0.003 -0.004
## (0.001) (0.001) (0.007) (0.008) (0.007) (0.009)
## factor(climatechangereal_cat)55 0.002** 0.001 0.014* 0.010 0.002 -0.005
## (0.001) (0.001) (0.007) (0.008) (0.007) (0.009)
## factor(climatechangereal_cat)60 0.003*** 0.003** 0.020*** 0.015* 0.003 -0.004
## (0.001) (0.001) (0.007) (0.008) (0.007) (0.009)
## factor(climatechangereal_cat)65 0.003*** 0.001 0.024*** 0.018** 0.0004 -0.007
## (0.001) (0.001) (0.007) (0.008) (0.007) (0.009)
## factor(climatechangereal_cat)70 0.004*** 0.001 0.022*** 0.016* 0.0004 -0.009
## (0.001) (0.001) (0.008) (0.008) (0.008) (0.009)
## factor(climatechangereal_cat)75 0.005*** 0.003** 0.029*** 0.026*** -0.002 -0.013
## (0.001) (0.001) (0.008) (0.009) (0.008) (0.010)
## factor(climatechangereal_cat)80 0.008*** 0.005*** 0.032*** 0.029*** 0.007 -0.004
## (0.001) (0.001) (0.009) (0.009) (0.009) (0.010)
## log(median_hh_income) -0.001 -0.003 0.015***
## (0.001) (0.004) (0.004)
## log(median_age) 0.00001 -0.009 -0.008
## (0.002) (0.008) (0.009)
## log(white_frac) 0.0002 -0.006 0.008*
## (0.001) (0.005) (0.005)
## log(college_frac) -0.001 -0.0005 -0.001
## (0.001) (0.004) (0.004)
## log(total_population) 0.006*** -0.013 -0.024***
## (0.002) (0.008) (0.008)
## log(no_of_homes) -0.017*** 0.050*** -0.0004
## (0.004) (0.012) (0.012)
## log(owner_frac) 0.002** 0.010* -0.003
## (0.001) (0.006) (0.006)
## log(lr_cost) 0.0001
## (0.0003)
## log(hr_cost) -0.052*** 0.009***
## (0.004) (0.004)
## log(median_house_age) -0.0004** -0.003** 0.003***
## (0.0002) (0.001) (0.001)
## log(house_price) -0.006*** -0.040*** 0.008*
## (0.001) (0.005) (0.004)
## disaster_1 0.002*** 0.005*** -0.002***
## (0.0001) (0.001) (0.001)
## disaster_2 0.002*** 0.005*** -0.001*
## (0.0002) (0.001) (0.001)
## disaster_3 0.003*** 0.004*** -0.002**
## (0.0002) (0.001) (0.001)
## -------------------------------------------------------------------------------------------------------
## Fixed Effects Tract, Year Tract, Year Tract, Year Tract, Year Tract, Year Tract, Year
## Observations 116,986 100,422 128,153 107,139 128,153 107,139
## Adjusted R2 0.973 0.974 0.926 0.931 0.886 0.892
## =======================================================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
gr <-list()
gr[[1]]<-.coef_plot_1reg(regs[[1]],endo,45)+ylab(expression(beta[z]))+ggtitle("NonSFHA Takeup")
gr[[2]]<-.coef_plot_1reg(regs[[3]],endo,45)+ylab(expression(beta[z]))+ggtitle("SFHA Content Coverage")
gr[[3]]<-.coef_plot_1reg(regs[[5]],endo,45)+ylab(expression(beta[z]))+ggtitle("SFHA Max Deductible")
grid.arrange(gr[[1]],gr[[2]],gr[[3]],nrow=2)
us_state <- 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_state <- fortify(us_state,region="STATEFP")
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
counties <- fortify(counties,region="GEOID")
t <- data.frame(counties[,"id"],stringsAsFactors = FALSE)
names(t) <- "countycode"
t2 <- merge(t,yale[yale$year==2016],by="countycode",all.x=TRUE)
counties <- cbind(counties,t2)
col_list <- c("gray90","gray85","gray80","gray75","gray60","gray50","gray40","gray20","gray10")
gr <- ggplot()+
geom_polygon(data = counties[!substr(counties$id,1,2) %in% c("02","15","72"),],aes(x = long, y = lat, group = group,fill=factor(climatechangereal_cat)),color="gray20")+
geom_polygon(data = us_state[!us_state$id %in% c("02","15","72"),],aes(x = long, y = lat, group = group),color="black",fill=NA)+
# scale_color_manual(values=c("bisque3","midnightblue"))+
# scale_fill_manual(values=c("bisque3","midnightblue"))+
theme_minimal()+
theme(legend.position = "bottom",panel.grid = element_blank(),axis.text = element_blank(),legend.title = element_blank())+
xlab("")+
ylab("")+
scale_color_manual(values = col_list,na.value="white") +
scale_fill_manual(values = col_list,na.value="white")
# ggtitle("Fraction of homes with A and V policies")
gr
us_state <- 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_state <- fortify(us_state,region="STATEFP")
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
counties <- fortify(counties,region="GEOID")
t <- data.frame(counties[,"id"],stringsAsFactors = FALSE)
names(t) <- "countycode"
t2 <- merge(t,election,by="countycode",all.x=TRUE)
counties <- cbind(counties,t2)
counties['rep_gain_cat'] <-ifelse(counties$rep_gain<(-0.20),"1. less than -20%",
ifelse(counties$rep_gain<0.0,"2. 0% to -20%",
ifelse(counties$rep_gain<0.1,"3. 0% to 10%",
ifelse(counties$rep_gain<0.2,"5. 10% to 20%","6. More than 20%"))))
col_list <- c("blue4","royalblue1","hotpink3","red1","darkred")
gr <- ggplot()+
geom_polygon(data = counties[!substr(counties$id,1,2) %in% c("02","15","72"),],aes(x = long, y = lat, group = group,fill=factor(rep_gain_cat)),color="gray20")+
geom_polygon(data = us_state[!us_state$id %in% c("02","15","72"),],aes(x = long, y = lat, group = group),color="black",fill=NA)+
# scale_color_manual(values=c("bisque3","midnightblue"))+
# scale_fill_manual(values=c("bisque3","midnightblue"))+
theme_minimal()+
theme(legend.position = "bottom",panel.grid = element_blank(),axis.text = element_blank(),legend.title = element_blank())+
xlab("")+
ylab("")+
scale_color_manual(values = col_list,na.value="white") +
scale_fill_manual(values = col_list,na.value="white")
# ggtitle("Fraction of homes with A and V policies")
gr
regs <- list()
regs[[1]] <- felm(as.formula(paste(endo_variable_1,"~",instrument,fixed_effects,"|0",cluster,sep="")),data=nonsfha_sample[nonsfha_sample$year %in% time_period])
regs[[2]] <- felm(as.formula(paste(endo_variable_1,"~",instrument,"+",controls_nonsfha,fixed_effects,"|0",cluster,sep="")),data=nonsfha_sample[nonsfha_sample$year %in% time_period])
regs[[3]] <- felm(as.formula(paste(endo_variable_2,"~",instrument,"+",controls_nonsfha,fixed_effects,"|0",cluster,sep="")),data=nonsfha_sample[nonsfha_sample$year %in% time_period])
regs[[4]] <- felm(as.formula(paste(endo_variable_3,"~",instrument,"+",controls_nonsfha,fixed_effects,"|0",cluster,sep="")),data=nonsfha_sample[nonsfha_sample$year %in% time_period])
.printtable(regs,lines = list(c("Fixed Effects","Tract, Year","Tract, Year","Tract, Year","Tract, Year")))
##
## =====================================================================
## Dependent variable:
## -----------------------------------------------
## (1) (2) (3) (4)
## ---------------------------------------------------------------------
## rep_gain
## (0.000) (0.000) (0.000) (0.000)
## post
## (0.000) (0.000) (0.000) (0.000)
## log(median_hh_income) -0.003** -0.006*** -0.004**
## (0.001) (0.002) (0.002)
## log(median_age) -0.0003 -0.001 -0.005
## (0.003) (0.004) (0.004)
## log(white_frac) -0.001 -0.003 -0.001
## (0.002) (0.002) (0.002)
## log(college_frac) -0.002 -0.003* -0.003*
## (0.001) (0.002) (0.002)
## log(total_population) 0.002 0.0003 -0.010**
## (0.003) (0.004) (0.004)
## log(no_of_homes) -0.0003 0.007 -0.009*
## (0.004) (0.006) (0.005)
## log(owner_frac) -0.010*** -0.012*** -0.003
## (0.002) (0.003) (0.003)
## log(lr_cost) -0.001 -0.0003 0.0001
## (0.001) (0.001) (0.001)
## log(median_house_age) 0.0001 -0.00000 0.0002
## (0.0002) (0.0003) (0.0003)
## log(house_price) -0.016*** -0.028*** -0.026***
## (0.002) (0.002) (0.002)
## disaster_1 0.003*** 0.001*** 0.001***
## (0.0002) (0.0003) (0.0003)
## disaster_2 0.004*** 0.001*** 0.001***
## (0.0002) (0.0003) (0.0003)
## disaster_3 0.001*** -0.001** -0.004***
## (0.0003) (0.0003) (0.0003)
## rep_gain:post -0.072*** -0.067*** -0.064*** -0.077***
## (0.002) (0.002) (0.002) (0.003)
## ---------------------------------------------------------------------
## Fixed Effects Tract, Year Tract, Year Tract, Year Tract, Year
## Observations 116,802 100,265 100,265 100,265
## Adjusted R2 0.951 0.952 0.953 0.974
## =====================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
regs <- list()
regs[[1]] <- felm(as.formula(paste(endo_variable_1,"~",instrument,fixed_effects,"|0",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
regs[[2]] <- felm(as.formula(paste(endo_variable_1,"~",instrument,"+",controls_sfha,fixed_effects,"|0",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
regs[[3]] <- felm(as.formula(paste(endo_variable_2,"~",instrument,"+",controls_sfha,fixed_effects,"|0",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
regs[[4]] <- felm(as.formula(paste(endo_variable_3,"~",instrument,"+",controls_sfha,fixed_effects,"|0",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
.printtable(regs,lines = list(c("Fixed Effects","Tract, Year","Tract, Year","Tract, Year","Tract, Year")))
##
## =====================================================================
## Dependent variable:
## -----------------------------------------------
## (1) (2) (3) (4)
## ---------------------------------------------------------------------
## rep_gain
## (0.000) (0.000) (0.000) (0.000)
## post
## (0.000) (0.000) (0.000) (0.000)
## log(median_hh_income) -0.002 -0.003** -0.003**
## (0.001) (0.002) (0.002)
## log(median_age) -0.007** -0.009** -0.005
## (0.003) (0.004) (0.004)
## log(white_frac) -0.004** -0.006*** -0.005***
## (0.002) (0.002) (0.002)
## log(college_frac) -0.003** -0.003** -0.001
## (0.001) (0.002) (0.001)
## log(total_population) -0.003 -0.008** -0.012***
## (0.003) (0.004) (0.003)
## log(no_of_homes) -0.006 0.003 -0.010*
## (0.004) (0.005) (0.005)
## log(owner_frac) -0.008*** -0.011*** -0.007***
## (0.002) (0.002) (0.002)
## log(hr_cost) -0.0003 0.002*** -0.001
## (0.001) (0.001) (0.001)
## log(median_house_age) 0.0003 -0.00001 0.0002
## (0.0003) (0.0003) (0.0003)
## log(house_price) -0.013*** -0.020*** -0.012***
## (0.002) (0.002) (0.002)
## disaster_1 0.003*** 0.003*** 0.002***
## (0.0002) (0.0003) (0.0003)
## disaster_2 0.004*** 0.002*** 0.001**
## (0.0003) (0.0003) (0.0003)
## disaster_3 0.0003 -0.001*** -0.004***
## (0.0003) (0.0003) (0.0003)
## rep_gain:post -0.084*** -0.081*** -0.080*** -0.083***
## (0.002) (0.002) (0.003) (0.003)
## ---------------------------------------------------------------------
## Fixed Effects Tract, Year Tract, Year Tract, Year Tract, Year
## Observations 127,891 106,925 106,925 106,925
## Adjusted R2 0.950 0.952 0.953 0.975
## =====================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
regs <- list()
regs[[1]] <- felm(as.formula(paste(dep_takeup,"0",fixed_effects,"|(",endo_variable_1,"~",instrument,")",cluster,sep="")),data=nonsfha_sample[nonsfha_sample$year %in% time_period])
regs[[2]] <- felm(as.formula(paste(dep_takeup,controls_nonsfha,fixed_effects,"|(",endo_variable_1,"~",instrument,")",cluster,sep="")),data=nonsfha_sample[nonsfha_sample$year %in% time_period])
regs[[3]] <- felm(as.formula(paste(dep_takeup,controls_nonsfha,fixed_effects,"|(",endo_variable_2,"~",instrument,")",cluster,sep="")),data=nonsfha_sample[nonsfha_sample$year %in% time_period])
regs[[4]] <- felm(as.formula(paste(dep_takeup,controls_nonsfha,fixed_effects,"|(",endo_variable_3,"~",instrument,")",cluster,sep="")),data=nonsfha_sample[nonsfha_sample$year %in% time_period])
.printtable(regs,lines = list(c("Fixed Effects","Tract, Year","Tract, Year","Tract, Year","Tract, Year"),c("Cond. F. Stat",round(condfstat(regs[[1]])[1],2),round(condfstat(regs[[2]])[1],2),round(condfstat(regs[[3]])[1],2),round(condfstat(regs[[4]])[1],2))))
##
## =======================================================================================
## Dependent variable:
## -----------------------------------------------
## (1) (2) (3) (4)
## ---------------------------------------------------------------------------------------
## log(median_hh_income) -0.0002 0.0004 -0.0002
## (0.001) (0.001) (0.001)
## log(median_age) -0.0004 -0.0003 0.0004
## (0.002) (0.002) (0.002)
## log(white_frac) 0.001 0.001 0.001
## (0.001) (0.001) (0.001)
## log(college_frac) -0.0002 -0.00003 -0.0001
## (0.001) (0.001) (0.001)
## log(total_population) 0.004** 0.005** 0.006***
## (0.002) (0.002) (0.002)
## log(no_of_homes) -0.018*** -0.019*** -0.016***
## (0.004) (0.004) (0.004)
## log(owner_frac) 0.004*** 0.005*** 0.003**
## (0.001) (0.001) (0.001)
## log(lr_cost) 0.0003 0.0002 0.0002
## (0.0003) (0.0003) (0.0003)
## log(median_house_age) -0.0004** -0.0004** -0.0004**
## (0.0002) (0.0002) (0.0002)
## log(house_price) -0.004*** -0.002* -0.003***
## (0.001) (0.001) (0.001)
## disaster_1 0.001*** 0.001*** 0.001***
## (0.0001) (0.0001) (0.0001)
## disaster_2 0.001*** 0.002*** 0.002***
## (0.0002) (0.0002) (0.0002)
## disaster_3 0.002*** 0.003*** 0.003***
## (0.0002) (0.0002) (0.0002)
## `log(climatechangereal)(fit)` 0.184*** 0.177***
## (0.012) (0.014)
## `log(worriedaboutclimatechange)(fit)` 0.186***
## (0.015)
## `log(climatechangeimpactpersonal)(fit)` 0.155***
## (0.013)
## ---------------------------------------------------------------------------------------
## Fixed Effects Tract, Year Tract, Year Tract, Year Tract, Year
## Cond. F. Stat 512.62 67.71 41.54 50.72
## Observations 116,802 100,265 100,265 100,265
## Adjusted R2 0.969 0.971 0.969 0.971
## =======================================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
regs <- list()
regs[[1]] <- felm(as.formula(paste(dep_content,"0",fixed_effects,"|(",endo_variable_1,"~",instrument,")",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
regs[[2]] <- felm(as.formula(paste(dep_content,controls_sfha,fixed_effects,"|(",endo_variable_1,"~",instrument,")",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
regs[[3]] <- felm(as.formula(paste(dep_content,controls_sfha,fixed_effects,"|(",endo_variable_2,"~",instrument,")",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
regs[[4]] <- felm(as.formula(paste(dep_content,controls_sfha,fixed_effects,"|(",endo_variable_3,"~",instrument,")",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
.printtable(regs,lines = list(c("Fixed Effects","Tract, Year","Tract, Year","Tract, Year","Tract, Year"),c("Cond. F. Stat",round(condfstat(regs[[1]])[1],2),round(condfstat(regs[[2]])[1],2),round(condfstat(regs[[3]])[1],2),round(condfstat(regs[[4]])[1],2))))
##
## =======================================================================================
## Dependent variable:
## -----------------------------------------------
## (1) (2) (3) (4)
## ---------------------------------------------------------------------------------------
## log(median_hh_income) -0.003 -0.001 -0.001
## (0.004) (0.004) (0.004)
## log(median_age) -0.005 -0.004 -0.008
## (0.009) (0.009) (0.009)
## log(white_frac) -0.002 -0.0003 -0.001
## (0.005) (0.005) (0.005)
## log(college_frac) 0.003 0.004 0.002
## (0.004) (0.004) (0.004)
## log(total_population) -0.016* -0.011 -0.008
## (0.009) (0.009) (0.009)
## log(no_of_homes) 0.054*** 0.046*** 0.058***
## (0.013) (0.013) (0.013)
## log(owner_frac) 0.017*** 0.019*** 0.016**
## (0.007) (0.007) (0.007)
## log(hr_cost) -0.051*** -0.053*** -0.050***
## (0.004) (0.004) (0.004)
## log(median_house_age) -0.003** -0.002** -0.003**
## (0.001) (0.001) (0.001)
## log(house_price) -0.038*** -0.031*** -0.039***
## (0.005) (0.005) (0.005)
## disaster_1 0.001 0.002** 0.003***
## (0.001) (0.001) (0.001)
## disaster_2 0.001 0.002*** 0.003***
## (0.001) (0.001) (0.001)
## disaster_3 0.003*** 0.005*** 0.007***
## (0.001) (0.001) (0.001)
## `log(climatechangereal)(fit)` 0.696*** 0.889***
## (0.074) (0.087)
## `log(worriedaboutclimatechange)(fit)` 0.895***
## (0.089)
## `log(climatechangeimpactpersonal)(fit)` 0.869***
## (0.087)
## ---------------------------------------------------------------------------------------
## Fixed Effects Tract, Year Tract, Year Tract, Year Tract, Year
## Cond. F. Stat 657.81 89.08 62.06 59.81
## Observations 127,891 106,925 106,925 106,925
## Adjusted R2 0.922 0.924 0.921 0.924
## =======================================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
regs <- list()
regs[[1]] <- felm(as.formula(paste(dep_deductible,"0",fixed_effects,"|(",endo_variable_1,"~",instrument,")",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
regs[[2]] <- felm(as.formula(paste(dep_deductible,controls_sfha,fixed_effects,"|(",endo_variable_1,"~",instrument,")",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
regs[[3]] <- felm(as.formula(paste(dep_deductible,controls_sfha,fixed_effects,"|(",endo_variable_2,"~",instrument,")",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
regs[[4]] <- felm(as.formula(paste(dep_deductible,controls_sfha,fixed_effects,"|(",endo_variable_3,"~",instrument,")",cluster,sep="")),data=sfha_sample[sfha_sample$year %in% time_period])
.printtable(regs,lines = list(c("Fixed Effects","Tract, Year","Tract, Year","Tract, Year","Tract, Year"),c("Cond. F. Stat",round(condfstat(regs[[1]])[1],2),round(condfstat(regs[[2]])[1],2),round(condfstat(regs[[3]])[1],2),round(condfstat(regs[[4]])[1],2))))
##
## =======================================================================================
## Dependent variable:
## -----------------------------------------------
## (1) (2) (3) (4)
## ---------------------------------------------------------------------------------------
## log(median_hh_income) 0.015*** 0.014*** 0.014***
## (0.004) (0.004) (0.004)
## log(median_age) -0.010 -0.010 -0.009
## (0.009) (0.009) (0.009)
## log(white_frac) 0.007 0.006 0.006
## (0.005) (0.005) (0.005)
## log(college_frac) -0.003 -0.003 -0.003
## (0.004) (0.004) (0.004)
## log(total_population) -0.023*** -0.024*** -0.026***
## (0.008) (0.008) (0.008)
## log(no_of_homes) -0.002 0.001 -0.003
## (0.012) (0.012) (0.012)
## log(owner_frac) -0.005 -0.006 -0.005
## (0.007) (0.007) (0.007)
## log(hr_cost) 0.008** 0.010*** 0.008**
## (0.004) (0.004) (0.004)
## log(median_house_age) 0.003*** 0.003*** 0.003***
## (0.001) (0.001) (0.001)
## log(house_price) 0.006 0.003 0.006
## (0.004) (0.005) (0.004)
## disaster_1 -0.001 -0.001 -0.001*
## (0.001) (0.001) (0.001)
## disaster_2 0.0003 -0.0003 -0.001
## (0.001) (0.001) (0.001)
## disaster_3 -0.001 -0.002** -0.003***
## (0.001) (0.001) (0.001)
## `log(climatechangereal)(fit)` -0.238*** -0.373***
## (0.077) (0.088)
## `log(worriedaboutclimatechange)(fit)` -0.376***
## (0.088)
## `log(climatechangeimpactpersonal)(fit)` -0.365***
## (0.086)
## ---------------------------------------------------------------------------------------
## Fixed Effects Tract, Year Tract, Year Tract, Year Tract, Year
## Cond. F. Stat 657.81 89.08 62.06 59.81
## Observations 127,891 106,925 106,925 106,925
## Adjusted R2 0.885 0.890 0.889 0.890
## =======================================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
Using proprietary ZTRAX Data, public voter regustration data, and NFIP data
‘voterdata.fst’ is available here
Script used to create ‘voterdata.fst’ is available here
voterdata <- read_fst(paste0("C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/ZTRAX NFIP Match/voterdata.fst"),as.data.table = TRUE)
voterdata <- voterdata[voterdata$effectiveyear %in% 2015:2016]
controls = "republican+white+basefloodelevation+log(age)+log(house_age)+log(totalbuildinginsurancecoverage)+log(housevalue)+log(timesincepurchase)+primaryresidenceindicator+I(occupancytype==1)+postfirmconstructionindicator+log(noofstories)+elevationdifference+log(policyCost1dollarcov)+log(1+lotsizesquarefeet)+totalbedrooms|ct_zone+effectiveyear|0|ct_zone"
regs <- list()
regs[[1]] <- felm(as.formula(paste0("maxdeductible~",controls)),
data=voterdata)
regs[[2]] <- felm(as.formula(paste0("log(1+buildingdeductible)~",controls)),
data=voterdata)
regs[[3]] <- felm(as.formula(paste0("contentscovered~",controls)),
data=voterdata)
regs[[4]] <- felm(as.formula(paste0("log(1+totalcontentsinsurancecoverage)~",controls)),
data=voterdata)
.printtable(regs)
##
## ===========================================================================
## Dependent variable:
## ---------------------------------------
## (1) (2) (3) (4)
## ---------------------------------------------------------------------------
## republican 0.019** 0.019 -0.024** -0.274**
## (0.009) (0.014) (0.010) (0.106)
## white -0.007 -0.018 0.004 0.090
## (0.014) (0.020) (0.015) (0.171)
## basefloodelevation -0.003** -0.004** 0.002 0.020
## (0.001) (0.002) (0.002) (0.018)
## log(age) -0.021 -0.042 0.047** 0.552**
## (0.019) (0.027) (0.023) (0.244)
## log(house_age) 0.016 0.036* -0.010 -0.226
## (0.014) (0.020) (0.014) (0.153)
## log(totalbuildinginsurancecoverage) 0.035* 0.146*** -0.037* -0.012
## (0.019) (0.028) (0.020) (0.208)
## log(housevalue) -0.009 -0.006 0.039*** 0.524***
## (0.011) (0.015) (0.010) (0.110)
## log(timesincepurchase) -0.049*** -0.096*** 0.027*** 0.321***
## (0.004) (0.006) (0.004) (0.049)
## primaryresidenceindicator -0.001 0.011 0.015 0.252*
## (0.012) (0.015) (0.013) (0.144)
## I(occupancytype == 1) 0.027 0.046 0.022 0.098
## (0.035) (0.052) (0.048) (0.528)
## postfirmconstructionindicator -0.061*** -0.114*** 0.032* 0.250
## (0.020) (0.027) (0.019) (0.208)
## log(noofstories) 0.025 0.033 -0.010 -0.079
## (0.019) (0.027) (0.018) (0.199)
## elevationdifference 0.0001 0.0002 -0.00002 -0.0003
## (0.0001) (0.0001) (0.0001) (0.001)
## log(policyCost1dollarcov) 0.067*** 0.121*** -0.130*** -1.561***
## (0.015) (0.021) (0.015) (0.160)
## log(1 + lotsizesquarefeet) 0.005 0.010 -0.003 0.002
## (0.009) (0.012) (0.008) (0.089)
## totalbedrooms 0.002 -0.003 -0.004 -0.054
## (0.006) (0.008) (0.006) (0.063)
## ---------------------------------------------------------------------------
##
## Observations 11,013 11,013 11,013 11,013
## Adjusted R2 0.198 0.253 0.207 0.240
## ===========================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
col_list <- c("gray60","gray10")
dep_vars <- c(dep_takeup,"log(median_hh_income)~","log(lr_cost)~","fraction_no_health_insurance~")
gr <- list()
i = 1
for(dv in dep_vars) {
formula <- as.formula(paste(dv,"factor(year)|censustract|0|censustract",sep=""))
regs <- list()
regs[[1]] <- felm(formula,data=nonsfha_sample[nonsfha_sample$rep_gain>0 & nonsfha_sample$year>=2009])
regs[[2]] <- felm(formula,data=nonsfha_sample[nonsfha_sample$rep_gain<0 & nonsfha_sample$year>=2009])
# .printtable(regs)
gr[[i]] <- .coef_plot_2reg(regs[[1]],"Increased Republican voter share in 2016",regs[[2]],"Decreased Republican voter share in 2016","factor(year)",2012)+ggtitle(dv)+scale_fill_manual(values = col_list,na.value="white")+scale_color_manual(values = col_list,na.value="white")
gr[[i]]
i=i+1
}
col_list <- c("gray60","gray10")
dep_vars <- c(dep_content,dep_deductible,"log(median_hh_income)~","log(hr_cost)~","fraction_no_health_insurance~")
gr <- list()
i = 1
for(dv in dep_vars) {
formula <- as.formula(paste(dv,"factor(year)|censustract|0|censustract",sep=""))
regs <- list()
regs[[1]] <- felm(formula,data=sfha_sample[sfha_sample$rep_gain>0 & sfha_sample$year>=2009])
regs[[2]] <- felm(formula,data=sfha_sample[sfha_sample$rep_gain<0 & sfha_sample$year>=2009])
# .printtable(regs)
gr[[i]] <- .coef_plot_2reg(regs[[1]],"Increased Republican voter share in 2016",regs[[2]],"Decreased Republican voter share in 2016","factor(year)",2012)+ggtitle(dv)+scale_fill_manual(values = col_list,na.value="white")+scale_color_manual(values = col_list,na.value="white")
gr[[i]]
i=i+1
}
‘DisasterDeclarationsSummaries.csv’ from: https://www.fema.gov/openfema-dataset-disaster-declarations-summaries-v1
disaster_dec <- read.csv(file="C:/Users/dratnadiwakara2/Downloads/DisasterDeclarationsSummaries.csv",stringsAsFactors = FALSE)
disaster_dec <- disaster_dec[disaster_dec$paProgramDeclared==1 & disaster_dec$hmProgramDeclared==1 & disaster_dec$disasterType %in% c("DR","EM"),]
disaster_dec['flooding'] <- sapply(disaster_dec$title,function(x) as.numeric(regexpr("FLOODING",x)>0 |regexpr("FLOOD",x)>0 | regexpr("HURRICANE",x)>0 | regexpr("STORM",x)>0) )
disaster_dec <- disaster_dec[disaster_dec$flooding==1 | disaster_dec$incidentType=="Flood",]
disaster_dec <- disaster_dec[,c("disasterNumber","state","incidentType","title","fyDeclared","declaredCountyArea")]
disaster_dec$declaredCountyArea <- gsub('[[:punct:]]', '', disaster_dec$declaredCountyArea)
disaster_dec$declaredCountyArea <- paste(disaster_dec$declaredCountyArea,disaster_dec$state,sep=", ")
disaster_dec$declaredCountyArea <- tolower(disaster_dec$declaredCountyArea)
county_fips <- read.csv(file="C:/Users/dratnadiwakara2/Downloads/county_fips_master.csv",stringsAsFactors = FALSE)
county_fips$declaredCountyArea <- paste(county_fips$county_name,county_fips$state_abbr,sep=", ")
county_fips <- county_fips[,c("fips","declaredCountyArea")]
county_fips$declaredCountyArea <- tolower(county_fips$declaredCountyArea)
disaster_dec <- merge(disaster_dec,county_fips,by="declaredCountyArea",all.x=TRUE)
disaster_dec['countycode']<-as.character(disaster_dec$fips)
disaster_dec['countycode'] <- ifelse(nchar(disaster_dec$countycode)==4,paste("0",disaster_dec$countycode,sep=""),disaster_dec$countycode)
disaster_dec <- disaster_dec[!is.na(disaster_dec$countycode),c("fyDeclared","countycode")]
names(disaster_dec) <- c("year","countycode")
disaster_dec['disaster_1'] <- 1
disaster_dec$year <- disaster_dec$year+1
disaster_dec <- disaster_dec[!duplicated(disaster_dec),]
policies_unique <- policies[!is.na(policies$censustract11) & !is.na(policies$originalnbdate) & !is.na(policies$originalconstructiondate) & !is.na(policies$reportedcity) & !is.na(policies$reportedzipcode) & !is.na(policies$longitude) & !is.na(policies$latitude) & !is.na(policies$numberoffloorsininsuredbuilding) & policies$condominiumindicator=="N" & policies$policycount==1 & policies$occupancytype==1 & policies$policyduration>300 & policies$construction_year<2012 & policies$postfirmconstructionindicator==1 & policies$floodzone %in% c("X","AE")]
gc()
## used (Mb) gc trigger (Mb) max used (Mb)
## Ncells 2733988 146.1 7790327 416.1 37147166 1983.9
## Vcells 2877245262 21951.7 4418695394 33712.0 4418695394 33712.0
policies_unique[,unique_code_1:=paste(policies_unique$censustract11,policies_unique$originalnbdate,policies_unique$originalconstructiondate,policies_unique$reportedcity,policies_unique$reportedzipcode,policies_unique$longitude,policies_unique$latitude,policies_unique$numberoffloorsininsuredbuilding)]
temp <- policies_unique
policies_unique <- policies_unique[!duplicated(policies_unique[,c("unique_code_1","effectiveyear")])]
policies_year <- data.table::dcast(policies_unique,unique_code_1~effectiveyear,value.var = c("policycount"))
policies_year[is.na(policies_year)] <- 0
policies_year <- reshape2::melt(policies_year,id.vars="unique_code_1")
policies_year[,year:=as.integer(as.character(policies_year$variable))]
policies_year[,variable:=list(NULL)]
names(policies_year) <- c("unique_code_1","policyyes","year")
gc()
## used (Mb) gc trigger (Mb) max used (Mb)
## Ncells 6108099 326.3 53906996 2879 43113614 2302.6
## Vcells 3487588204 26608.2 5302514472 40455 4418695394 33712.0
policies_unique <- temp[!duplicated(temp[,c("unique_code_1")]),c("unique_code_1","reportedzipcode","countycode","crsdiscount","censustract11","totalcoverage","floodzone_cat","SFHA","policyCost1dollarcov")]
policies_year <- merge(policies_year,policies_unique,by="unique_code_1")
policies_year[,countycode:=substr(policies_year$censustract11,1,5)]
rm(list=c("policies_unique","temp"))
policy_premium <- policies[policies$SFHA==1,.(costoffloodinsurance=median(policyCost1dollarcov)),by=.(censustract11,effectiveyear)]
names(policy_premium) <- c("censustract11","year","costoffloodinsurance_hr")
policy_premium_lr <- policies[policies$SFHA==0,.(costoffloodinsurance=median(policyCost1dollarcov)),by=.(censustract11,effectiveyear)]
names(policy_premium_lr) <- c("censustract11","year","costoffloodinsurance_lr")
policy_premium <- merge(policy_premium,policy_premium_lr,by=c("censustract11","year"),all.x=TRUE,all.y=TRUE)
policies_year <- merge(policies_year,election,by=c("countycode"))
policies_year <- merge(policies_year,yale,by=c("countycode","year"),all.x=TRUE)
#policies_year <- merge(policies_year,yale1618,by=c("countycode"),all.x=TRUE)
policies_year <- merge(policies_year,policy_premium,by=c("censustract11","year"),all.x=TRUE)
policies_year <- merge(policies_year,disaster_dec,by=c("countycode","year"),all.x=TRUE)
policies_year[,disaster_1:=ifelse(is.na(policies_year$disaster_1),0,policies_year$disaster_1)]
disaster_dec$year <- disaster_dec$year+1
names(disaster_dec) <- c("year","countycode","disaster_2")
policies_year <- merge(policies_year,disaster_dec,by=c("countycode","year"),all.x=TRUE)
policies_year[,disaster_2:=ifelse(is.na(policies_year$disaster_2),0,policies_year$disaster_2)]
disaster_dec$year <- disaster_dec$year+1
names(disaster_dec) <- c("year","countycode","disaster_3")
policies_year <- merge(policies_year,disaster_dec,by=c("countycode","year"),all.x=TRUE)
policies_year[,disaster_3:=ifelse(is.na(policies_year$disaster_3),0,policies_year$disaster_3)]
policies_year[,state:=substr(policies_year$censustract11,1,2)]
policies_year[,state_year:=paste(substr(policies_year$censustract11,1,2),policies_year$year)]
policies_year[,ct_year:=paste(policies_year$censustract11,policies_year$year)]
policies_year[,post:=ifelse(policies_year$year>2016,1,0)]
policies_year[,instrument:=policies_year$rep_gain*policies_year$post]
policies_year[,costoffloodinsurance:=ifelse(policies_year$SFHA==1,policies_year$costoffloodinsurance_hr,policies_year$costoffloodinsurance_lr)]
gc()
## used (Mb) gc trigger (Mb) max used (Mb)
## Ncells 6724189 359.2 22080307 1179.3 43113614 2302.6
## Vcells 3695396879 28193.7 6363097366 48546.6 5712799821 43585.3
regs <- list()
regs[[1]] <- felm(policyyes~I(1-SFHA)*climatechangereal+disaster_1+disaster_2+disaster_3+log(1+rep_pct_2012)+log(costoffloodinsurance)|ct_year + unique_code_1+year|0|unique_code_1,data=policies_year[policies_year$costoffloodinsurance>0 & policies_year$year<2020 & policies_year$floodzone_cat %in% c("X","A") ])
gc()
## used (Mb) gc trigger (Mb) max used (Mb)
## Ncells 6757378 360.9 22080307 1179.3 43113614 2302.6
## Vcells 4715353959 35975.3 7635796839 58256.6 6352655034 48467.0
.printtable(regs)
##
## =========================================================
## Dependent variable:
## ---------------------------
## ---------------------------------------------------------
## I(1 - SFHA)
## (0.000)
## climatechangereal
## (0.000)
## disaster_1
## (0.000)
## disaster_2
## (0.000)
## disaster_3
## (0.000)
## log(1 + rep_pct_2012)
## (0.000)
## log(costoffloodinsurance) -0.166***
## (0.001)
## I(1 - SFHA):climatechangereal 0.007***
## (0.0001)
## ---------------------------------------------------------
##
## Observations 36,823,531
## Adjusted R2 0.264
## =========================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
# .coef_plot_1reg(regs[[1]],"I(1 - SFHA):climatechangereal",2009)
gc()
## used (Mb) gc trigger (Mb) max used (Mb)
## Ncells 6757329 360.9 22080307 1179.3 43113614 2302.6
## Vcells 4715354404 35975.3 7635796839 58256.6 6352655034 48467.0
regs <- list()
regs[[1]] <- felm(policyyes~I(1-SFHA)*rep_gain*factor(year)+disaster_1+disaster_2+disaster_3+log(1+rep_pct_2012)+log(costoffloodinsurance)|ct_year + unique_code_1|0|unique_code_1,data=policies_year[policies_year$costoffloodinsurance>0 & policies_year$year<2020 & policies_year$floodzone_cat %in% c("X","A") ])
gc()
## used (Mb) gc trigger (Mb) max used (Mb)
## Ncells 6757567 360.9 22080307 1179.3 43113614 2302.6
## Vcells 6151482021 46932.1 11193728960 85401.4 9643747503 73576.0
.printtable(regs)
##
## =================================================================
## Dependent variable:
## ---------------------------
## -----------------------------------------------------------------
## I(1 - SFHA)
## (0.000)
## rep_gain
## (0.000)
## factor(year)2010
## (0.000)
## factor(year)2011
## (0.000)
## factor(year)2012
## (0.000)
## factor(year)2013
## (0.000)
## factor(year)2014
## (0.000)
## factor(year)2015
## (0.000)
## factor(year)2016
## (0.000)
## factor(year)2017
## (0.000)
## factor(year)2018
## (0.000)
## factor(year)2019
## (0.000)
## disaster_1
## (0.000)
## disaster_2
## (0.000)
## disaster_3
## (0.000)
## log(1 + rep_pct_2012)
## (0.000)
## log(costoffloodinsurance) -0.168***
## (0.001)
## I(1 - SFHA):rep_gain
## (0.000)
## I(1 - SFHA):factor(year)2010 -0.029***
## (0.001)
## I(1 - SFHA):factor(year)2011 -0.038***
## (0.001)
## I(1 - SFHA):factor(year)2012 -0.040***
## (0.001)
## I(1 - SFHA):factor(year)2013 -0.025***
## (0.001)
## I(1 - SFHA):factor(year)2014 -0.010***
## (0.001)
## I(1 - SFHA):factor(year)2015 -0.016***
## (0.001)
## I(1 - SFHA):factor(year)2016 -0.015***
## (0.001)
## I(1 - SFHA):factor(year)2017 0.007***
## (0.001)
## I(1 - SFHA):factor(year)2018 0.060***
## (0.001)
## I(1 - SFHA):factor(year)2019 0.057***
## (0.001)
## rep_gain:factor(year)2010
## (0.000)
## rep_gain:factor(year)2011
## (0.000)
## rep_gain:factor(year)2012
## (0.000)
## rep_gain:factor(year)2013
## (0.000)
## rep_gain:factor(year)2014
## (0.000)
## rep_gain:factor(year)2015
## (0.000)
## rep_gain:factor(year)2016
## (0.000)
## rep_gain:factor(year)2017
## (0.000)
## rep_gain:factor(year)2018
## (0.000)
## rep_gain:factor(year)2019
## (0.000)
## I(1 - SFHA):rep_gain:factor(year)2010 -0.020**
## (0.010)
## I(1 - SFHA):rep_gain:factor(year)2011 0.032***
## (0.011)
## I(1 - SFHA):rep_gain:factor(year)2012 0.057***
## (0.012)
## I(1 - SFHA):rep_gain:factor(year)2013 0.096***
## (0.012)
## I(1 - SFHA):rep_gain:factor(year)2014 0.090***
## (0.012)
## I(1 - SFHA):rep_gain:factor(year)2015 0.095***
## (0.013)
## I(1 - SFHA):rep_gain:factor(year)2016 -0.048***
## (0.013)
## I(1 - SFHA):rep_gain:factor(year)2017 -0.073***
## (0.013)
## I(1 - SFHA):rep_gain:factor(year)2018 -0.211***
## (0.013)
## I(1 - SFHA):rep_gain:factor(year)2019 -0.209***
## (0.013)
## -----------------------------------------------------------------
##
## Observations 36,823,531
## Adjusted R2 0.265
## =================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
.coef_plot_1reg(regs[[1]],"I(1 - SFHA):rep_gain:factor(year)",2009)
load(file="C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/NFIP/unique_codes.rda")
policies[,unique_code_1:=paste(policies$censustract11,policies$originalnbdate,policies$originalconstructiondate,policies$reportedcity,policies$reportedzipcode,policies$longitude,policies$latitude,policies$numberoffloorsininsuredbuilding,policies$totalbuildinginsurancecoverage,policies$totalcontentsinsurancecoverage)]
bw_policies <- policies[policies$unique_code_1 %in% matched_unique_codes]
regs <- list()
regs[[1]] <- felm(log(policyCost1dollarcov)~year|unique_code_1|0|unique_code_1,data=bw_policies[bw_policies$floodzone_cat=="A" & bw_policies$effectiveyear >2009])
regs[[2]] <- felm(log(policyCost1dollarcov)~year|unique_code_1|0|unique_code_1,data=bw_policies[bw_policies$floodzone_cat=="X" & bw_policies$policyCost1dollarcov>0 & bw_policies$effectiveyear >2009])
# .printtable(regs)
.coef_plot_2reg(regs[[1]],"SFHA",regs[[2]],"Non-SFHA","year",2010)+scale_fill_manual(values = c("gray60","gray10"),na.value="white")+scale_color_manual(values = c("gray60","gray10"),na.value="white")
‘moodyloanmonths_FL.fst’ is available here
Script used to create ‘moodyloanmonths_FL.fst’ is available here
moodyloanmonths<-read_fst("C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/NFIP/moodyloanmonths_FL.fst",as.data.table = TRUE)
moodyloanmonths <- moodyloanmonths[moodyloanmonths$occupancytype %in% c("PRI") & moodyloanmonths$producttype %in% c("FIX") & moodyloanmonths$originalterm %in% c(360) & moodyloanmonths$year>=2005 & !substr(moodyloanmonths$censustract,1,5) %in% c("12021") ]
moodyloanmonths <- merge(moodyloanmonths,bw_premchange[,c("censustract11","costchange_sfha_post")],by.x="censustract",by.y="censustract11",all.x=TRUE)
regs <- list()
regs[[1]] <- felm(prepaid~sfha*factor(year)+loanage+log(1+lagbalance)|loanid+ct_year|0|loanid,data=moodyloanmonths[moodyloanmonths$climatechangereal<70 ])
regs[[2]] <- felm(prepaid~sfha*factor(year)+loanage+log(1+lagbalance)|loanid+ct_year|0|loanid,data=moodyloanmonths[moodyloanmonths$climatechangereal>=70])
regs[[3]] <- felm(prepaid~sfha*post*factor(climatechangereal_cat)+loanage+log(1+lagbalance)|loanid+ct_year|0|loanid,data=moodyloanmonths)
.coef_plot_2reg(regs[[2]],"Belivers",regs[[1]],"Deniers","sfha:factor(year)",2005)+scale_fill_manual(values = c("gray60","gray10"),na.value="white")+scale_color_manual(values = c("gray60","gray10"),na.value="white")
.coef_plot_1reg(regs[[3]],"sfha:post:factor(climatechangereal_cat)",60)
regs <- list()
regs[[1]] <- felm(prepaid~republican*post+loanage+log(1+lagbalance)|loanid+ct_year|0|loanid,data=moodyloanmonths[ moodyloanmonths$sfha==1 & moodyloanmonths$loanoriginationdate<="2013-01-01" ])
regs[[2]] <- felm(prepaid~republican*factor(year)+loanage+log(1+lagbalance)|loanid+ct_year|0|loanid,data=moodyloanmonths[ moodyloanmonths$sfha==1 & moodyloanmonths$loanoriginationdate<="2013-01-01" ])
.printtable(regs)
##
## ========================================================
## Dependent variable:
## ----------------------------
## (1) (2)
## --------------------------------------------------------
## republican
## (0.000) (0.000)
## post
## (0.000)
## factor(year)2006
## (0.000)
## factor(year)2007
## (0.000)
## factor(year)2008
## (0.000)
## factor(year)2009
## (0.000)
## factor(year)2010
## (0.000)
## factor(year)2011
## (0.000)
## factor(year)2012
## (0.000)
## factor(year)2013
## (0.000)
## factor(year)2014
## (0.000)
## factor(year)2015
## (0.000)
## factor(year)2016
## (0.000)
## factor(year)2017
## (0.000)
## factor(year)2018
## (0.000)
## factor(year)2019
## (0.000)
## loanage 0.0003*** 0.0003***
## (0.0001) (0.0001)
## log(1 + lagbalance) -0.034*** -0.034***
## (0.001) (0.001)
## republican:post 0.013**
## (0.005)
## republican:factor(year)2006 -0.001
## (0.005)
## republican:factor(year)2007 -0.001
## (0.006)
## republican:factor(year)2008 0.0001
## (0.006)
## republican:factor(year)2009 -0.002
## (0.006)
## republican:factor(year)2010 -0.001
## (0.006)
## republican:factor(year)2011 -0.001
## (0.006)
## republican:factor(year)2012 0.003
## (0.007)
## republican:factor(year)2013 0.007
## (0.007)
## republican:factor(year)2014 0.009
## (0.007)
## republican:factor(year)2015 0.018**
## (0.008)
## republican:factor(year)2016 0.015*
## (0.008)
## republican:factor(year)2017 0.014
## (0.009)
## republican:factor(year)2018 0.018*
## (0.010)
## republican:factor(year)2019 0.013
## (0.010)
## --------------------------------------------------------
##
## Observations 681,474 681,474
## Adjusted R2 0.901 0.901
## ========================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##
.coef_plot_1reg(regs[[2]],"republican:factor(year)",2005)
temp <- policies[ policies$SFHA==1 & policies$postfirmconstructionindicator==1 & policies$floodzone_cat=="A" & policies$effectiveyear>=2013]
temp[,year:=effectiveyear]
temp <- merge(temp,yale,by=c("countycode","year"))
temp <- merge(temp,acs,by=c("censustract","year"))
temp <- temp[temp$basefloodelevation>0 & temp$primaryresidenceindicator==1 & temp$median_age>0 & temp$median_hh_income>0 & temp$effectiveyear>temp$median_year_structure_built & temp$white_population>0 & temp$total_population>0 & temp$basefloodelevation>0 & temp$numberoffloorsininsuredbuilding>0 & temp$policyCost1dollarcov>0 & temp$zhvi>0]
temp[,white_fraction:=temp$white_population/temp$total_population]
temp[,collage_fraction:=temp$college_degree_popu/temp$total_population]
temp[,owner_frac:=temp$owner_occ_units/temp$no_of_homes]
temp[,numberoffloorsininsuredbuilding:=as.numeric(temp$numberoffloorsininsuredbuilding)]
temp <- temp[is.finite(temp$policyCost1dollarcov)]
regs <- list()
# regs[[1]] <- felm(log(1+crsdiscount)~log(climatechangereal)+log(median_hh_income)+log(median_age)+I(effectiveyear-median_year_structure_built)+I(white_population/total_population)+I(college_degree_popu/total_population)+log(zhvi)+log(1+basefloodelevation)+numberoffloorsininsuredbuilding+log(house_age)+nobasement+log(1+lowestfloorelevation)+log(1+elevationdifference)+log(1+no_of_disasters)+log(policyCost1dollarcov)|year|0|censustract,data=temp[temp$slr_county==1 & temp$basefloodelevation>=0 & temp$house_age>0 & temp$primaryresidence==1 & temp$house_age>0 & temp$lowestfloorelevation>=0 & temp$elevationdifference>=0])
regs[[1]] <- felm(log(1+crsdiscount)~log(climatechangereal)+log(median_hh_income)+log(median_age)+log(zhvi)+basefloodelevation+numberoffloorsininsuredbuilding+elevationdifference+log(policyCost1dollarcov)+white_fraction+collage_fraction+owner_frac+postfirmconstructionindicator|year|0|censustract,data=temp)
regs[[2]] <- felm(log(1+crsdiscount)~log(climatechangereal)+log(median_hh_income)+log(median_age)+log(zhvi)+basefloodelevation+numberoffloorsininsuredbuilding+elevationdifference+log(policyCost1dollarcov)+white_fraction+collage_fraction+owner_frac+postfirmconstructionindicator|propertystate+year|0|censustract,data=temp)
regs[[3]] <- felm(log(1+crsdiscount)~log(worriedaboutclimatechange)+log(median_hh_income)+log(median_age)+log(zhvi)+basefloodelevation+numberoffloorsininsuredbuilding+elevationdifference+log(policyCost1dollarcov)+white_fraction+collage_fraction+owner_frac+postfirmconstructionindicator|propertystate+year|0|censustract,data=temp)
regs[[4]] <- felm(log(1+crsdiscount)~log(climatechangeimpactpersonal)+log(median_hh_income)+log(median_age)+log(zhvi)+basefloodelevation+numberoffloorsininsuredbuilding+elevationdifference+log(policyCost1dollarcov)+white_fraction+collage_fraction+owner_frac+postfirmconstructionindicator|propertystate+year|0|censustract,data=temp)
.printtable(regs,lines = list(c("Fixed Effects","","State","State","State")))
##
## ================================================================================
## Dependent variable:
## -----------------------------------------------
## (1) (2) (3) (4)
## --------------------------------------------------------------------------------
## log(climatechangereal) 0.218*** 0.125***
## (0.018) (0.019)
## log(worriedaboutclimatechange) 0.064***
## (0.013)
## log(climatechangeimpactpersonal) 0.056***
## (0.011)
## log(median_hh_income) -0.030*** -0.006 -0.006 -0.005
## (0.005) (0.004) (0.004) (0.004)
## log(median_age) 0.046*** 0.023*** 0.021*** 0.025***
## (0.009) (0.008) (0.007) (0.007)
## log(zhvi) 0.015*** 0.004 0.005* 0.004
## (0.003) (0.003) (0.003) (0.003)
## basefloodelevation -0.00003*** -0.00001*** -0.00001*** -0.00001***
## (0.00000) (0.00000) (0.00000) (0.00000)
## numberoffloorsininsuredbuilding -0.021*** -0.011*** -0.011*** -0.011***
## (0.001) (0.001) (0.001) (0.001)
## elevationdifference 0.00000*** 0.00000*** 0.00000*** 0.00000***
## (0.00000) (0.00000) (0.00000) (0.00000)
## log(policyCost1dollarcov) -0.031*** -0.023*** -0.023*** -0.023***
## (0.002) (0.001) (0.001) (0.001)
## white_fraction 0.023** -0.001 -0.004 -0.004
## (0.009) (0.009) (0.009) (0.009)
## collage_fraction -0.047 -0.013 -0.014 -0.008
## (0.029) (0.025) (0.026) (0.026)
## owner_frac 0.015* 0.004 0.006 0.004
## (0.008) (0.007) (0.007) (0.007)
## postfirmconstructionindicator
## (0.000) (0.000) (0.000) (0.000)
## --------------------------------------------------------------------------------
## Fixed Effects State State State
## Observations 3,929,925 3,929,925 3,929,925 3,929,925
## Adjusted R2 0.224 0.425 0.422 0.423
## ================================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
##