Step 1

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)
library(dplyr)
p_load("matrixStats")
p_load("tidyverse")
p_load("MatchIt")
p_load("fixest")
setwd('C:/Users/mooph/OneDrive/Documents/Grad HW/Metrics Term 3')
library(readr)
data<- read_csv("data-002.csv")
## Rows: 710 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): state, county, gisjoin
## dbl (9): pop_enslaved_1860, pop_total_1860, pop_total_2010, pop_black_2010, ...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Step 2

ggplot(data,aes(x=income_white_2010-income_black_2010,fill=factor(had_rosenwald_school)))+
  xlab("Racial Income Gap")+
  ylab("Counties")+
   geom_histogram(color="#e9ecef", alpha=0.5, position = 'identity')+
  scale_fill_manual(values=c("#69b3a2", "#404080"))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(data,aes(x=pct_pop_enslaved_1860, fill=factor( had_rosenwald_school)))+
  xlab("Percentage of the Population Enslaved in 1860")+
  ylab("Counties")+
   geom_histogram( color="#e9ecef", alpha=0.5, position = 'identity') +
    scale_fill_manual(values=c("#69b3a2", "#404080")) 
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(data,aes(x=pct_pop_enslaved_1860,y=income_white_2010-income_black_2010,fill= factor(had_rosenwald_school)))+
  ylab("County Level Racial Income Gap")+xlab("Percentage of Population Enslaved in 1860")+
  geom_point(aes(color=had_rosenwald_school))

## Step 03

data1 = data%>%mutate(income_gap = income_white_2010-income_black_2010)
fit<-lm(income_gap~had_rosenwald_school, data=data1)
summary(fit)
## 
## Call:
## lm(formula = income_gap ~ had_rosenwald_school, data = data1)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -55160  -4409    911   5719  37520 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           14537.5      802.8  18.107  < 2e-16 ***
## had_rosenwald_school   4323.7      909.7   4.753 2.43e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10060 on 708 degrees of freedom
## Multiple R-squared:  0.03092,    Adjusted R-squared:  0.02955 
## F-statistic: 22.59 on 1 and 708 DF,  p-value: 2.43e-06

The identifying assumptions for this regression to be interpreted as casual is that the treatment is completley uncorrelated with the error terms.
## Step 04

state_FE = feols(income_gap~had_rosenwald_school|state, data=data1)
summary(state_FE)
## OLS estimation, Dep. Var.: income_gap
## Observations: 710 
## Fixed-effects: state: 10
## Standard-errors: Clustered (state) 
##                      Estimate Std. Error t value  Pr(>|t|)    
## had_rosenwald_school  4285.75    1087.03 3.94261 0.0033925 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 9,692.8     Adj. R2: 0.084873
##                 Within R2: 0.029378

The conditional independence assumption required is that treatment of having a rosenwald school in a county is good as random. ## Step 05

state_FE_contr = feols(income_gap~had_rosenwald_school+pct_pop_enslaved_1860+pop_total_1860|state,data=data1)
summary(state_FE_contr)
## OLS estimation, Dep. Var.: income_gap
## Observations: 710 
## Fixed-effects: state: 10
## Standard-errors: Clustered (state) 
##                          Estimate Std. Error t value   Pr(>|t|)    
## had_rosenwald_school  2252.940316 669.074006 3.36725 0.00829310 ** 
## pct_pop_enslaved_1860  129.092412  20.057895 6.43599 0.00012009 ***
## pop_total_1860           0.106201   0.040882 2.59773 0.02884547 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 9,342.2     Adj. R2: 0.147426
##                 Within R2: 0.098312

###Step 06 The change in estimated coefficients from 04 to 05 suggest that excluding the two control variables was causing an omitted variable bias in the estimate for 04. ### Step 07 The conditional independence assumption for 06 is the same as 04, plus that the control variables had an effect on the racial income gap, and the likelihood a county had a rosenwald school, and not the other way around. Any variables that are likely affected by the county racial income gap, and the likelihood a county had a rosenwald school, are bad control variables.

Step 08

I think that using the county’s 2010 population as a control in this regression is not the best idea. The amount of people in a county most likely effects the magnitude of the racial income gap. I.E higher populated counties have highly populated cities where people of color have been affected disproportionally.

Section 2

Step 09

treated_data<-filter(data1, had_rosenwald_school==1)
control_data<-filter(data1, had_rosenwald_school==0)
dist_matr <- mahalanobis_dist(data=data1, had_rosenwald_school~pct_pop_enslaved_1860 +pop_total_1860)
nearest_neighbor_distance <- numeric(nrow(treated_data))
nearest_neighbor_county <- character(nrow(treated_data))
nearest_neighbor_state <- character(nrow(treated_data))

for (i in 1:nrow(treated_data)){

  treated_dist <- dist_matr[i, ]

  untreat_dist <- treated_dist[data1$had_rosenwald_school == 0]

  min_dist <- min(untreat_dist, na.rm = TRUE)

  min_index <- which(untreat_dist == min_dist)

  nearest_neighbor_distance[i] <- min_dist

  nearest_neighbor_county[i] <- data1$county[data1$had_rosenwald_school == 0][min_index]

  nearest_neighbor_state[i] <- data1$state[data1$had_rosenwald_school == 0][min_index]

}

 

nearest_neighbor_data <- data.frame(

  County = treated_data$county,

  State = treated_data$county,

  Distance = nearest_neighbor_distance,

  Nearest_Neighbor_County = nearest_neighbor_county,

  Nearest_Neighbor_State = nearest_neighbor_state

)
nearest_neighbor_data
##               County            State     Distance Nearest_Neighbor_County
## 1            Autauga          Autauga  0.674065846                 Liberty
## 2            Baldwin          Baldwin  0.247529166                 Winston
## 3            Barbour          Barbour  0.925578639                 Liberty
## 4               Bibb             Bibb  0.257273808               Effingham
## 5             Blount           Blount  0.178277167              Washington
## 6             Butler           Butler  0.880234954               Effingham
## 7            Calhoun          Calhoun  1.126665942              Washington
## 8           Chambers         Chambers  0.444055607                 Liberty
## 9           Cherokee         Cherokee  0.779215216              Washington
## 10           Choctaw          Choctaw  0.405548789                 Winston
## 11            Clarke           Clarke  0.533693005                 Winston
## 12            Coffee           Coffee  0.095121001                   Baker
## 13           Conecuh          Conecuh  0.365575168                 Winston
## 14             Coosa            Coosa  0.959867042               Effingham
## 15         Covington        Covington  0.242386509               St. Johns
## 16              Dale             Dale  0.250167771                 Lincoln
## 17            Dallas           Dallas  1.228979999                 Liberty
## 18           Fayette          Fayette  0.238823804              Washington
## 19          Franklin         Franklin  0.790741732                 Liberty
## 20            Greene           Greene  1.028459787                 Liberty
## 21             Henry            Henry  0.488632401               Effingham
## 22           Jackson          Jackson  0.807711744              Washington
## 23         Jefferson        Jefferson  0.245132942                   Jones
## 24        Lauderdale       Lauderdale  0.843283470               Effingham
## 25          Lawrence         Lawrence  0.431430444                 Winston
## 26         Limestone        Limestone  0.555861264                 Winston
## 27           Lowndes          Lowndes  0.606038481                 Liberty
## 28             Macon            Macon  0.482642006                 Liberty
## 29           Madison          Madison  0.439790285                 Liberty
## 30           Marengo          Marengo  1.110304622                 Liberty
## 31            Marion           Marion  0.086901068              Washington
## 32          Marshall         Marshall  0.174510440                 Calhoun
## 33            Mobile           Mobile  2.677309524                 Liberty
## 34            Monroe           Monroe  0.621672149                 Winston
## 35        Montgomery       Montgomery  1.285655393                 Liberty
## 36            Morgan           Morgan  0.247255739               Effingham
## 37             Perry            Perry  0.491871358                 Liberty
## 38           Pickens          Pickens  0.267628870                 Liberty
## 39              Pike             Pike  1.229789332                 Liberty
## 40          Randolph         Randolph  0.948323690              Washington
## 41           Russell          Russell  0.353659954                 Liberty
## 42            Shelby           Shelby  0.253815537               Effingham
## 43            Sumter           Sumter  0.758975241                 Liberty
## 44         Talladega        Talladega  1.119797387                 Liberty
## 45        Tallapoosa       Tallapoosa  1.423496989               Effingham
## 46        Tuscaloosa       Tuscaloosa  0.810664862                 Liberty
## 47            Walker           Walker  0.052924114                  Sumter
## 48        Washington       Washington  0.107474785                Franklin
## 49            Wilcox           Wilcox  0.609188188                 Liberty
## 50           Alachua          Alachua  0.198399221            Hillsborough
## 51           Brevard          Brevard  0.047642136                Cherokee
## 52          Columbia         Columbia  0.359201592                 Fayette
## 53             Duval            Duval  0.126219934                 Fayette
## 54          Escambia         Escambia  0.038286380               Lafayette
## 55           Gadsden          Gadsden  0.121759543                   Irwin
## 56          Hamilton         Hamilton  0.127962207               Lafayette
## 57            Holmes           Holmes  0.022308555                   Butts
## 58           Jackson          Jackson  0.077213260                 Winston
## 59         Jefferson        Jefferson  0.268641023                   Irwin
## 60              Leon             Leon  0.171553552                Hernando
## 61           Madison          Madison  0.163877737            Hillsborough
## 62           Manatee          Manatee  0.391937999                Crawford
## 63            Marion           Marion  0.190258579            Hillsborough
## 64            Nassau           Nassau  0.345822990                Crawford
## 65            Orange           Orange  0.057672841                Haralson
## 66            Putnam           Putnam  0.074721403                Crawford
## 67          Suwannee         Suwannee  0.067667987                Crawford
## 68            Taylor           Taylor  0.068125900                   Butts
## 69           Volusia          Volusia  0.236462470                    Clay
## 70            Walton           Walton  0.108300453                 Calhoun
## 71           Appling          Appling  0.055979759                  DeKalb
## 72           Baldwin          Baldwin  0.235935439            Hillsborough
## 73             Banks            Banks  0.200572247                    Clay
## 74           Berrien          Berrien  0.203985946                 Calhoun
## 75              Bibb             Bibb  0.826227437                 Winston
## 76            Brooks           Brooks  0.314207786                Franklin
## 77             Bryan            Bryan  0.216849037                Franklin
## 78           Bulloch          Bulloch  0.056267839                 Fayette
## 79             Burke            Burke  0.590678072                Hernando
## 80            Camden           Camden  0.315224991                  DeKalb
## 81           Carroll          Carroll  0.233945941                 Calhoun
## 82          Charlton         Charlton  0.306177409                Crawford
## 83           Chatham          Chatham  1.097029069                 Liberty
## 84     Chattahoochee    Chattahoochee  0.420328093                 Winston
## 85         Chattooga        Chattooga  0.317704517               Effingham
## 86            Clarke           Clarke  0.137267329                 Winston
## 87              Clay             Clay  0.421382575                 Fayette
## 88           Clayton          Clayton  0.262540778                    Clay
## 89            Clinch           Clinch  0.109638730                 Calhoun
## 90              Cobb             Cobb  0.441254171               Effingham
## 91            Coffee           Coffee  0.013078932                    Clay
## 92          Colquitt         Colquitt  0.035042079                   Butts
## 93            Coweta           Coweta  0.498776142                 Winston
## 94           Decatur          Decatur  0.206625334                 Winston
## 95             Dooly            Dooly  0.194011672                 Winston
## 96         Dougherty        Dougherty  0.256338228               St. Clair
## 97             Early            Early  0.256183260                  DeKalb
## 98            Elbert           Elbert  0.238105664                   Irwin
## 99           Emanuel          Emanuel  0.251667496                    Clay
## 100            Floyd            Floyd  0.686510656               Effingham
## 101         Franklin         Franklin  0.209783071                   Baker
## 102           Fulton           Fulton  0.454218659                 Calhoun
## 103            Glynn            Glynn  0.203007246                  DeKalb
## 104           Gordon           Gordon  0.093683064                    Levy
## 105         Gwinnett         Gwinnett  0.303311749                 Calhoun
## 106        Habersham        Habersham  0.291980838               St. Johns
## 107             Hall             Hall  0.096638634                 Lincoln
## 108          Hancock          Hancock  0.160685866                Hernando
## 109           Harris           Harris  0.413400502                   Irwin
## 110             Hart             Hart  0.346622676                    Clay
## 111            Heard            Heard  0.228901740                 Fayette
## 112            Henry            Henry  0.382040429                 Winston
## 113          Houston          Houston  0.447197618                Hernando
## 114          Jackson          Jackson  0.170394744               Effingham
## 115           Jasper           Jasper  0.260808919                   Irwin
## 116        Jefferson        Jefferson  0.016535680                   Irwin
## 117          Johnson          Johnson  0.309010645                    Clay
## 118          Laurens          Laurens  0.306699398                 Winston
## 119              Lee              Lee  0.250558601                  DeKalb
## 120          Liberty          Liberty  0.230664648               St. Clair
## 121          Lowndes          Lowndes  0.387935281                 Fayette
## 122            Macon            Macon  0.059828735            Hillsborough
## 123       Meriwether       Meriwether  0.555009372                   Irwin
## 124           Miller           Miller  0.088385276                Crawford
## 125         Mitchell         Mitchell  0.198140289               Lafayette
## 126           Monroe           Monroe  0.585013299                   Irwin
## 127       Montgomery       Montgomery  0.247537713               Lafayette
## 128         Muscogee         Muscogee  0.767416441                 Winston
## 129           Newton           Newton  0.540067892                 Winston
## 130         Paulding         Paulding  0.006291554               St. Johns
## 131           Pierce           Pierce  0.140092158                 Calhoun
## 132             Pike             Pike  0.128304027                 Winston
## 133             Polk             Polk  0.011331816                 Fayette
## 134          Pulaski          Pulaski  0.153031551                 Winston
## 135         Randolph         Randolph  0.131103645                 Winston
## 136         Richmond         Richmond  1.011704533                 Liberty
## 137          Screven          Screven  0.169999291            Hillsborough
## 138         Spalding         Spalding  0.277604519                 Winston
## 139          Stewart          Stewart  0.330184624                   Irwin
## 140           Sumter           Sumter  0.145525211                 Winston
## 141       Taliaferro       Taliaferro  0.355594856                Franklin
## 142         Tattnall         Tattnall  0.224704451                    Clay
## 143           Taylor           Taylor  0.075891619                 Fayette
## 144          Telfair          Telfair  0.296422173               Lafayette
## 145           Thomas           Thomas  0.092455608                   Irwin
## 146            Troup            Troup  0.606434751                   Irwin
## 147           Walker           Walker  0.101774335                 Calhoun
## 148           Walton           Walton  0.420833313                 Winston
## 149             Ware             Ware  0.124388449                 Calhoun
## 150       Washington       Washington  0.289587195                 Winston
## 151            Wayne            Wayne  0.241107315                    Clay
## 152          Webster          Webster  0.386918524                 Fayette
## 153           Wilcox           Wilcox  0.151551921                    Clay
## 154           Wilkes           Wilkes  0.035172442                Hernando
## 155        Wilkinson        Wilkinson  0.334158862                 Fayette
## 156        Ascension        Ascension  0.247727307                   Irwin
## 157        Bienville        Bienville  0.242401754                 Winston
## 158          Bossier          Bossier  0.018446760                Hernando
## 159            Caddo            Caddo  0.185767500                   Irwin
## 160        Calcasieu        Calcasieu  0.238674139                  DeKalb
## 161         Caldwell         Caldwell  0.178014164                 Fayette
## 162        Catahoula        Catahoula  0.216779725                 Winston
## 163        Claiborne        Claiborne  0.759444055                 Winston
## 164        Concordia        Concordia  1.011347865                Hernando
## 165          De Soto          De Soto  0.347664963                   Irwin
## 166 East Baton Rouge East Baton Rouge  0.632794484                 Winston
## 167   East Feliciana   East Feliciana  0.327662805                Hernando
## 168         Franklin         Franklin  0.207572965            Hillsborough
## 169        Iberville        Iberville  0.329286465                Hernando
## 170          Jackson          Jackson  0.297248342                 Winston
## 171        Jefferson        Jefferson  0.560472843               Effingham
## 172        Lafayette        Lafayette  0.097436793                 Winston
## 173       Livingston       Livingston  0.228103315               Lafayette
## 174          Madison          Madison  0.889961350                Hernando
## 175        Morehouse        Morehouse  0.199399264                   Irwin
## 176     Natchitoches     Natchitoches  0.679564216                 Liberty
## 177          Orleans          Orleans 16.403984745                 Liberty
## 178         Ouachita         Ouachita  0.253333162                Franklin
## 179      Plaquemines      Plaquemines  0.269488235            Hillsborough
## 180    Pointe Coupee    Pointe Coupee  0.635450057                Hernando
## 181          Rapides          Rapides  0.206965881                 Liberty
## 182           Sabine           Sabine  0.245905487               Lafayette
## 183           Tensas           Tensas  1.045222199                Hernando
## 184       Terrebonne       Terrebonne  0.269930791                   Irwin
## 185            Union            Union  0.402177250               Effingham
## 186       Washington       Washington  0.127720669               Lafayette
## 187 West Baton Rouge West Baton Rouge  0.259643452                  DeKalb
## 188   West Feliciana   West Feliciana  0.569642397               St. Clair
## 189             Winn             Winn  0.264130376                   Jones
## 190            Adams            Adams  0.691021053                 Liberty
## 191            Amite            Amite  0.280830060                   Irwin
## 192           Attala           Attala  0.506855314               Effingham
## 193          Bolivar          Bolivar  0.806680514               St. Clair
## 194          Carroll          Carroll  0.209609453                 Liberty
## 195        Chickasaw        Chickasaw  0.688214712                 Winston
## 196          Choctaw          Choctaw  0.595969722               Effingham
## 197        Claiborne        Claiborne  0.535858715                Hernando
## 198           Clarke           Clarke  0.154469242                 Winston
## 199          Coahoma          Coahoma  0.356723447                  DeKalb
## 200           Copiah           Copiah  0.560924255                 Winston
## 201        Covington        Covington  0.135879406               Lafayette
## 202         Franklin         Franklin  0.044480280            Hillsborough
## 203           Greene           Greene  0.298364506                Crawford
## 204          Hancock          Hancock  0.218250587                    Clay
## 205         Harrison         Harrison  0.184854523                  DeKalb
## 206            Hinds            Hinds  0.918131788                 Liberty
## 207           Holmes           Holmes  0.699247549                Hernando
## 208        Issaquena        Issaquena  1.109965995                  DeKalb
## 209         Itawamba         Itawamba  0.781565811                 Calhoun
## 210          Jackson          Jackson  0.203699745                    Clay
## 211           Jasper           Jasper  0.437066681                 Winston
## 212        Jefferson        Jefferson  0.595677313                Hernando
## 213            Jones            Jones  0.197366963                 Calhoun
## 214           Kemper           Kemper  0.186200895                 Winston
## 215        Lafayette        Lafayette  0.738650208                 Winston
## 216       Lauderdale       Lauderdale  0.557648712               Effingham
## 217         Lawrence         Lawrence  0.307781236                 Fayette
## 218            Leake            Leake  0.270898319               Effingham
## 219          Lowndes          Lowndes  0.540898298                 Liberty
## 220          Madison          Madison  0.879560155                 Liberty
## 221           Marion           Marion  0.434136171                Franklin
## 222         Marshall         Marshall  0.566076013                 Liberty
## 223           Monroe           Monroe  0.212414724                 Liberty
## 224          Neshoba          Neshoba  0.186950338               Effingham
## 225           Newton           Newton  0.364947800               Effingham
## 226          Noxubee          Noxubee  0.851360543                 Liberty
## 227        Oktibbeha        Oktibbeha  0.283224132                   Irwin
## 228           Panola           Panola  0.359670258                   Irwin
## 229            Perry            Perry  0.276714810                    Clay
## 230             Pike             Pike  0.302015819                 Winston
## 231           Rankin           Rankin  0.386392666                 Winston
## 232            Scott            Scott  0.247848397                 Fayette
## 233          Simpson          Simpson  0.020547500                 Fayette
## 234            Smith            Smith  0.270006594               Effingham
## 235        Sunflower        Sunflower  0.400369316                  DeKalb
## 236     Tallahatchie     Tallahatchie  0.308032209            Hillsborough
## 237           Tunica           Tunica  0.503924794                  DeKalb
## 238           Warren           Warren  0.466474929                 Liberty
## 239       Washington       Washington  1.104227889                Hernando
## 240            Wayne            Wayne  0.110431749                Franklin
## 241        Wilkinson        Wilkinson  0.689074293                Hernando
## 242          Winston          Winston  0.313320604                 Winston
## 243        Yalobusha        Yalobusha  0.655268737                 Liberty
## 244            Yazoo            Yazoo  0.766431759                 Liberty
## 245         Alamance         Alamance  0.176799310               Effingham
## 246        Alexander        Alexander  0.157384138               St. Johns
## 247            Anson            Anson  0.383603151                 Winston
## 248         Beaufort         Beaufort  0.691927037               Effingham
## 249           Bertie           Bertie  0.448996871                   Irwin
## 250           Bladen           Bladen  0.357451924                 Winston
## 251        Brunswick        Brunswick  0.293181729                 Fayette
## 252         Buncombe         Buncombe  0.298560168                 Lincoln
## 253            Burke            Burke  0.133582315               Effingham
## 254         Cabarrus         Cabarrus  0.055230994               Effingham
## 255           Camden           Camden  0.117623664                 Fayette
## 256         Carteret         Carteret  0.169527791                   Jones
## 257          Caswell          Caswell  0.634538417                   Irwin
## 258          Catawba          Catawba  0.121904966                 Calhoun
## 259          Chatham          Chatham  0.918262999               Effingham
## 260         Cherokee         Cherokee  0.082833077              Santa Rosa
## 261           Chowan           Chowan  0.197041926            Hillsborough
## 262        Cleveland        Cleveland  0.239148659                 Calhoun
## 263         Columbus         Columbus  0.170157052               Effingham
## 264           Craven           Craven  0.736576312               Effingham
## 265       Cumberland       Cumberland  0.689230729               Effingham
## 266        Currituck        Currituck  0.209231211               Lafayette
## 267         Davidson         Davidson  0.665288349              Washington
## 268            Davie            Davie  0.173074486               Effingham
## 269           Duplin           Duplin  0.682211832                 Winston
## 270        Edgecombe        Edgecombe  0.609587547                 Liberty
## 271          Forsyth          Forsyth  0.249621022              Washington
## 272         Franklin         Franklin  0.430666434                 Winston
## 273           Gaston           Gaston  0.076930627                   Jones
## 274            Gates            Gates  0.197123888                 Winston
## 275           Greene           Greene  0.212285469                 Winston
## 276         Guilford         Guilford  0.960367316              Washington
## 277          Halifax          Halifax  0.475757221                 Liberty
## 278          Harnett          Harnett  0.306601088               Lafayette
## 279          Haywood          Haywood  0.164100675                Glascock
## 280        Henderson        Henderson  0.070544309                 Lincoln
## 281         Hertford         Hertford  0.127204242                 Winston
## 282             Hyde             Hyde  0.219729197                 Fayette
## 283          Iredell          Iredell  0.550044182               Effingham
## 284          Jackson          Jackson  0.140719048                Glascock
## 285         Johnston         Johnston  0.567850256               Effingham
## 286            Jones            Jones  0.257019286            Hillsborough
## 287           Lenoir           Lenoir  0.053103044                 Winston
## 288          Lincoln          Lincoln  0.210224984               Effingham
## 289            Macon            Macon  0.116026154               St. Johns
## 290          Madison          Madison  0.164006898                 Lumpkin
## 291           Martin           Martin  0.360812171                 Winston
## 292         McDowell         McDowell  0.245077644                    Levy
## 293      Mecklenburg      Mecklenburg  0.816463271               Effingham
## 294       Montgomery       Montgomery  0.211560222                   Jones
## 295            Moore            Moore  0.215898368                   Jones
## 296             Nash             Nash  0.532009126                 Winston
## 297      New Hanover      New Hanover  0.611550504                 Liberty
## 298      Northampton      Northampton  0.353907459                 Winston
## 299           Onslow           Onslow  0.270824924                 Fayette
## 300           Orange           Orange  0.696292385               Effingham
## 301       Pasquotank       Pasquotank  0.319313829               Effingham
## 302       Perquimans       Perquimans  0.276470822                 Winston
## 303           Person           Person  0.222233351                 Winston
## 304             Pitt             Pitt  0.632347227                 Winston
## 305             Polk             Polk  0.136845993                  DeKalb
## 306         Randolph         Randolph  0.605733864              Washington
## 307         Richmond         Richmond  0.112821360                 Winston
## 308          Robeson          Robeson  0.605888815               Effingham
## 309       Rockingham       Rockingham  0.766359568               Effingham
## 310            Rowan            Rowan  0.475256167               Effingham
## 311       Rutherford       Rutherford  0.210884480                 Calhoun
## 312          Sampson          Sampson  0.839587741                 Winston
## 313           Stanly           Stanly  0.135669499                   Baker
## 314           Stokes           Stokes  0.122750321                   Jones
## 315            Surry            Surry  0.049220334                 Lincoln
## 316          Tyrrell          Tyrrell  0.092002137               Lafayette
## 317            Union            Union  0.167301344                 Calhoun
## 318             Wake             Wake  1.342504738                 Liberty
## 319           Warren           Warren  0.522245571                Hernando
## 320       Washington       Washington  0.016673275                 Fayette
## 321            Wayne            Wayne  0.594109761               Effingham
## 322           Wilkes           Wilkes  0.415035349              Washington
## 323           Wilson           Wilson  0.410972985                 Fayette
## 324           Yadkin           Yadkin  0.094827041                 Lincoln
## 325        Abbeville        Abbeville  0.924629911                 Liberty
## 326         Anderson         Anderson  1.151061054                 Liberty
## 327         Barnwell         Barnwell  0.818342971                 Liberty
## 328         Beaufort         Beaufort  1.862616484                 Liberty
## 329       Charleston       Charleston  4.938237210                 Liberty
## 330          Chester          Chester  0.542620829                 Liberty
## 331     Chesterfield     Chesterfield  0.443429571               Effingham
## 332        Clarendon        Clarendon  0.323015091                Hernando
## 333         Colleton         Colleton  1.962891854                 Liberty
## 334       Darlington       Darlington  0.304827257                 Liberty
## 335        Edgefield        Edgefield  1.717960741                 Liberty
## 336        Fairfield        Fairfield  0.555684969                 Liberty
## 337       Georgetown       Georgetown  1.140197960                Hernando
## 338       Greenville       Greenville  1.201296651               Effingham
## 339            Horry            Horry  0.255599620               Effingham
## 340          Kershaw          Kershaw  0.283353507                   Irwin
## 341        Lancaster        Lancaster  0.221204451                 Winston
## 342          Laurens          Laurens  0.247247052                 Liberty
## 343        Lexington        Lexington  0.740725096               Effingham
## 344           Marion           Marion  0.647579342                 Liberty
## 345         Marlboro         Marlboro  0.323669509                   Irwin
## 346         Newberry         Newberry  0.415782440                 Liberty
## 347       Orangeburg       Orangeburg  0.343607929                 Liberty
## 348          Pickens          Pickens  0.979183823              Washington
## 349         Richland         Richland  0.524782285                 Liberty
## 350      Spartanburg      Spartanburg  1.583820896                 Liberty
## 351           Sumter           Sumter  0.493510136                 Liberty
## 352            Union            Union  0.416835129                 Liberty
## 353     Williamsburg     Williamsburg  0.496978521                Hernando
## 354             York             York  0.668669791                 Liberty
## 355          Bedford          Bedford  1.171122210               Effingham
## 356          Bledsoe          Bledsoe  0.156553383                  DeKalb
## 357           Blount           Blount  0.236434632              Washington
## 358          Bradley          Bradley  0.075518214              Washington
## 359          Carroll          Carroll  0.772029700                 Calhoun
## 360         Cheatham         Cheatham  0.297553418               Effingham
## 361        Claiborne        Claiborne  0.129432193                  Sumter
## 362            Cocke            Cocke  0.088023982              Washington
## 363           Coffee           Coffee  0.066226901                   Baker
## 364         Davidson         Davidson  3.073990609                 Liberty
## 365          Decatur          Decatur  0.242204228               St. Johns
## 366          Dickson          Dickson  0.065521125                   Jones
## 367             Dyer             Dyer  0.157815601               Effingham
## 368          Fayette          Fayette  0.193340549                 Liberty
## 369         Franklin         Franklin  0.423263837               Effingham
## 370           Gibson           Gibson  1.208487454               Effingham
## 371            Giles            Giles  1.023748542                 Liberty
## 372         Hamilton         Hamilton  0.234651677              Washington
## 373         Hardeman         Hardeman  0.922398684               Effingham
## 374           Hardin           Hardin  0.161682780                 Lincoln
## 375          Hawkins          Hawkins  0.531401429              Washington
## 376          Haywood          Haywood  0.422426186                 Liberty
## 377        Henderson        Henderson  0.490465228                 Calhoun
## 378            Henry            Henry  0.928022647               Effingham
## 379          Hickman          Hickman  0.024456710                    Levy
## 380        Jefferson        Jefferson  0.523771489              Washington
## 381             Knox             Knox  1.226743457              Washington
## 382       Lauderdale       Lauderdale  0.154152719                 Fayette
## 383         Lawrence         Lawrence  0.067474888                 Lincoln
## 384            Lewis            Lewis  0.179641131                   Butts
## 385          Lincoln          Lincoln  1.304815226               Effingham
## 386          Madison          Madison  0.665510382                 Liberty
## 387         Marshall         Marshall  0.458204333               Effingham
## 388            Maury            Maury  1.314509399                 Liberty
## 389           McMinn           McMinn  0.314125730              Washington
## 390          McNairy          McNairy  0.394774052              Washington
## 391            Meigs            Meigs  0.249122841                  DeKalb
## 392           Monroe           Monroe  0.204988241              Washington
## 393       Montgomery       Montgomery  0.710844975                 Liberty
## 394            Obion            Obion  0.283762326                 Calhoun
## 395           Putnam           Putnam  0.081977867                  Sumter
## 396             Rhea             Rhea  0.295500377                 Forsyth
## 397        Robertson        Robertson  0.532737240               Effingham
## 398       Rutherford       Rutherford  0.895006084                 Liberty
## 399           Sevier           Sevier  0.075196292                  Sumter
## 400           Shelby           Shelby  3.058606292                 Liberty
## 401            Smith            Smith  0.674732031               Effingham
## 402         Sullivan         Sullivan  0.299457206              Washington
## 403           Sumner           Sumner  1.221230682               Effingham
## 404           Tipton           Tipton  0.082077511                 Winston
## 405           Warren           Warren  0.174264578                    Levy
## 406       Washington       Washington  0.462542801              Washington
## 407            Wayne            Wayne  0.108846110                   Baker
## 408          Weakley          Weakley  0.845812459                 Calhoun
## 409            White            White  0.057058167                 Lincoln
## 410       Williamson       Williamson  0.415643208                 Liberty
## 411           Wilson           Wilson  1.553057719                 Liberty
## 412         Anderson         Anderson  0.363441173               Effingham
## 413         Angelina         Angelina  0.117330800                  DeKalb
## 414           Austin           Austin  0.408956314                 Fayette
## 415          Bastrop          Bastrop  0.126292709                 Fayette
## 416              Bee              Bee  0.020537700                Cherokee
## 417            Bowie            Bowie  0.174717979                Franklin
## 418         Brazoria         Brazoria  0.279708914                  DeKalb
## 419           Brazos           Brazos  0.202913184                Crawford
## 420         Burleson         Burleson  0.061282283               Lafayette
## 421         Caldwell         Caldwell  0.146569920               Lafayette
## 422          Calhoun          Calhoun  0.076725328                 Calhoun
## 423         Cherokee         Cherokee  0.221527215               Effingham
## 424         Colorado         Colorado  0.268261108                 Winston
## 425            Ellis            Ellis  0.209658714                  DeKalb
## 426            Falls            Falls  0.369009334                Franklin
## 427           Fannin           Fannin  0.035783543                    Levy
## 428          Fayette          Fayette  0.254909934               Effingham
## 429        Fort Bend        Fort Bend  0.204165888                  DeKalb
## 430        Freestone        Freestone  0.273649364            Hillsborough
## 431        Galveston        Galveston  0.132025499                    Levy
## 432         Gonzales         Gonzales  0.189335101                 Fayette
## 433          Grayson          Grayson  0.093228494                   Baker
## 434           Grimes           Grimes  0.183818254                 Winston
## 435        Guadalupe        Guadalupe  0.098444282               Lafayette
## 436           Hardin           Hardin  0.067736693                 Calhoun
## 437           Harris           Harris  0.043226627                   Jones
## 438         Harrison         Harrison  0.496237047                   Irwin
## 439        Henderson        Henderson  0.190492805                    Clay
## 440          Hopkins          Hopkins  0.196173152                   Baker
## 441          Houston          Houston  0.271019587               Lafayette
## 442             Hunt             Hunt  0.054617832               St. Johns
## 443          Jackson          Jackson  0.406186383                Crawford
## 444           Jasper           Jasper  0.212625936                Crawford
## 445        Jefferson        Jefferson  0.044116801                 Calhoun
## 446          Johnson          Johnson  0.244004767                 Forsyth
## 447          Kaufman          Kaufman  0.217400996                 Calhoun
## 448           Lavaca           Lavaca  0.283846961               Lafayette
## 449             Leon             Leon  0.059419463                 Fayette
## 450          Liberty          Liberty  0.228784411               Lafayette
## 451        Limestone        Limestone  0.181294420                    Clay
## 452          Madison          Madison  0.350261094               Lafayette
## 453           Marion           Marion  0.210996281                Franklin
## 454        Matagorda        Matagorda  0.321741466                Franklin
## 455            Milam            Milam  0.210441555               Lafayette
## 456       Montgomery       Montgomery  0.254612057                Franklin
## 457      Nacogdoches      Nacogdoches  0.198005353               Effingham
## 458          Navarro          Navarro  0.151123630               Lafayette
## 459           Newton           Newton  0.236235105               Lafayette
## 460           Panola           Panola  0.287468956                 Fayette
## 461             Polk             Polk  0.189574576                 Winston
## 462        Red River        Red River  0.307677123                 Fayette
## 463          Refugio          Refugio  0.042235403                 Calhoun
## 464        Robertson        Robertson  0.375290777                 Fayette
## 465             Rusk             Rusk  0.723853024               Effingham
## 466    San Augustine    San Augustine  0.273289938                Crawford
## 467           Shelby           Shelby  0.322481869                    Clay
## 468            Smith            Smith  0.520941582               Effingham
## 469          Tarrant          Tarrant  0.316682303                   Baker
## 470            Titus            Titus  0.134569673               Effingham
## 471           Travis           Travis  0.193153524                 Fayette
## 472          Trinity          Trinity  0.186331380                    Clay
## 473            Tyler            Tyler  0.201732795                    Clay
## 474           Upshur           Upshur  0.379553067               Effingham
## 475        Van Zandt        Van Zandt  0.096722980                 Forsyth
## 476           Walker           Walker  0.198053063                 Winston
## 477       Washington       Washington  0.543586137                 Winston
## 478          Wharton          Wharton  0.597821140                  DeKalb
## 479       Williamson       Williamson  0.118251857                  DeKalb
## 480             Wood             Wood  0.165516518                  DeKalb
## 481         Accomack         Accomack  0.892057355                 Calhoun
## 482        Albemarle        Albemarle  0.560629383                 Liberty
## 483           Amelia           Amelia  0.068359243               St. Clair
## 484          Amherst          Amherst  0.468370333                 Winston
## 485       Appomattox       Appomattox  0.175815831                 Winston
## 486          Augusta          Augusta  1.727081492              Washington
## 487             Bath             Bath  0.156602408                    Clay
## 488          Bedford          Bedford  1.019589940                 Liberty
## 489        Botetourt        Botetourt  0.227100008                   Jones
## 490        Brunswick        Brunswick  0.458794078                   Irwin
## 491       Buckingham       Buckingham  0.527553011                   Irwin
## 492         Campbell         Campbell  0.894083594                 Liberty
## 493         Caroline         Caroline  0.497969270                 Liberty
## 494          Carroll          Carroll  0.073649944              Santa Rosa
## 495     Charles City     Charles City  0.217540701                Franklin
## 496        Charlotte        Charlotte  0.445911568                   Irwin
## 497     Chesterfield     Chesterfield  0.843740585                 Liberty
## 498           Clarke           Clarke  0.287055330                 Winston
## 499         Culpeper         Culpeper  0.298131961                   Irwin
## 500       Cumberland       Cumberland  0.157557832               St. Clair
## 501        Dinwiddie        Dinwiddie  1.236207967                 Liberty
## 502            Essex            Essex  0.224482261                   Irwin
## 503          Fairfax          Fairfax  0.207716894               Effingham
## 504         Fauquier         Fauquier  0.583158547                 Liberty
## 505            Floyd            Floyd  0.032526797                  Sumter
## 506         Fluvanna         Fluvanna  0.077677093                 Winston
## 507         Franklin         Franklin  1.017946722               Effingham
## 508        Frederick        Frederick  0.577465818              Washington
## 509       Gloucester       Gloucester  0.169638750                 Winston
## 510        Goochland        Goochland  0.103726686                   Irwin
## 511          Grayson          Grayson  0.029474036                  Sumter
## 512      Greensville      Greensville  0.297564482                  DeKalb
## 513          Halifax          Halifax  0.410745041                 Liberty
## 514          Hanover          Hanover  0.637241601                 Liberty
## 515          Henrico          Henrico  4.448471593                 Liberty
## 516            Henry            Henry  0.491617516                 Winston
## 517       James City       James City  0.312233592                 Fayette
## 518      King George      King George  0.158142330            Hillsborough
## 519     King William     King William  0.303765119               St. Clair
## 520        Lancaster        Lancaster  0.111049984                Franklin
## 521           Louisa           Louisa  0.652640026                   Irwin
## 522        Lunenburg        Lunenburg  0.174772466                   Irwin
## 523          Mathews          Mathews  0.196862918                 Fayette
## 524      Mecklenburg      Mecklenburg  0.366210295                 Liberty
## 525        Middlesex        Middlesex  0.043732280                Franklin
## 526       Montgomery       Montgomery  0.130407283                    Levy
## 527         New Kent         New Kent  0.203178241                Franklin
## 528      Northampton      Northampton  0.217274006                 Winston
## 529   Northumberland   Northumberland  0.279206211                 Winston
## 530         Nottoway         Nottoway  0.207692307               St. Clair
## 531           Orange           Orange  0.175187334                   Irwin
## 532             Page             Page  0.140527794               St. Johns
## 533     Pittsylvania     Pittsylvania  1.295978149                 Liberty
## 534         Powhatan         Powhatan  0.318176735            Hillsborough
## 535    Prince Edward    Prince Edward  0.183294913                   Irwin
## 536    Prince George    Prince George  0.081348406            Hillsborough
## 537   Prince William   Prince William  0.160736516               Effingham
## 538          Pulaski          Pulaski  0.236781256               Lafayette
## 539     Rappahannock     Rappahannock  0.270274325                 Fayette
## 540         Richmond         Richmond  0.158789064                 Fayette
## 541          Roanoke          Roanoke  0.292362340               Lafayette
## 542       Rockbridge       Rockbridge  0.751792673                 Calhoun
## 543       Rockingham       Rockingham  1.290192449              Washington
## 544            Scott            Scott  0.325726705              Washington
## 545            Smyth            Smyth  0.099225177                 Lincoln
## 546      Southampton      Southampton  0.530124023                 Winston
## 547     Spotsylvania     Spotsylvania  0.651156008                 Winston
## 548         Stafford         Stafford  0.243055232                 Fayette
## 549           Sussex           Sussex  0.169336774                   Irwin
## 550       Washington       Washington  0.625134133              Washington
## 551     Westmoreland     Westmoreland  0.259495419                 Winston
## 552            Wythe            Wythe  0.232322018                 Calhoun
## 553             York             York  0.134441261                 Fayette
##     Nearest_Neighbor_State
## 1                  Florida
## 2                  Alabama
## 3                  Florida
## 4                  Georgia
## 5                  Florida
## 6                  Georgia
## 7                  Florida
## 8                  Florida
## 9                  Florida
## 10                 Alabama
## 11                 Alabama
## 12                 Georgia
## 13                 Alabama
## 14                 Georgia
## 15                 Florida
## 16                 Georgia
## 17                 Florida
## 18                 Florida
## 19                 Florida
## 20                 Florida
## 21                 Georgia
## 22                 Florida
## 23                 Georgia
## 24                 Georgia
## 25                 Alabama
## 26                 Alabama
## 27                 Florida
## 28                 Florida
## 29                 Florida
## 30                 Florida
## 31                 Florida
## 32                 Florida
## 33                 Florida
## 34                 Alabama
## 35                 Florida
## 36                 Georgia
## 37                 Florida
## 38                 Florida
## 39                 Florida
## 40                 Florida
## 41                 Florida
## 42                 Georgia
## 43                 Florida
## 44                 Florida
## 45                 Georgia
## 46                 Florida
## 47                 Florida
## 48                 Florida
## 49                 Florida
## 50                 Florida
## 51                 Georgia
## 52                 Georgia
## 53                 Georgia
## 54                 Florida
## 55                 Georgia
## 56                 Florida
## 57                 Georgia
## 58                 Alabama
## 59                 Georgia
## 60                 Florida
## 61                 Florida
## 62                 Georgia
## 63                 Florida
## 64                 Georgia
## 65                 Georgia
## 66                 Georgia
## 67                 Georgia
## 68                 Georgia
## 69                 Florida
## 70                 Georgia
## 71                 Georgia
## 72                 Florida
## 73                 Florida
## 74                 Georgia
## 75                 Alabama
## 76                 Florida
## 77                 Florida
## 78                 Georgia
## 79                 Florida
## 80                 Alabama
## 81                 Florida
## 82                 Georgia
## 83                 Florida
## 84                 Alabama
## 85                 Georgia
## 86                 Alabama
## 87                 Georgia
## 88                 Florida
## 89                 Georgia
## 90                 Georgia
## 91                 Florida
## 92                 Georgia
## 93                 Alabama
## 94                 Alabama
## 95                 Alabama
## 96                 Alabama
## 97                 Alabama
## 98                 Georgia
## 99                 Florida
## 100                Georgia
## 101                Georgia
## 102                Florida
## 103                Alabama
## 104                Florida
## 105                Florida
## 106                Florida
## 107                Georgia
## 108                Florida
## 109                Georgia
## 110                Florida
## 111                Georgia
## 112                Alabama
## 113                Florida
## 114                Georgia
## 115                Georgia
## 116                Georgia
## 117                Florida
## 118                Alabama
## 119                Alabama
## 120                Alabama
## 121                Georgia
## 122                Florida
## 123                Georgia
## 124                Georgia
## 125                Florida
## 126                Georgia
## 127                Florida
## 128                Alabama
## 129                Alabama
## 130                Florida
## 131                Georgia
## 132                Alabama
## 133                Georgia
## 134                Alabama
## 135                Alabama
## 136                Florida
## 137                Florida
## 138                Alabama
## 139                Georgia
## 140                Alabama
## 141                Florida
## 142                Florida
## 143                Georgia
## 144                Florida
## 145                Georgia
## 146                Georgia
## 147                Florida
## 148                Alabama
## 149                Georgia
## 150                Alabama
## 151                Florida
## 152                Georgia
## 153                Florida
## 154                Florida
## 155                Georgia
## 156                Georgia
## 157                Alabama
## 158                Florida
## 159                Georgia
## 160                Georgia
## 161                Georgia
## 162                Alabama
## 163                Alabama
## 164                Florida
## 165                Georgia
## 166                Alabama
## 167                Florida
## 168                Florida
## 169                Florida
## 170                Alabama
## 171                Georgia
## 172                Alabama
## 173                Florida
## 174                Florida
## 175                Georgia
## 176                Florida
## 177                Florida
## 178                Florida
## 179                Florida
## 180                Florida
## 181                Florida
## 182                Florida
## 183                Florida
## 184                Georgia
## 185                Georgia
## 186                Florida
## 187                Alabama
## 188                Alabama
## 189                Georgia
## 190                Florida
## 191                Georgia
## 192                Georgia
## 193                Alabama
## 194                Florida
## 195                Alabama
## 196                Georgia
## 197                Florida
## 198                Alabama
## 199                Alabama
## 200                Alabama
## 201                Florida
## 202                Florida
## 203                Georgia
## 204                Florida
## 205                Georgia
## 206                Florida
## 207                Florida
## 208                Alabama
## 209                Florida
## 210                Florida
## 211                Alabama
## 212                Florida
## 213                Georgia
## 214                Alabama
## 215                Alabama
## 216                Georgia
## 217                Georgia
## 218                Georgia
## 219                Florida
## 220                Florida
## 221                Florida
## 222                Florida
## 223                Florida
## 224                Georgia
## 225                Georgia
## 226                Florida
## 227                Georgia
## 228                Georgia
## 229                Florida
## 230                Alabama
## 231                Alabama
## 232                Georgia
## 233                Georgia
## 234                Georgia
## 235                Alabama
## 236                Florida
## 237                Alabama
## 238                Florida
## 239                Florida
## 240                Florida
## 241                Florida
## 242                Alabama
## 243                Florida
## 244                Florida
## 245                Georgia
## 246                Florida
## 247                Alabama
## 248                Georgia
## 249                Georgia
## 250                Alabama
## 251                Georgia
## 252                Georgia
## 253                Georgia
## 254                Georgia
## 255                Georgia
## 256                Georgia
## 257                Georgia
## 258                Florida
## 259                Georgia
## 260                Florida
## 261                Florida
## 262                Florida
## 263                Georgia
## 264                Georgia
## 265                Georgia
## 266                Florida
## 267                Florida
## 268                Georgia
## 269                Alabama
## 270                Florida
## 271                Florida
## 272                Alabama
## 273                Georgia
## 274                Alabama
## 275                Alabama
## 276                Florida
## 277                Florida
## 278                Florida
## 279                Georgia
## 280                Georgia
## 281                Alabama
## 282                Georgia
## 283                Georgia
## 284                Georgia
## 285                Georgia
## 286                Florida
## 287                Alabama
## 288                Georgia
## 289                Florida
## 290                Georgia
## 291                Alabama
## 292                Florida
## 293                Georgia
## 294                Georgia
## 295                Georgia
## 296                Alabama
## 297                Florida
## 298                Alabama
## 299                Georgia
## 300                Georgia
## 301                Georgia
## 302                Alabama
## 303                Alabama
## 304                Alabama
## 305                Georgia
## 306                Florida
## 307                Alabama
## 308                Georgia
## 309                Georgia
## 310                Georgia
## 311                Florida
## 312                Alabama
## 313                Georgia
## 314                Georgia
## 315                Georgia
## 316                Florida
## 317                Florida
## 318                Florida
## 319                Florida
## 320                Georgia
## 321                Georgia
## 322                Florida
## 323                Georgia
## 324                Georgia
## 325                Florida
## 326                Florida
## 327                Florida
## 328                Florida
## 329                Florida
## 330                Florida
## 331                Georgia
## 332                Florida
## 333                Florida
## 334                Florida
## 335                Florida
## 336                Florida
## 337                Florida
## 338                Georgia
## 339                Georgia
## 340                Georgia
## 341                Alabama
## 342                Florida
## 343                Georgia
## 344                Florida
## 345                Georgia
## 346                Florida
## 347                Florida
## 348                Florida
## 349                Florida
## 350                Florida
## 351                Florida
## 352                Florida
## 353                Florida
## 354                Florida
## 355                Georgia
## 356                Georgia
## 357                Florida
## 358                Florida
## 359                Florida
## 360                Georgia
## 361                Florida
## 362                Florida
## 363                Georgia
## 364                Florida
## 365                Florida
## 366                Georgia
## 367                Georgia
## 368                Florida
## 369                Georgia
## 370                Georgia
## 371                Florida
## 372                Florida
## 373                Georgia
## 374                Georgia
## 375                Florida
## 376                Florida
## 377                Florida
## 378                Georgia
## 379                Florida
## 380                Florida
## 381                Florida
## 382                Georgia
## 383                Georgia
## 384                Georgia
## 385                Georgia
## 386                Florida
## 387                Georgia
## 388                Florida
## 389                Florida
## 390                Florida
## 391                Georgia
## 392                Florida
## 393                Florida
## 394                Florida
## 395                Florida
## 396                Georgia
## 397                Georgia
## 398                Florida
## 399                Florida
## 400                Florida
## 401                Georgia
## 402                Florida
## 403                Georgia
## 404                Alabama
## 405                Florida
## 406                Florida
## 407                Georgia
## 408                Florida
## 409                Georgia
## 410                Florida
## 411                Florida
## 412                Georgia
## 413                Georgia
## 414                Georgia
## 415                Georgia
## 416                Georgia
## 417                Florida
## 418                Alabama
## 419                Georgia
## 420                Florida
## 421                Florida
## 422                Georgia
## 423                Georgia
## 424                Alabama
## 425                Georgia
## 426                Florida
## 427                Florida
## 428                Georgia
## 429                Alabama
## 430                Florida
## 431                Florida
## 432                Georgia
## 433                Georgia
## 434                Alabama
## 435                Florida
## 436                Georgia
## 437                Georgia
## 438                Georgia
## 439                Florida
## 440                Georgia
## 441                Florida
## 442                Florida
## 443                Georgia
## 444                Georgia
## 445                Georgia
## 446                Georgia
## 447                Georgia
## 448                Florida
## 449                Georgia
## 450                Florida
## 451                Florida
## 452                Florida
## 453                Florida
## 454                Florida
## 455                Florida
## 456                Florida
## 457                Georgia
## 458                Florida
## 459                Florida
## 460                Georgia
## 461                Alabama
## 462                Georgia
## 463                Georgia
## 464                Georgia
## 465                Georgia
## 466                Georgia
## 467                Florida
## 468                Georgia
## 469                Georgia
## 470                Georgia
## 471                Georgia
## 472                Florida
## 473                Florida
## 474                Georgia
## 475                Georgia
## 476                Alabama
## 477                Alabama
## 478                Alabama
## 479                Georgia
## 480                Georgia
## 481                Florida
## 482                Florida
## 483                Alabama
## 484                Alabama
## 485                Alabama
## 486                Florida
## 487                Florida
## 488                Florida
## 489                Georgia
## 490                Georgia
## 491                Georgia
## 492                Florida
## 493                Florida
## 494                Florida
## 495                Florida
## 496                Georgia
## 497                Florida
## 498                Alabama
## 499                Georgia
## 500                Alabama
## 501                Florida
## 502                Georgia
## 503                Georgia
## 504                Florida
## 505                Florida
## 506                Alabama
## 507                Georgia
## 508                Florida
## 509                Alabama
## 510                Georgia
## 511                Florida
## 512                Alabama
## 513                Florida
## 514                Florida
## 515                Florida
## 516                Alabama
## 517                Georgia
## 518                Florida
## 519                Alabama
## 520                Florida
## 521                Georgia
## 522                Georgia
## 523                Georgia
## 524                Florida
## 525                Florida
## 526                Florida
## 527                Florida
## 528                Alabama
## 529                Alabama
## 530                Alabama
## 531                Georgia
## 532                Florida
## 533                Florida
## 534                Florida
## 535                Georgia
## 536                Florida
## 537                Georgia
## 538                Florida
## 539                Georgia
## 540                Georgia
## 541                Florida
## 542                Florida
## 543                Florida
## 544                Florida
## 545                Georgia
## 546                Alabama
## 547                Alabama
## 548                Georgia
## 549                Georgia
## 550                Florida
## 551                Alabama
## 552                Florida
## 553                Georgia

Step 10

treatment_effect <- numeric(nrow(treated_data))

 

for(i in 1:nrow(treated_data)){

  treated_county <- treated_data$county[i]

  treated_state <- treated_data$state[i]

  near_control_county <- nearest_neighbor_data$Nearest_Neighbor_County[i]

  near_control_state <- nearest_neighbor_data$Nearest_Neighbor_State[i]

  treat <- data1$income_gap[data1$county == treated_county & data1$state == treated_state]

  control <- data1$income_gap[data1$county == near_control_county & data1$state == near_control_state]

 

  treatment_effect[i] <- treat - control

}

 

treatment_effect_df<- data.frame(

  County = treated_data$county,

  State = treated_data$state,

  Treatment_Effect = treatment_effect

)

print(treatment_effect_df)
##               County          State Treatment_Effect
## 1            Autauga        Alabama            18240
## 2            Baldwin        Alabama            -7891
## 3            Barbour        Alabama             9199
## 4               Bibb        Alabama            -6364
## 5             Blount        Alabama            13631
## 6             Butler        Alabama           -12192
## 7            Calhoun        Alabama             9189
## 8           Chambers        Alabama             2503
## 9           Cherokee        Alabama            10304
## 10           Choctaw        Alabama           -11720
## 11            Clarke        Alabama            -3994
## 12            Coffee        Alabama            14318
## 13           Conecuh        Alabama            -8833
## 14             Coosa        Alabama           -14959
## 15         Covington        Alabama           -12545
## 16              Dale        Alabama             -852
## 17            Dallas        Alabama            12919
## 18           Fayette        Alabama             4738
## 19          Franklin        Alabama             3147
## 20            Greene        Alabama            15959
## 21             Henry        Alabama            -9350
## 22           Jackson        Alabama            -2999
## 23         Jefferson        Alabama            15676
## 24        Lauderdale        Alabama            -5184
## 25          Lawrence        Alabama           -24442
## 26         Limestone        Alabama           -17431
## 27           Lowndes        Alabama            15864
## 28             Macon        Alabama             5007
## 29           Madison        Alabama            16190
## 30           Marengo        Alabama            15763
## 31            Marion        Alabama            -2902
## 32          Marshall        Alabama             8848
## 33            Mobile        Alabama            10356
## 34            Monroe        Alabama            -7426
## 35        Montgomery        Alabama            16034
## 36            Morgan        Alabama            -5943
## 37             Perry        Alabama             5988
## 38           Pickens        Alabama            13619
## 39              Pike        Alabama             6872
## 40          Randolph        Alabama             2267
## 41           Russell        Alabama              315
## 42            Shelby        Alabama            -7051
## 43            Sumter        Alabama             9624
## 44         Talladega        Alabama             3857
## 45        Tallapoosa        Alabama            -7459
## 46        Tuscaloosa        Alabama             7978
## 47            Walker        Alabama             7029
## 48        Washington        Alabama            11342
## 49            Wilcox        Alabama            16900
## 50           Alachua        Florida             -541
## 51           Brevard        Florida             1441
## 52          Columbia        Florida            10826
## 53             Duval        Florida            17415
## 54          Escambia        Florida            -6270
## 55           Gadsden        Florida             5429
## 56          Hamilton        Florida            -3201
## 57            Holmes        Florida             1377
## 58           Jackson        Florida           -14925
## 59         Jefferson        Florida             3769
## 60              Leon        Florida            18558
## 61           Madison        Florida            -1775
## 62           Manatee        Florida             -817
## 63            Marion        Florida            -9748
## 64            Nassau        Florida             -934
## 65            Orange        Florida             2391
## 66            Putnam        Florida            -4439
## 67          Suwannee        Florida             -142
## 68            Taylor        Florida             -279
## 69           Volusia        Florida             4119
## 70            Walton        Florida            11150
## 71           Appling        Georgia           -14074
## 72           Baldwin        Georgia              -11
## 73             Banks        Georgia           -17046
## 74           Berrien        Georgia            -3747
## 75              Bibb        Georgia            -4200
## 76            Brooks        Georgia             8494
## 77             Bryan        Georgia             9360
## 78           Bulloch        Georgia            17300
## 79             Burke        Georgia            12712
## 80            Camden        Georgia            14276
## 81           Carroll        Georgia             4458
## 82          Charlton        Georgia            -5854
## 83           Chatham        Georgia            11929
## 84     Chattahoochee        Georgia           -28099
## 85         Chattooga        Georgia           -14186
## 86            Clarke        Georgia           -17607
## 87              Clay        Georgia            10279
## 88           Clayton        Georgia           -12439
## 89            Clinch        Georgia            -4185
## 90              Cobb        Georgia            -1516
## 91            Coffee        Georgia            -1188
## 92          Colquitt        Georgia            -5928
## 93            Coweta        Georgia            -1650
## 94           Decatur        Georgia           -17345
## 95             Dooly        Georgia            -9427
## 96         Dougherty        Georgia             6303
## 97             Early        Georgia            14694
## 98            Elbert        Georgia            -7736
## 99           Emanuel        Georgia             2843
## 100            Floyd        Georgia            -9233
## 101         Franklin        Georgia            17913
## 102           Fulton        Georgia            36112
## 103            Glynn        Georgia            19808
## 104           Gordon        Georgia              757
## 105         Gwinnett        Georgia             8035
## 106        Habersham        Georgia           -26650
## 107             Hall        Georgia             1359
## 108          Hancock        Georgia             4026
## 109           Harris        Georgia            14241
## 110             Hart        Georgia             8064
## 111            Heard        Georgia            -4453
## 112            Henry        Georgia           -23159
## 113          Houston        Georgia            13910
## 114          Jackson        Georgia            -8460
## 115           Jasper        Georgia            -9113
## 116        Jefferson        Georgia             -201
## 117          Johnson        Georgia             2518
## 118          Laurens        Georgia            -8441
## 119              Lee        Georgia            14334
## 120          Liberty        Georgia           -12106
## 121          Lowndes        Georgia            18396
## 122            Macon        Georgia             -770
## 123       Meriwether        Georgia              552
## 124           Miller        Georgia             3725
## 125         Mitchell        Georgia            -3465
## 126           Monroe        Georgia             4185
## 127       Montgomery        Georgia           -12603
## 128         Muscogee        Georgia           -11807
## 129           Newton        Georgia           -20400
## 130         Paulding        Georgia           -20210
## 131           Pierce        Georgia            -4846
## 132             Pike        Georgia            -5068
## 133             Polk        Georgia             7722
## 134          Pulaski        Georgia            -5547
## 135         Randolph        Georgia            -8673
## 136         Richmond        Georgia             -209
## 137          Screven        Georgia              171
## 138         Spalding        Georgia           -11103
## 139          Stewart        Georgia             9244
## 140           Sumter        Georgia           -10067
## 141       Taliaferro        Georgia            -4942
## 142         Tattnall        Georgia            -2132
## 143           Taylor        Georgia            19512
## 144          Telfair        Georgia           -13595
## 145           Thomas        Georgia            10535
## 146            Troup        Georgia             6387
## 147           Walker        Georgia             -967
## 148           Walton        Georgia            -6638
## 149             Ware        Georgia            -3505
## 150       Washington        Georgia            -3741
## 151            Wayne        Georgia             3536
## 152          Webster        Georgia             8405
## 153           Wilcox        Georgia             9339
## 154           Wilkes        Georgia             4326
## 155        Wilkinson        Georgia            15316
## 156        Ascension      Louisiana            13753
## 157        Bienville      Louisiana           -11189
## 158          Bossier      Louisiana            21058
## 159            Caddo      Louisiana             7753
## 160        Calcasieu      Louisiana            -3977
## 161         Caldwell      Louisiana            14073
## 162        Catahoula      Louisiana            -6735
## 163        Claiborne      Louisiana            -9348
## 164        Concordia      Louisiana            18629
## 165          De Soto      Louisiana            15745
## 166 East Baton Rouge      Louisiana            -4086
## 167   East Feliciana      Louisiana            19599
## 168         Franklin      Louisiana             7891
## 169        Iberville      Louisiana            17748
## 170          Jackson      Louisiana           -19087
## 171        Jefferson      Louisiana            -9391
## 172        Lafayette      Louisiana            -1747
## 173       Livingston      Louisiana            -1921
## 174          Madison      Louisiana            10746
## 175        Morehouse      Louisiana             2302
## 176     Natchitoches      Louisiana            11798
## 177          Orleans      Louisiana            17868
## 178         Ouachita      Louisiana             6129
## 179      Plaquemines      Louisiana             8647
## 180    Pointe Coupee      Louisiana            19497
## 181          Rapides      Louisiana             9749
## 182           Sabine      Louisiana            -5715
## 183           Tensas      Louisiana            13206
## 184       Terrebonne      Louisiana             7830
## 185            Union      Louisiana            -6275
## 186       Washington      Louisiana            -9101
## 187 West Baton Rouge      Louisiana            16155
## 188   West Feliciana      Louisiana            22238
## 189             Winn      Louisiana             4759
## 190            Adams    Mississippi             7100
## 191            Amite    Mississippi            -3213
## 192           Attala    Mississippi            -6500
## 193          Bolivar    Mississippi            14219
## 194          Carroll    Mississippi            12945
## 195        Chickasaw    Mississippi           -11975
## 196          Choctaw    Mississippi           -11442
## 197        Claiborne    Mississippi            10698
## 198           Clarke    Mississippi           -18257
## 199          Coahoma    Mississippi            18746
## 200           Copiah    Mississippi            -8230
## 201        Covington    Mississippi            -4794
## 202         Franklin    Mississippi            -6178
## 203           Greene    Mississippi             -335
## 204          Hancock    Mississippi            10798
## 205         Harrison    Mississippi            -7602
## 206            Hinds    Mississippi            11598
## 207           Holmes    Mississippi            15234
## 208        Issaquena    Mississippi            11984
## 209         Itawamba    Mississippi             6869
## 210          Jackson    Mississippi            12347
## 211           Jasper    Mississippi           -18234
## 212        Jefferson    Mississippi            14671
## 213            Jones    Mississippi            -1078
## 214           Kemper    Mississippi           -13527
## 215        Lafayette    Mississippi           -13199
## 216       Lauderdale    Mississippi            -5686
## 217         Lawrence    Mississippi             8640
## 218            Leake    Mississippi           -10428
## 219          Lowndes    Mississippi            16190
## 220          Madison    Mississippi            31202
## 221           Marion    Mississippi            -5876
## 222         Marshall    Mississippi             4670
## 223           Monroe    Mississippi            12214
## 224          Neshoba    Mississippi           -11602
## 225           Newton    Mississippi           -15880
## 226          Noxubee    Mississippi            15034
## 227        Oktibbeha    Mississippi            -3868
## 228           Panola    Mississippi              759
## 229            Perry    Mississippi            -1545
## 230             Pike    Mississippi           -13138
## 231           Rankin    Mississippi            -2168
## 232            Scott    Mississippi            13583
## 233          Simpson    Mississippi            13641
## 234            Smith    Mississippi           -10702
## 235        Sunflower    Mississippi             8237
## 236     Tallahatchie    Mississippi            -1363
## 237           Tunica    Mississippi            11010
## 238           Warren    Mississippi            22661
## 239       Washington    Mississippi            21061
## 240            Wayne    Mississippi            -4031
## 241        Wilkinson    Mississippi            11998
## 242          Winston    Mississippi           -13594
## 243        Yalobusha    Mississippi             4683
## 244            Yazoo    Mississippi            16525
## 245         Alamance North Carolina            -7948
## 246        Alexander North Carolina           -19202
## 247            Anson North Carolina           -14927
## 248         Beaufort North Carolina             -243
## 249           Bertie North Carolina             2036
## 250           Bladen North Carolina           -16655
## 251        Brunswick North Carolina            16827
## 252         Buncombe North Carolina               93
## 253            Burke North Carolina           -26521
## 254         Cabarrus North Carolina           -13877
## 255           Camden North Carolina            15918
## 256         Carteret North Carolina             9795
## 257          Caswell North Carolina            -1351
## 258          Catawba North Carolina             7286
## 259          Chatham North Carolina             4375
## 260         Cherokee North Carolina             5102
## 261           Chowan North Carolina             6085
## 262        Cleveland North Carolina             2340
## 263         Columbus North Carolina            -5887
## 264           Craven North Carolina            -5823
## 265       Cumberland North Carolina           -16573
## 266        Currituck North Carolina            -2644
## 267         Davidson North Carolina             9546
## 268            Davie North Carolina            -6932
## 269           Duplin North Carolina           -15691
## 270        Edgecombe North Carolina             4795
## 271          Forsyth North Carolina             9854
## 272         Franklin North Carolina            -8325
## 273           Gaston North Carolina             7581
## 274            Gates North Carolina            -8515
## 275           Greene North Carolina           -15771
## 276         Guilford North Carolina            12220
## 277          Halifax North Carolina             6701
## 278          Harnett North Carolina            -8914
## 279          Haywood North Carolina           -15082
## 280        Henderson North Carolina            -8954
## 281         Hertford North Carolina           -15374
## 282             Hyde North Carolina            29646
## 283          Iredell North Carolina            -7530
## 284          Jackson North Carolina            -5081
## 285         Johnston North Carolina            -6831
## 286            Jones North Carolina            -3797
## 287           Lenoir North Carolina           -13528
## 288          Lincoln North Carolina            -5319
## 289            Macon North Carolina           -16622
## 290          Madison North Carolina           -69158
## 291           Martin North Carolina           -15622
## 292         McDowell North Carolina           -17537
## 293      Mecklenburg North Carolina            -2187
## 294       Montgomery North Carolina             9328
## 295            Moore North Carolina            18067
## 296             Nash North Carolina           -14358
## 297      New Hanover North Carolina            15213
## 298      Northampton North Carolina           -14652
## 299           Onslow North Carolina             6290
## 300           Orange North Carolina             1662
## 301       Pasquotank North Carolina            -5186
## 302       Perquimans North Carolina               90
## 303           Person North Carolina           -16749
## 304             Pitt North Carolina           -12733
## 305             Polk North Carolina           -16541
## 306         Randolph North Carolina             1063
## 307         Richmond North Carolina           -17711
## 308          Robeson North Carolina           -14174
## 309       Rockingham North Carolina           -16162
## 310            Rowan North Carolina            -9410
## 311       Rutherford North Carolina             6130
## 312          Sampson North Carolina           -12361
## 313           Stanly North Carolina             8255
## 314           Stokes North Carolina            -2321
## 315            Surry North Carolina            -5240
## 316          Tyrrell North Carolina            -6295
## 317            Union North Carolina            12575
## 318             Wake North Carolina            19307
## 319           Warren North Carolina            15997
## 320       Washington North Carolina            15702
## 321            Wayne North Carolina            -9825
## 322           Wilkes North Carolina            -4722
## 323           Wilson North Carolina            22308
## 324           Yadkin North Carolina           -12105
## 325        Abbeville South Carolina             9998
## 326         Anderson South Carolina             7569
## 327         Barnwell South Carolina             9053
## 328         Beaufort South Carolina            18297
## 329       Charleston South Carolina            18901
## 330          Chester South Carolina             4620
## 331     Chesterfield South Carolina           -13531
## 332        Clarendon South Carolina            12156
## 333         Colleton South Carolina             5526
## 334       Darlington South Carolina             6271
## 335        Edgefield South Carolina            25546
## 336        Fairfield South Carolina             8652
## 337       Georgetown South Carolina            21195
## 338       Greenville South Carolina            -6742
## 339            Horry South Carolina            -6594
## 340          Kershaw South Carolina             1269
## 341        Lancaster South Carolina           -16441
## 342          Laurens South Carolina             2413
## 343        Lexington South Carolina            -4586
## 344           Marion South Carolina             8691
## 345         Marlboro South Carolina            -8146
## 346         Newberry South Carolina            13475
## 347       Orangeburg South Carolina             7419
## 348          Pickens South Carolina             2843
## 349         Richland South Carolina            11336
## 350      Spartanburg South Carolina             6513
## 351           Sumter South Carolina            10249
## 352            Union South Carolina             3447
## 353     Williamsburg South Carolina            15695
## 354             York South Carolina            11242
## 355          Bedford      Tennessee            -9792
## 356          Bledsoe      Tennessee           -27705
## 357           Blount      Tennessee            -1340
## 358          Bradley      Tennessee            -7596
## 359          Carroll      Tennessee            -1936
## 360         Cheatham      Tennessee           -54426
## 361        Claiborne      Tennessee            -2274
## 362            Cocke      Tennessee              435
## 363           Coffee      Tennessee             -466
## 364         Davidson      Tennessee             5960
## 365          Decatur      Tennessee           -13150
## 366          Dickson      Tennessee             6979
## 367             Dyer      Tennessee           -13389
## 368          Fayette      Tennessee            13583
## 369         Franklin      Tennessee           -22205
## 370           Gibson      Tennessee            -8547
## 371            Giles      Tennessee             3505
## 372         Hamilton      Tennessee            13338
## 373         Hardeman      Tennessee           -22393
## 374           Hardin      Tennessee           -26053
## 375          Hawkins      Tennessee           -18627
## 376          Haywood      Tennessee             1877
## 377        Henderson      Tennessee            -7936
## 378            Henry      Tennessee           -10518
## 379          Hickman      Tennessee             8938
## 380        Jefferson      Tennessee             9426
## 381             Knox      Tennessee            14235
## 382       Lauderdale      Tennessee             8170
## 383         Lawrence      Tennessee            -6086
## 384            Lewis      Tennessee             6837
## 385          Lincoln      Tennessee            -9233
## 386          Madison      Tennessee            13378
## 387         Marshall      Tennessee            -4667
## 388            Maury      Tennessee             7549
## 389           McMinn      Tennessee            -1424
## 390          McNairy      Tennessee             1769
## 391            Meigs      Tennessee            -6601
## 392           Monroe      Tennessee            -7703
## 393       Montgomery      Tennessee             1298
## 394            Obion      Tennessee             4757
## 395           Putnam      Tennessee             1169
## 396             Rhea      Tennessee           -11550
## 397        Robertson      Tennessee            -2414
## 398       Rutherford      Tennessee             2179
## 399           Sevier      Tennessee            -8615
## 400           Shelby      Tennessee            18647
## 401            Smith      Tennessee           -24155
## 402         Sullivan      Tennessee            -8061
## 403           Sumner      Tennessee           -14901
## 404           Tipton      Tennessee            -4097
## 405           Warren      Tennessee           -13527
## 406       Washington      Tennessee             5114
## 407            Wayne      Tennessee             3345
## 408          Weakley      Tennessee             5524
## 409            White      Tennessee            -1788
## 410       Williamson      Tennessee            11367
## 411           Wilson      Tennessee             7149
## 412         Anderson          Texas           -10110
## 413         Angelina          Texas           -12186
## 414           Austin          Texas            30780
## 415          Bastrop          Texas            18047
## 416              Bee          Texas           -27469
## 417            Bowie          Texas              588
## 418         Brazoria          Texas            -5500
## 419           Brazos          Texas            -2442
## 420         Burleson          Texas            -7653
## 421         Caldwell          Texas            -8057
## 422          Calhoun          Texas           -14581
## 423         Cherokee          Texas           -18433
## 424         Colorado          Texas            -6994
## 425            Ellis          Texas             2025
## 426            Falls          Texas              -28
## 427           Fannin          Texas             2584
## 428          Fayette          Texas            -4609
## 429        Fort Bend          Texas            12961
## 430        Freestone          Texas            10837
## 431        Galveston          Texas             9896
## 432         Gonzales          Texas            18542
## 433          Grayson          Texas             4204
## 434           Grimes          Texas            -8538
## 435        Guadalupe          Texas           -32321
## 436           Hardin          Texas             2966
## 437           Harris          Texas            14565
## 438         Harrison          Texas            13149
## 439        Henderson          Texas             3926
## 440          Hopkins          Texas               -7
## 441          Houston          Texas            -9651
## 442             Hunt          Texas            -6737
## 443          Jackson          Texas             1433
## 444           Jasper          Texas             3078
## 445        Jefferson          Texas             3731
## 446          Johnson          Texas            -7487
## 447          Kaufman          Texas            -6260
## 448           Lavaca          Texas           -13717
## 449             Leon          Texas            24339
## 450          Liberty          Texas            -4743
## 451        Limestone          Texas             6368
## 452          Madison          Texas           -12257
## 453           Marion          Texas             1068
## 454        Matagorda          Texas             9312
## 455            Milam          Texas            -2827
## 456       Montgomery          Texas             7414
## 457      Nacogdoches          Texas           -10618
## 458          Navarro          Texas           -10900
## 459           Newton          Texas            -5712
## 460           Panola          Texas            13832
## 461             Polk          Texas           -24875
## 462        Red River          Texas             7188
## 463          Refugio          Texas           -22226
## 464        Robertson          Texas            27946
## 465             Rusk          Texas            -8224
## 466    San Augustine          Texas           -12719
## 467           Shelby          Texas             2152
## 468            Smith          Texas            -4853
## 469          Tarrant          Texas            10697
## 470            Titus          Texas           -14997
## 471           Travis          Texas            21011
## 472          Trinity          Texas             9343
## 473            Tyler          Texas            -2305
## 474           Upshur          Texas            -7442
## 475        Van Zandt          Texas             5933
## 476           Walker          Texas           -11003
## 477       Washington          Texas            -3248
## 478          Wharton          Texas            15946
## 479       Williamson          Texas           -12010
## 480             Wood          Texas           -24690
## 481         Accomack       Virginia             3749
## 482        Albemarle       Virginia            20736
## 483           Amelia       Virginia             1786
## 484          Amherst       Virginia           -13727
## 485       Appomattox       Virginia           -22798
## 486          Augusta       Virginia            -1155
## 487             Bath       Virginia            -4250
## 488          Bedford       Virginia             8868
## 489        Botetourt       Virginia            21365
## 490        Brunswick       Virginia             7354
## 491       Buckingham       Virginia            -3995
## 492         Campbell       Virginia              193
## 493         Caroline       Virginia             2086
## 494          Carroll       Virginia             8516
## 495     Charles City       Virginia            -3986
## 496        Charlotte       Virginia            -1397
## 497     Chesterfield       Virginia             2948
## 498           Clarke       Virginia             1473
## 499         Culpeper       Virginia             6655
## 500       Cumberland       Virginia             8618
## 501        Dinwiddie       Virginia             -750
## 502            Essex       Virginia           -10653
## 503          Fairfax       Virginia            12380
## 504         Fauquier       Virginia            25425
## 505            Floyd       Virginia            18515
## 506         Fluvanna       Virginia            -8598
## 507         Franklin       Virginia           -12984
## 508        Frederick       Virginia            -2877
## 509       Gloucester       Virginia            -9680
## 510        Goochland       Virginia            38390
## 511          Grayson       Virginia           -14666
## 512      Greensville       Virginia            -1263
## 513          Halifax       Virginia             2579
## 514          Hanover       Virginia             6332
## 515          Henrico       Virginia             7787
## 516            Henry       Virginia           -25556
## 517       James City       Virginia            31328
## 518      King George       Virginia             5617
## 519     King William       Virginia            13157
## 520        Lancaster       Virginia             4027
## 521           Louisa       Virginia             7836
## 522        Lunenburg       Virginia           -14917
## 523          Mathews       Virginia            26979
## 524      Mecklenburg       Virginia             6490
## 525        Middlesex       Virginia             3566
## 526       Montgomery       Virginia            -6649
## 527         New Kent       Virginia             6736
## 528      Northampton       Virginia            -1447
## 529   Northumberland       Virginia             -481
## 530         Nottoway       Virginia            -7592
## 531           Orange       Virginia             8790
## 532             Page       Virginia           -31235
## 533     Pittsylvania       Virginia              398
## 534         Powhatan       Virginia             6561
## 535    Prince Edward       Virginia            -4086
## 536    Prince George       Virginia           -11400
## 537   Prince William       Virginia            -6723
## 538          Pulaski       Virginia           -12324
## 539     Rappahannock       Virginia            13745
## 540         Richmond       Virginia             3607
## 541          Roanoke       Virginia           -18291
## 542       Rockbridge       Virginia             8984
## 543       Rockingham       Virginia            -8509
## 544            Scott       Virginia           -47678
## 545            Smyth       Virginia            -9337
## 546      Southampton       Virginia           -15029
## 547     Spotsylvania       Virginia           -19061
## 548         Stafford       Virginia             5412
## 549           Sussex       Virginia            -2197
## 550       Washington       Virginia             6112
## 551     Westmoreland       Virginia           -31017
## 552            Wythe       Virginia           -22481
## 553             York       Virginia            22015
Avg<- mean(treatment_effect_df$Treatment_Effect)

print(Avg)
## [1] 102.0217

Step 11

The average treatment effect is much lower when matching with Mahalanobis distances corresponding to percent population enslaved in 1860, and total population in 1860. Both estimates have their assumptions that are likely violated to some degree, but the estimate using matching most likely is more “trustworthy” as treatment effects are typically more accurately estimated using matching. ### Step 12 The estimator in step 10 is exactly the average treatment effect.

Section 3

Step 13

reg <-feglm(had_rosenwald_school ~ I((pct_pop_enslaved_1860)^2) + I((pop_total_1860)^2) + pct_pop_enslaved_1860 + pop_total_1860 + pct_pop_enslaved_1860:pop_total_1860, data = data, family = 'logit')

 

propscore<-reg$fitted.values

 

data2 <- data1%>% mutate(propscore)

Step 14

state_fe_reg <- feols(income_gap ~ had_rosenwald_school + pct_pop_enslaved_1860 + pop_total_1860 + propscore | state, data = data2)

summary(state_fe_reg)
## OLS estimation, Dep. Var.: income_gap
## Observations: 710 
## Fixed-effects: state: 10
## Standard-errors: Clustered (state) 
##                          Estimate  Std. Error t value  Pr(>|t|)    
## had_rosenwald_school  1626.797846  928.156245 1.75272 0.1135566    
## pct_pop_enslaved_1860   95.694403   23.669237 4.04299 0.0029155 ** 
## pop_total_1860           0.061851    0.031726 1.94955 0.0830262 .  
## propscore             7464.471958 4561.486979 1.63641 0.1361810    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 9,307.6     Adj. R2: 0.152518
##                 Within R2: 0.104984

The coeffecient decreased from the first part of the assignment, and has become “less significant”. ### Step 15

dense<- ggplot(data2,aes(x=propscore, fill=factor(had_rosenwald_school)))+
  geom_density(color="#e9ecef", alpha=0.5, position = 'identity') +
    scale_fill_manual(values=c("#69b3a2", "#404080"))
dense

### Step 16 667 out of the 710 observations have overlap, 93.9% of observations do have overlap, so the 6.1% without overlap.

Step 17

We care about overlap because our assumptions require that each county has some probability of being treated and untreated, this enforces our CIA and validates matching. ### Step 18

controls = filter(data2, had_rosenwald_school==0)
treats = filter(data2, had_rosenwald_school==1)
max_cont = max(controls$propscore)
min_treat = min(treats$propscore)
good_controls = filter(data2, had_rosenwald_school == 0 & propscore>min_treat)
good_treats = filter(data2, had_rosenwald_school == 1 & propscore<max_cont)
overlap_enforced <- rbind(good_controls,good_treats)
overlap_enforced
## # A tibble: 667 × 14
##    state  county gisjoin pop_e…¹ pop_t…² pop_t…³ pop_b…⁴ pop_w…⁵ incom…⁶ incom…⁷
##    <chr>  <chr>  <chr>     <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
##  1 Alaba… DeKalb G01004…     848   10705   71109    1078   60087   25585   34990
##  2 Alaba… St. C… G01011…    1768   11013   83593    7150   73741   35924   50691
##  3 Alaba… Winst… G01013…     122    3576   24484     115   23409    2499   34266
##  4 Flori… Calho… G12001…     524    1446   14625    2011   11818   22969   35452
##  5 Flori… Clay   G12001…     519    1914  190865   18831  156087   49001   62243
##  6 Flori… Frank… G12003…     520    1904   11549    1589    9540   20915   38841
##  7 Flori… Herna… G12005…     200    1200  172778    8816  154598   35506   42357
##  8 Flori… Hills… G12005…     564    2981 1229226  205073  876137   35110   53534
##  9 Flori… Lafay… G12006…     577    2068    8870    1411    6868   18167   47224
## 10 Flori… Levy   G12007…     450    1781   40801    3832   34876   17591   37842
## # … with 657 more rows, 4 more variables: pct_pop_enslaved_1860 <dbl>,
## #   had_rosenwald_school <dbl>, income_gap <dbl>, propscore <dbl>, and
## #   abbreviated variable names ¹​pop_enslaved_1860, ²​pop_total_1860,
## #   ³​pop_total_2010, ⁴​pop_black_2010, ⁵​pop_white_2010, ⁶​income_black_2010,
## #   ⁷​income_white_2010
state_fe_reg1<- feols(income_gap ~ had_rosenwald_school + pct_pop_enslaved_1860 + pop_total_1860 + propscore | state, data = overlap_enforced)

summary(state_fe_reg1)
## OLS estimation, Dep. Var.: income_gap
## Observations: 667 
## Fixed-effects: state: 10
## Standard-errors: Clustered (state) 
##                          Estimate  Std. Error  t value  Pr(>|t|)    
## had_rosenwald_school  1622.607079  920.926558 1.761929 0.1119216    
## pct_pop_enslaved_1860   95.127616   23.879579 3.983639 0.0031882 ** 
## pop_total_1860           0.002359    0.101923 0.023149 0.9820369    
## propscore             8365.160878 5651.095515 1.480272 0.1729338    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 9,196.3     Adj. R2: 0.146549
##                 Within R2: 0.094592

There is very little change from 14 ### Step 19

overlap_enforced$had_rosenwald_school<-as.numeric(overlap_enforced$had_rosenwald_school)
weights <- overlap_enforced$had_rosenwald_school/overlap_enforced$propscore+(1-overlap_enforced$had_rosenwald_school)/(1-overlap_enforced$propscore)
data5 <- overlap_enforced%>%mutate(weights)
state_fe_reg2<- feols(income_gap ~ had_rosenwald_school + pct_pop_enslaved_1860 + pop_total_1860 |state,weights=~weights, data=data5)

summary(state_fe_reg2)
## OLS estimation, Dep. Var.: income_gap
## Observations: 667 
## Weights: weights 
## Fixed-effects: state: 10
## Standard-errors: Clustered (state) 
##                          Estimate Std. Error  t value  Pr(>|t|)    
## had_rosenwald_school  1966.393786 941.608353 2.088335 0.0663623 .  
## pct_pop_enslaved_1860  147.512138  34.882663 4.228809 0.0022105 ** 
## pop_total_1860           0.102588   0.149688 0.685343 0.5103924    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 13,520.4     Adj. R2: 0.160007
##                  Within R2: 0.091519

The estimate increased, while standard error increased less proportionally. ### Step 20

firstblock = filter(data5,propscore>=.03&propscore<0.4)
secondblock =filter(data5,propscore>=.04&propscore<0.5)
thirdblock = filter(data5,propscore>=.05&propscore<0.6)
fourthblock = filter(data5,propscore>=.06&propscore<0.7)
fithblock = filter(data5,propscore>=.07&propscore<0.8)
sixblock = filter(data5,propscore>=.08&propscore<0.9)
seventhblock = filter(data5,propscore>=.9&propscore<1)
first<-feols(income_gap~had_rosenwald_school+pct_pop_enslaved_1860+pop_total_1860|state,data=firstblock)
second<-feols(income_gap~had_rosenwald_school+pct_pop_enslaved_1860+pop_total_1860|state,data=secondblock)
third<-feols(income_gap~had_rosenwald_school+pct_pop_enslaved_1860+pop_total_1860|state,data=thirdblock)
fourth<-feols(income_gap~had_rosenwald_school+pct_pop_enslaved_1860+pop_total_1860|state,data=fourthblock)
fifth<-feols(income_gap~had_rosenwald_school+pct_pop_enslaved_1860+pop_total_1860|state,data=fithblock)
sixth<-feols(income_gap~had_rosenwald_school+pct_pop_enslaved_1860+pop_total_1860|state,data=sixblock)
seven<-feols(income_gap~had_rosenwald_school+pct_pop_enslaved_1860+pop_total_1860|state,data=seventhblock)

summary(first)
## OLS estimation, Dep. Var.: income_gap
## Observations: 34 
## Fixed-effects: state: 7
## Standard-errors: Clustered (state) 
##                           Estimate  Std. Error   t value Pr(>|t|) 
## had_rosenwald_school  -6141.971381 12647.39375 -0.485631  0.64445 
## pct_pop_enslaved_1860  2295.055945  3522.22945  0.651592  0.53881 
## pop_total_1860           -0.044103     4.71248 -0.009359  0.99284 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 16,030.3     Adj. R2: -0.027472
##                  Within R2:  0.077882
summary(second)
## OLS estimation, Dep. Var.: income_gap
## Observations: 63 
## Fixed-effects: state: 8
## Standard-errors: Clustered (state) 
##                          Estimate Std. Error   t value Pr(>|t|) 
## had_rosenwald_school  3801.579760 2864.67675  1.327054  0.22614 
## pct_pop_enslaved_1860  140.134359  471.90978  0.296952  0.77512 
## pop_total_1860          -0.008613    1.64949 -0.005221  0.99598 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 15,822.2     Adj. R2: -0.020635
##                  Within R2:  0.014751
summary(third)
## OLS estimation, Dep. Var.: income_gap
## Observations: 99 
## Fixed-effects: state: 8
## Standard-errors: Clustered (state) 
##                         Estimate Std. Error  t value Pr(>|t|) 
## had_rosenwald_school  2808.65166 2089.28524 1.344312  0.22078 
## pct_pop_enslaved_1860   85.32634   94.59138 0.902052  0.39700 
## pop_total_1860           0.25262    0.72139 0.350185  0.73650 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 13,898.5     Adj. R2: -0.007396
##                  Within R2:  0.013924
summary(fourth)
## OLS estimation, Dep. Var.: income_gap
## Observations: 165 
## Fixed-effects: state: 9
## Standard-errors: Clustered (state) 
##                         Estimate  Std. Error  t value Pr(>|t|) 
## had_rosenwald_school  991.427531 1843.193771 0.537886  0.60529 
## pct_pop_enslaved_1860 124.604536   74.895451 1.663713  0.13474 
## pop_total_1860          0.199815    0.402281 0.496704  0.63276 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 12,561.6     Adj. R2: 0.049863
##                  Within R2: 0.016132
summary(fifth)
## OLS estimation, Dep. Var.: income_gap
## Observations: 279 
## Fixed-effects: state: 9
## Standard-errors: Clustered (state) 
##                          Estimate Std. Error   t value Pr(>|t|)    
## had_rosenwald_school  2116.478705 805.196996  2.628523 0.030247 *  
## pct_pop_enslaved_1860  104.973235  32.321223  3.247811 0.011739 *  
## pop_total_1860          -0.045197   0.274063 -0.164915 0.873102    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 11,070.1     Adj. R2: 0.10796 
##                  Within R2: 0.035223
summary(sixth)
## OLS estimation, Dep. Var.: income_gap
## Observations: 485 
## Fixed-effects: state: 10
## Standard-errors: Clustered (state) 
##                          Estimate Std. Error   t value  Pr(>|t|)    
## had_rosenwald_school  2099.228755 540.445067  3.884259 0.0037072 ** 
## pct_pop_enslaved_1860  127.215656  31.050626  4.097040 0.0026886 ** 
## pop_total_1860          -0.048264   0.150372 -0.320966 0.7555642    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 10,071.0     Adj. R2: 0.117603
##                  Within R2: 0.063152
summary(seven)
## OLS estimation, Dep. Var.: income_gap
## Observations: 182 
## Fixed-effects: state: 9
## Standard-errors: Clustered (state) 
##                          Estimate  Std. Error  t value Pr(>|t|)    
## had_rosenwald_school  2780.196318 4278.497650 0.649807 0.534027    
## pct_pop_enslaved_1860  123.299821   44.684967 2.759313 0.024701 *  
## pop_total_1860           0.239697    0.115009 2.084152 0.070658 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 6,069.3     Adj. R2: 0.149358
##                 Within R2: 0.123077
ATE= (-6141.971381+3801.579760+2808.65166+991.427531+2116.478705+2099.228755+2780.196318)/7
ATE
## [1] 1207.942