library(pacman)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
p_load("tidyverse")
p_load("fixest")
setwd('C:/Users/mooph/OneDrive/Documents/Grad HW/Metrics Term 3')
p_load("haven")
##Step 01
allsites <- read_dta("allsites.dta")
View(allsites)
glimpse(allsites)
## Rows: 42,974
## Columns: 44
## $ fips <chr> "01001020200", "01001020300", "01001020400", "0100102…
## $ state <chr> "", "", "", "", "", "", "", "", "AL", "", "", "", "",…
## $ npl2000 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ pop_den8 <dbl> 1634.88367, 1497.60767, 1995.14172, 454.03589, 913.84…
## $ shrblk8 <dbl> 0.606448, 0.149201, 0.000000, 0.059753, 0.156902, 0.2…
## $ shrhsp8 <dbl> 0.012328, 0.016613, 0.016842, 0.014321, 0.003367, 0.0…
## $ child8 <dbl> 0.355618, 0.328753, 0.300121, 0.357530, 0.347474, 0.3…
## $ old8 <dbl> 0.139876, 0.098083, 0.059050, 0.025185, 0.056565, 0.1…
## $ shrfor8 <dbl> 0.010431, 0.021405, 0.009334, 0.014321, 0.000000, 0.0…
## $ ffh8 <dbl> 0.249146, 0.166015, 0.097989, 0.066844, 0.175700, 0.1…
## $ smhse8 <dbl> 0.517978, 0.404166, 0.488126, 0.408845, 0.422598, 0.6…
## $ hsdrop8 <dbl> 0.141361, 0.066079, 0.083333, 0.272222, 0.196428, 0.0…
## $ no_hs_diploma8 <dbl> 0.4954874, 0.2879581, 0.2278614, 0.2380952, 0.3936529…
## $ ba_or_better8 <dbl> 0.10288808, 0.14077953, 0.20651032, 0.20602527, 0.087…
## $ unemprt8 <dbl> 0.108241, 0.035384, 0.033933, 0.073512, 0.079545, 0.0…
## $ povrat8 <dbl> 0.302460, 0.077174, 0.057426, 0.070123, 0.084511, 0.2…
## $ welfare8 <dbl> 0.203566, 0.091003, 0.033996, 0.076256, 0.070646, 0.1…
## $ avhhin8 <dbl> 14465.63, 18397.63, 23987.15, 22034.01, 19911.98, 151…
## $ tothsun8 <dbl> 741, 1018, 1633, 641, 1029, 1077, 803, 1013, 708, 113…
## $ ownocc8 <dbl> 491, 716, 1293, 487, 834, 826, 590, 715, 617, 658, 67…
## $ firestoveheat80 <dbl> 0.05802969, 0.00000000, 0.01959584, 0.02340094, 0.017…
## $ noaircond80 <dbl> 0.33063427, 0.11296660, 0.01898347, 0.06240249, 0.165…
## $ nofullkitchen80 <dbl> 0.006747638, 0.017681729, 0.004286589, 0.034321371, 0…
## $ zerofullbath80 <dbl> 0.03373819, 0.03143419, 0.00000000, 0.01560062, 0.016…
## $ statefips <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ bedrms0_80occ <dbl> 0.0000000000, 0.0000000000, 0.0000000000, 0.000000000…
## $ bedrms1_80occ <dbl> 0.069246434, 0.008379889, 0.000000000, 0.012170386, 0…
## $ bedrms2_80occ <dbl> 0.15274949, 0.03910615, 0.08971384, 0.17241380, 0.232…
## $ bedrms3_80occ <dbl> 0.5987780, 0.7416201, 0.6140758, 0.5354970, 0.5455636…
## $ bedrms4_80occ <dbl> 0.13849287, 0.20391062, 0.27610210, 0.26977688, 0.157…
## $ bedrms5_80occ <dbl> 0.040733196, 0.006983240, 0.020108275, 0.010141988, 0…
## $ blt0_1yrs80occ <dbl> 0.03258656, 0.06145252, 0.02552204, 0.09146342, 0.056…
## $ blt2_5yrs80occ <dbl> 0.11201629, 0.07541899, 0.10208817, 0.24390244, 0.229…
## $ blt6_10yrs80occ <dbl> 0.2749491, 0.3198324, 0.1755607, 0.4857724, 0.2553957…
## $ blt10_20yrs80occ <dbl> 0.04276986, 0.33659217, 0.52668214, 0.16869919, 0.326…
## $ blt20_30yrs80occ <dbl> 0.08350305, 0.09916201, 0.16550657, 0.00000000, 0.093…
## $ blt30_40yrs80occ <dbl> 0.124236256, 0.018156424, 0.004640371, 0.000000000, 0…
## $ blt40_yrs80occ <dbl> 0.32993889, 0.08938547, 0.00000000, 0.01016260, 0.022…
## $ detach80occ <dbl> 0.9804772, 1.0000000, 0.9718969, 0.8747433, 0.7125457…
## $ attach80occ <dbl> 0.008676790, 0.000000000, 0.003903201, 0.000000000, 0…
## $ mobile80occ <dbl> 0.01084599, 0.00000000, 0.02419984, 0.12525667, 0.287…
## $ occupied80 <dbl> 0.9352227, 0.9715128, 0.9675444, 0.9126365, 0.9475219…
## $ lnmeanhs8 <dbl> 10.33014, 10.62553, 10.82902, 10.80235, 10.53244, 10.…
## $ lnmdvalhs0 <dbl> 11.21855, 11.29849, 11.40645, 11.66993, 11.35158, 11.…
fit<-lm(lnmdvalhs0~npl2000, data=allsites)
summary(fit)
##
## Call:
## lm(formula = lnmdvalhs0 ~ npl2000, data = allsites)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.50946 -0.40522 -0.02112 0.37935 2.11709
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 11.719696 0.003052 3840.095 <2e-16 ***
## npl2000 -0.021269 0.020159 -1.055 0.291
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6254 on 42972 degrees of freedom
## Multiple R-squared: 2.591e-05, Adjusted R-squared: 2.635e-06
## F-statistic: 1.113 on 1 and 42972 DF, p-value: 0.2914
Based on this regression listing a tract in the NPL is associated with a 2 percent decrese in log median housing value. ## Step 03
state_effect<-feols(lnmdvalhs0~npl2000|statefips,data=allsites)
summary(state_effect)
## OLS estimation, Dep. Var.: lnmdvalhs0
## Observations: 42,974
## Fixed-effects: statefips: 51
## Standard-errors: Clustered (statefips)
## Estimate Std. Error t value Pr(>|t|)
## npl2000 -0.031575 0.042163 -0.748888 0.45743
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.525648 Adj. R2: 0.292655
## Within R2: 7.949e-5
Clustering errors by state made the estimate more negative, and less signifcant. This makes sense as standard errors are downwardly biased in a standard regression when state effects aren’t being taken into consideration. ## Step 04
contr1980<- feols(lnmdvalhs0~npl2000+lnmeanhs8|statefips,data=allsites)
more_contr <- feols(lnmdvalhs0~npl2000+lnmeanhs8+shrblk8 + povrat8|statefips,data=allsites)
contr_SE <- feols(lnmdvalhs0~npl2000+lnmeanhs8+shrblk8 + povrat8|statefips,data=allsites)
summary(contr1980)
## OLS estimation, Dep. Var.: lnmdvalhs0
## Observations: 42,974
## Fixed-effects: statefips: 51
## Standard-errors: Clustered (statefips)
## Estimate Std. Error t value Pr(>|t|)
## npl2000 -0.002697 0.024651 -0.109425 0.9133
## lnmeanhs8 0.805832 0.032206 25.020985 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.343771 Adj. R2: 0.697456
## Within R2: 0.572326
summary(more_contr)
## OLS estimation, Dep. Var.: lnmdvalhs0
## Observations: 42,974
## Fixed-effects: statefips: 51
## Standard-errors: Clustered (statefips)
## Estimate Std. Error t value Pr(>|t|)
## npl2000 -0.005059 0.024290 -0.208287 0.83585
## lnmeanhs8 0.787808 0.053157 14.820344 < 2.2e-16 ***
## shrblk8 -0.072103 0.061961 -1.163686 0.25007
## povrat8 -0.036341 0.165869 -0.219092 0.82747
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.343357 Adj. R2: 0.69817
## Within R2: 0.573355
Controlling for log mean housing value in 1980 did help the reduce the standard errors, but then the estimate also reduced and is hard to distinguish from 0. Controlling for other demographics (share black and poverty rate from 1980), seamed to help the significance of the point estimate. ##Step 05 If the tracts NPL status is as good as random, then consistent point estimates can be produced.
##Step 06
allcovs<-read_dta("allcovariates.dta")
allcovs1<-allcovs%>%mutate(lnmedianh2000 = log(mdvalhs0))%>%mutate(lnmeanh80 = log(meanhs8))
contr_hv_80<- feols(lnmeanh80~ npl2000,data=allcovs1)
contr_shrblk <- feols(shrblk8~npl2000,data=allcovs1)
contr_pov <- feols(povrat8~npl2000, data =allcovs1)
summary(contr_pov)
## OLS estimation, Dep. Var.: povrat8
## Observations: 48,245
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.112509 0.000464 242.38015 < 2.2e-16 ***
## npl2000 -0.006901 0.003249 -2.12431 0.033649 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.100908 Adj. R2: 7.281e-5
summary(contr_hv_80)
## OLS estimation, Dep. Var.: lnmeanh80
## Observations: 48,245
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 10.882979 0.002518 4321.41734 < 2.2e-16 ***
## npl2000 -0.068878 0.017625 -3.90799 9.3193e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.547469 Adj. R2: 2.958e-4
summary(contr_shrblk)
## OLS estimation, Dep. Var.: shrblk8
## Observations: 48,245
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.116509 0.001091 106.81510 < 2.2e-16 ***
## npl2000 -0.025099 0.007634 -3.28795 0.0010099 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.237117 Adj. R2: 2.033e-4
Tracts with higher home values in 1980 are less likely to get listed, tracts with higher share of black residents in 1980 are less likely to get listed, and tracts with higher poverty rates in 1980 are less likely to get listed. ## Step 07
site_data <- read_dta("sitecovariates.dta")
site_data1<- site_data%>%mutate(lnmedianh2000 = log(mdvalhs0))%>%mutate(lnmeanh80 = log(meanhs8))
site_data1$hrsdummy <- ifelse(site_data1$hrs_82>28.5,1,0)
site_data1$hrsdummy2 <- ifelse(site_data1$hrs_82>= 16.5 & site_data1$hrs_82<28.5,1,0)
site_data1$hrsdummy3 <- ifelse(site_data1$hrs_82>=28.5 & site_data1$hrs_82<=40.5,1,0)
contr_hv_801<- feols(lnmeanh80~ npl2000,data=site_data1)
contr_shrblk1 <- feols(shrblk8~npl2000,data=site_data1)
contr_pov1 <-feols(povrat8~npl2000, data =site_data1)
contr_hv_802<- feols(lnmeanh80~ hrsdummy,data=site_data1)
contr_shrblk2 <- feols(shrblk8~hrsdummy,data=site_data1)
contr_pov2 <-feols(povrat8~hrsdummy, data =site_data1)
contr_hv_803<- feols(lnmeanh80~ hrsdummy2+hrsdummy3,data=site_data1)
contr_shrblk3 <- feols(shrblk8~hrsdummy2+hrsdummy3,data=site_data1)
contr_pov3 <- feols(povrat8~hrsdummy2+hrsdummy3, data =site_data1)
summary(contr_hv_801)
## OLS estimation, Dep. Var.: lnmeanh80
## Observations: 487
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 10.626067 0.031833 333.80649 < 2.2e-16 ***
## npl2000 0.150715 0.038554 3.90916 0.0001058 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.395503 Adj. R2: 0.028547
summary(contr_shrblk1)
## OLS estimation, Dep. Var.: shrblk8
## Observations: 487
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.118132 0.015396 7.67295 9.3019e-14 ***
## npl2000 -0.046173 0.018647 -2.47618 1.3620e-02 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.191284 Adj. R2: 0.010448
summary(contr_pov1)
## OLS estimation, Dep. Var.: povrat8
## Observations: 487
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.116907 0.006818 17.14652 < 2.2e-16 ***
## npl2000 -0.016756 0.008258 -2.02909 0.042995 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.08471 Adj. R2: 0.006373
summary(contr_hv_802)
## OLS estimation, Dep. Var.: lnmeanh80
## Observations: 487
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 10.63162 0.029396 361.66928 < 2.2e-16 ***
## hrsdummy 0.15468 0.037084 4.17101 3.5932e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.39467 Adj. R2: 0.032638
summary(contr_shrblk2)
## OLS estimation, Dep. Var.: shrblk8
## Observations: 487
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.112609 0.014260 7.89694 1.9262e-14 ***
## hrsdummy -0.041305 0.017989 -2.29606 2.2098e-02 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.191452 Adj. R2: 0.008713
summary(contr_pov2)
## OLS estimation, Dep. Var.: povrat8
## Observations: 487
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.113932 0.006318 18.03389 < 2.2e-16 ***
## hrsdummy -0.013445 0.007970 -1.68690 0.092266 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.08482 Adj. R2: 0.003783
summary(contr_hv_803)
## OLS estimation, Dep. Var.: lnmeanh80
## Observations: 487
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 10.739800 0.024942 430.599315 < 2.2e-16 ***
## hrsdummy2 -0.062702 0.049185 -1.274819 0.20298
## hrsdummy3 0.002138 0.042458 0.050349 0.95986
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.400929 Adj. R2: -3.537e-4
summary(contr_shrblk3)
## OLS estimation, Dep. Var.: shrblk8
## Observations: 487
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.089507 0.011973 7.475739 3.6284e-13 ***
## hrsdummy2 -0.007636 0.023611 -0.323399 7.4653e-01
## hrsdummy3 -0.005121 0.020382 -0.251246 8.0173e-01
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.192463 Adj. R2: -0.003861
summary(contr_pov3)
## OLS estimation, Dep. Var.: povrat8
## Observations: 487
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.101711 0.005285 19.243999 < 2.2e-16 ***
## hrsdummy2 0.005470 0.010423 0.524789 0.59997
## hrsdummy3 0.009818 0.008997 1.091246 0.27571
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.084961 Adj. R2: -0.001577
We see that being listed on the npl list and having a hrs score over 28.5 is strongly correlated. Also having an hrs score between 16.5 and 28.5 is assocated with not being listed on the npl list. And we see that an unbalance in the share of black residents in 1980 and the poverty rate, but both get better as the threshold narrows ## Step 08 The necessary assumptions are that hrs scores are exogenous, relevant to the treatment, and monotonic. ## Step 09 We need outcomes to vary around the cutoff, and also for npl listing to be affected at the cutoff of 28.5 ## Step 10 The second and third facts suggest that hrs scores would be a good instrumental variable. The first fact is concerning since the cutoff was selected with the number of sites in mind. ## Step 11
twomile <- read_dta("2miledata.dta")
first_stage <- feols(npl2000~hrs_82, data=twomile)
reduced_form<-feols(log(mdvalhs0)~hrs_82,data=twomile)
twosls<- feols(log(mdvalhs0)~1|npl2000~hrs_82,data=twomile)
summary(first_stage)
## OLS estimation, Dep. Var.: npl2000
## Observations: 483
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.003736 0.031098 0.120131 0.90443
## hrs_82 0.020178 0.000819 24.642755 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.308188 Adj. R2: 0.557093
summary(reduced_form)
## OLS estimation, Dep. Var.: log(mdvalhs0)
## Observations: 483
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 11.429770 0.048972 233.39318 < 2.2e-16 ***
## hrs_82 0.006238 0.001289 4.83781 1.7706e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.485328 Adj. R2: 0.044418
summary(twosls)
## TSLS estimation, Dep. Var.: log(mdvalhs0), Endo.: npl2000, Instr.: hrs_82
## Second stage: Dep. Var.: log(mdvalhs0)
## Observations: 483
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 11.428615 0.050045 228.36569 < 2.2e-16 ***
## fit_npl2000 0.309157 0.065022 4.75468 2.6303e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.493814 Adj. R2: 0.01071
## F-test (1st stage), npl2000: stat = 607.3 , p < 2.2e-16 , on 1 and 481 DoF.
## Wu-Hausman: stat = 9.46738, p = 0.002211, on 1 and 480 DoF.
##Step 12 Adding state fixed effects reduces out treatment effect, but increases the significance of the estimate. ##Step 13
twomile$hrsdummy <- ifelse(twomile$hrs_82>28.5,1,0)
first_stage1 <- feols(npl2000~hrsdummy, data=twomile)
reduced_form1<-feols(log(mdvalhs0)~hrsdummy,data=twomile)
twosls1<- feols(log(mdvalhs0)~1|npl2000~hrsdummy,data=twomile)
summary(first_stage1)
## OLS estimation, Dep. Var.: npl2000
## Observations: 483
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.163842 0.017880 9.16318 < 2.2e-16 ***
## hrsdummy 0.826354 0.022464 36.78537 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.237391 Adj. R2: 0.73721
summary(reduced_form1)
## OLS estimation, Dep. Var.: log(mdvalhs0)
## Observations: 483
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 11.527932 0.036868 312.67939 < 2.2e-16 ***
## hrsdummy 0.178662 0.046320 3.85715 0.00013033 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.489483 Adj. R2: 0.027986
summary(twosls1)
## TSLS estimation, Dep. Var.: log(mdvalhs0), Endo.: npl2000, Instr.: hrsdummy
## Second stage: Dep. Var.: log(mdvalhs0)
## Observations: 483
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 11.492508 0.044609 257.62790 < 2.2e-16 ***
## fit_npl2000 0.216205 0.056157 3.85003 0.00013406 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.490389 Adj. R2: 0.024385
## F-test (1st stage), npl2000: stat = 1,353.2 , p < 2.2e-16 , on 1 and 481 DoF.
## Wu-Hausman: stat = 1.74193, p = 0.187524, on 1 and 480 DoF.
Fuzzy RD, since first stage is very strong, and the effect from the reduced form is larger, which lead to a increase in the treatment effect after 28.5. ## Step 15
two_mile <- twomile%>%mutate(run=hrs_82-28.5,runbin = run%/%1*1)%>%group_by(runbin)%>%transmute(n=n(),Housing_Value = mean((mdvalhs0),na.rm=T),NPL2000 = mean(npl2000),Share_Black = mean(shrblk8_nbr),Poverty_Rate = mean(povrat8_nbr))%>%ungroup()
plot1 = ggplot(data=two_mile,aes(x=runbin, y= Housing_Value, group=runbin<0))+geom_vline(xintercept=0,color="red")+
geom_line()+geom_point()+geom_smooth(se=F, method=loess)+xlab("Distance from 28.5 HRS")+ylab("Mean Housing Value")
plot2 = ggplot(data=two_mile,aes(x=runbin, y= NPL2000, group=runbin<0))+geom_vline(xintercept=0,color="red")+
geom_line()+geom_point()+geom_smooth(se=F, method=loess)+xlab("Distance from 28.5 HRS")+ylab("Share of Treated")
plot3 = ggplot(data=two_mile,aes(x=runbin, y= Share_Black, group=runbin<0))+geom_vline(xintercept=0,color="red")+
geom_line()+geom_point()+geom_smooth(se=F, method=loess)+xlab("Distance from 28.5 HRS")+ylab("Mean of tract that is Black")
plot4 = ggplot(data=two_mile,aes(x=runbin, y= n, group=runbin<0))+geom_vline(xintercept=0,color="red")+
geom_line()+geom_point()+geom_smooth(se=F, method=loess)+xlab("Distance from 28.5 HRS")+ylab("# of Observations")
plot1
## `geom_smooth()` using formula = 'y ~ x'
plot2
## `geom_smooth()` using formula = 'y ~ x'
plot3
## `geom_smooth()` using formula = 'y ~ x'
plot4
## `geom_smooth()` using formula = 'y ~ x'
##Step 16 There definitely is plausible regression discontinuity, as the second plot shows a big jump at hrs score of 28.5. Although there isn’t much in when it comes to the treatment effect for property value or share of population that is black. ##Step 17
Rd_est <-feols(log(mdvalhs0)~1|0|npl2000~hrsdummy,data=twomile%>%filter(hrs_82%>%between(16.5,40.5)))
Rd_est_fe <-feols(log(mdvalhs0)~1|statefips|npl2000~hrsdummy,data=twomile%>%filter(hrs_82%>%between(16.5,40.5)))
summary(Rd_est)
## TSLS estimation, Dep. Var.: log(mdvalhs0), Endo.: npl2000, Instr.: hrsdummy
## Second stage: Dep. Var.: log(mdvalhs0)
## Observations: 226
## Standard-errors: IID
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 11.55528 0.071503 161.604646 < 2.2e-16 ***
## fit_npl2000 0.05636 0.091011 0.619267 0.53637
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.47634 Adj. R2: -0.006149
## F-test (1st stage), npl2000: stat = 317.5 , p < 2.2e-16 , on 1 and 224 DoF.
## Wu-Hausman: stat = 0.573708, p = 0.449589, on 1 and 223 DoF.
summary(Rd_est_fe)
## TSLS estimation, Dep. Var.: log(mdvalhs0), Endo.: npl2000, Instr.: hrsdummy
## Second stage: Dep. Var.: log(mdvalhs0)
## Observations: 226
## Fixed-effects: statefips: 37
## Standard-errors: Clustered (statefips)
## Estimate Std. Error t value Pr(>|t|)
## fit_npl2000 0.09218 0.072553 1.27051 0.21205
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.364865 Adj. R2: 0.296634
## Within R2: -0.006758
## F-test (1st stage), npl2000: stat = 298.3 , p < 2.2e-16 , on 1 and 224 DoF.
## Wu-Hausman: stat = 1.81925, p = 0.179034, on 1 and 187 DoF.
Without state fixed effects the point estimate is .056 doesnt significantly differ from zero. Now with state fixed affects our point estimate is .092, but the difference is not statistically significant. ##Step 18 I believe the regression from the fuzzy RD is the most credible, although none of the estimates came back too convincing, the estimate from the fuzzy RD most likely has the least of the “bad variation” in X, since we compared observations of tracts most like each other around the discontinuity.