rm(list=ls())
library(stargazer)
library(data.table)
library(ggplot2)
library(lfe)

1 Reading data

nonsfha <- fread("non_sfha_sample.csv")

2 Descriptive Stats Non-SFHA

t <- nonsfha[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","disaster_1")]
stargazer(t, 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.0452       0.0631       0.0163       0.0266       0.0473    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.5000 13,907
## disaster_1                     0.1728       0.3780         0            0            0       16,735
## ---------------------------------------------------------------------------------------------------
## 

3 OLS: Non-SFHA

regs <- list()

regs[[1]] <- felm(log(1+policies_fraction*100)~
                    worriedaboutclimatechange+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+log(flood_connectedness)
                  |censustract+state_yr|0|censustract,
                  data=nonsfha) 

regs[[2]] <- felm(log(1+policies_fraction*100)~
                    climatechangereal+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+log(flood_connectedness)
                  |censustract+state_yr|0|censustract,
                  data=nonsfha) 

regs[[3]] <- felm(log(1+policies_fraction*100)~
                    climatechangeimpactpersonal+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+log(flood_connectedness)
                  |censustract+state_yr|0|censustract,
                  data=nonsfha) 


regs[[4]] <- felm(log(1+policies_fraction*100)~
                    worriedaboutclimatechange*disaster_1+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)+log(flood_connectedness)
                  |censustract+state_yr|0|censustract,
                  data=nonsfha) 

regs[[5]] <- felm(log(1+policies_fraction*100)~
                    climatechangereal*disaster_1+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)+log(flood_connectedness)
                  |censustract+state_yr|0|censustract,
                  data=nonsfha) 

regs[[6]] <- felm(log(1+policies_fraction*100)~
                    climatechangeimpactpersonal*disaster_1+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)+log(flood_connectedness)
                  |censustract+state_yr|0|censustract,
                  data=nonsfha) 



stargazer(regs,type="text",no.space = T,align = T,
          omit.stat=c("ser","f", "rsq"),style = "qje",omit.table.layout = "n", 
          dep.var.labels.include = F,
          add.lines = list(c("Tract", rep("Y",6)),c("State*Year", rep("Y",6))))
## 
## ==================================================================================================
##                                           (1)       (2)       (3)       (4)       (5)       (6)   
## --------------------------------------------------------------------------------------------------
## worriedaboutclimatechange               0.104**                       0.095**                     
##                                         (0.047)                       (0.047)                     
## climatechangereal                                 0.098*                        0.087*            
##                                                   (0.053)                       (0.052)           
## climatechangeimpactpersonal                                0.241***                      0.224*** 
##                                                             (0.076)                       (0.076) 
## log(median_hh_income)                    0.013     0.013     0.013     0.013     0.013     0.013  
##                                         (0.009)   (0.009)   (0.009)   (0.009)   (0.009)   (0.009) 
## log(median_age)                         -0.001    -0.001    -0.001    -0.001    -0.001    -0.001  
##                                         (0.018)   (0.018)   (0.018)   (0.018)   (0.018)   (0.018) 
## log(white_frac)                          0.019     0.019     0.019     0.019     0.019     0.018  
##                                         (0.012)   (0.012)   (0.012)   (0.012)   (0.012)   (0.012) 
## log(college_frac)                      -0.019*** -0.019*** -0.019*** -0.019*** -0.019*** -0.019***
##                                         (0.007)   (0.007)   (0.007)   (0.007)   (0.007)   (0.007) 
## log(total_population)                  0.064***  0.064***  0.064***  0.064***  0.064***  0.064*** 
##                                         (0.019)   (0.019)   (0.019)   (0.019)   (0.019)   (0.019) 
## log(no_of_homes)                       -0.351*** -0.350*** -0.349*** -0.350*** -0.350*** -0.348***
##                                         (0.027)   (0.027)   (0.028)   (0.027)   (0.027)   (0.028) 
## log(owner_frac)                         0.039**   0.038**   0.039**   0.039**   0.038**   0.039** 
##                                         (0.016)   (0.016)   (0.016)   (0.016)   (0.016)   (0.016) 
## log(lr_cost)                           0.013***  0.013***  0.013***  0.013***  0.013***  0.013*** 
##                                         (0.005)   (0.005)   (0.005)   (0.005)   (0.005)   (0.005) 
## log(median_house_age)                    0.001     0.001     0.001     0.001     0.001     0.001  
##                                         (0.002)   (0.002)   (0.002)   (0.002)   (0.002)   (0.002) 
## log(house_price)                       -0.034*** -0.034*** -0.034*** -0.034*** -0.034*** -0.034***
##                                         (0.013)   (0.013)   (0.013)   (0.013)   (0.013)   (0.013) 
## disaster_1                             0.014***  0.014***  0.014***   -0.011    -0.024*   -0.010  
##                                         (0.001)   (0.001)   (0.001)   (0.009)   (0.012)   (0.008) 
## log(flood_connectedness)                0.004*    0.004*    0.004*    0.004*    0.004*    0.004*  
##                                         (0.002)   (0.002)   (0.002)   (0.002)   (0.002)   (0.002) 
## worriedaboutclimatechange:disaster_1                                 0.044***                     
##                                                                       (0.016)                     
## climatechangereal:disaster_1                                                   0.057***           
##                                                                                 (0.018)           
## climatechangeimpactpersonal:disaster_1                                                   0.063*** 
##                                                                                           (0.021) 
## Tract                                      Y         Y         Y         Y         Y         Y    
## State*Year                                 Y         Y         Y         Y         Y         Y    
## N                                       100,422   100,422   100,422   100,422   100,422   100,422 
## Adjusted R2                              0.967     0.967     0.967     0.967     0.967     0.967  
## ==================================================================================================

4 First Stage: Non-SFHA

regs <- list()

regs[[1]] <- felm(worriedaboutclimatechange~
                    rep_gain*post+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+log(flood_connectedness)
                  |censustract+state_yr|0|censustract,
                  data=nonsfha) 

regs[[2]] <- felm(climatechangereal~
                    rep_gain*post+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+log(flood_connectedness)
                  |censustract+state_yr|0|censustract,
                  data=nonsfha) 

regs[[3]] <- felm(climatechangeimpactpersonal~
                    rep_gain*post+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+log(flood_connectedness)
                  |censustract+state_yr|0|censustract,
                  data=nonsfha) 

stargazer(regs,type="text",no.space = T,align = T,
          omit.stat=c("ser","f", "rsq"),style = "qje",omit.table.layout = "n", 
          dep.var.labels.include = F,
          add.lines = list(c("Tract", rep("Y",6)),c("State*Year", rep("Y",6))))
## 
## ======================================================
##                             (1)       (2)       (3)   
## ------------------------------------------------------
## rep_gain                                              
##                           (0.000)   (0.000)   (0.000) 
## post                                                  
##                           (0.000)   (0.000)   (0.000) 
## log(median_hh_income)    -0.002**   -0.001   -0.001** 
##                           (0.001)   (0.001)   (0.001) 
## log(median_age)           -0.0005   -0.001    -0.001  
##                           (0.002)   (0.002)   (0.001) 
## log(white_frac)          -0.003*** -0.002**   -0.001  
##                           (0.001)   (0.001)   (0.001) 
## log(college_frac)        -0.003*** -0.003*** -0.001** 
##                           (0.001)   (0.001)   (0.001) 
## log(total_population)     -0.003*   -0.002   -0.004***
##                           (0.002)   (0.002)   (0.001) 
## log(no_of_homes)          -0.001    -0.004   -0.008***
##                           (0.003)   (0.002)   (0.002) 
## log(owner_frac)          -0.005*** -0.003*** -0.003***
##                           (0.001)   (0.001)   (0.001) 
## log(lr_cost)              -0.0005   -0.001   -0.00005 
##                          (0.0004)  (0.0003)  (0.0003) 
## log(median_house_age)     0.0002    0.0002*  0.0002** 
##                          (0.0001)  (0.0001)  (0.0001) 
## log(house_price)         0.006***  0.007***   -0.001  
##                           (0.001)   (0.001)   (0.001) 
## disaster_1               0.001***  0.001***   0.0001  
##                          (0.0002)  (0.0001)  (0.0001) 
## log(flood_connectedness) -0.001*** -0.001***  -0.0002 
##                          (0.0003)  (0.0003)  (0.0002) 
## rep_gain:post            -0.081*** -0.071*** -0.060***
##                           (0.002)   (0.002)   (0.002) 
## Tract                        Y         Y         Y    
## State*Year                   Y         Y         Y    
## N                         100,265   100,265   100,265 
## Adjusted R2                0.963     0.963     0.974  
## ======================================================

5 Second Stage: Non-SFHA

regs <- list()

regs[[1]] <- felm(log(1+policies_fraction*100)~
                    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+log(flood_connectedness)
                  |censustract+state_yr|(worriedaboutclimatechange~rep_gain*post)|censustract,
                  data=nonsfha) 

regs[[2]] <- felm(log(1+policies_fraction*100)~
                    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+log(flood_connectedness)
                  |censustract+state_yr|(climatechangereal~rep_gain*post)|censustract,
                  data=nonsfha) 

regs[[3]] <- felm(log(1+policies_fraction*100)~
                    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+log(flood_connectedness)
                  |censustract+state_yr|(climatechangeimpactpersonal~rep_gain*post)|censustract,
                  data=nonsfha) 


stargazer(regs,type="text",no.space = T,align = T,
          omit.stat=c("ser","f", "rsq"),style = "qje",omit.table.layout = "n", 
          dep.var.labels.include = F,
          add.lines = list(c("Tract", rep("Y",6)),c("State*Year", rep("Y",6))))
## 
## ================================================================
##                                       (1)       (2)       (3)   
## ----------------------------------------------------------------
## log(median_hh_income)                0.015     0.013    0.015*  
##                                     (0.009)   (0.009)   (0.009) 
## log(median_age)                     -0.005    -0.004    -0.002  
##                                     (0.018)   (0.018)   (0.018) 
## log(white_frac)                     0.024**   0.024**   0.021*  
##                                     (0.012)   (0.012)   (0.012) 
## log(college_frac)                   -0.007    -0.008    -0.010  
##                                     (0.007)   (0.007)   (0.007) 
## log(total_population)              0.062***  0.061***  0.066*** 
##                                     (0.019)   (0.019)   (0.019) 
## log(no_of_homes)                   -0.350*** -0.343*** -0.328***
##                                     (0.028)   (0.028)   (0.028) 
## log(owner_frac)                    0.048***  0.046***  0.046*** 
##                                     (0.016)   (0.016)   (0.016) 
## log(lr_cost)                       0.015***  0.016***  0.014*** 
##                                     (0.005)   (0.005)   (0.005) 
## log(median_house_age)               -0.0002   -0.0003   -0.0005 
##                                     (0.002)   (0.002)   (0.002) 
## log(house_price)                   -0.062*** -0.065*** -0.046***
##                                     (0.014)   (0.014)   (0.014) 
## disaster_1                         0.014***  0.012***  0.015*** 
##                                     (0.001)   (0.001)   (0.001) 
## log(flood_connectedness)           0.009***  0.010***  0.007*** 
##                                     (0.002)   (0.002)   (0.002) 
## `worriedaboutclimatechange(fit)`   2.106***                     
##                                     (0.178)                     
## `climatechangereal(fit)`                     2.396***           
##                                               (0.204)           
## `climatechangeimpactpersonal(fit)`                     2.846*** 
##                                                         (0.245) 
## Tract                                  Y         Y         Y    
## State*Year                             Y         Y         Y    
## N                                   100,265   100,265   100,265 
## Adjusted R2                          0.965     0.965     0.965  
## ================================================================