Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rCode/fipsCodeLabel.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# maybe they omit bedford city because their list is post 2013


countyLevelRaw <- read_dta("OriginalMaterials/county_level.dta")
countyLevelRaw <- read_dta(here::here("OriginalMaterials/county_level.dta"))


allFIPS <- tidycensus::fips_codes %>% tibble() %>%
Expand Down Expand Up @@ -41,7 +41,7 @@ countyLevel <- countyLevel0 %>% left_join(allFIPSBW %>% dplyr::select(id, coun
# these are missing in BW as well


saveRDS(countyLevel, "data/BWCountyLevel.rds")
saveRDS(countyLevel, here::here("data/BWCountyLevel.rds"))



Expand Down
12 changes: 6 additions & 6 deletions rCode/main.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# load packages
source("rCode/preamble.R")
source("preamble.R")

# Global vars
########################################################
Expand All @@ -16,15 +16,15 @@ QWIName <- "timeseries/qwi/rh"

# Pull census data if it doesn't exist
########################################################
if(!file.exists("data/censusDataByCounty.rds")){ source("rCode/censusAPIPull.R") }
if(!file.exists("data/censusDataByCounty.rds")){ source("censusAPIPull.R") }
# clean up BW data if not done - add FIPS code guesses etc
if(!file.exists("data/BWCountyLevel.rds")){ source("rCode/fipsCodeLabel.R")}
BWDataByCounty <- readRDS("data/BWCountyLevel.rds")
BWDataByCounty <- readRDS(here::here("data/BWCountyLevel.rds"))
# national aggregates for employment
if(!file.exists("data/natlResult.rds")){ source("rCode/natlCalcs.R")}
natlResult <- readRDS("data/natlResult.rds")
if(!file.exists("data/natlResult.rds")){ source("natlCalcs.R")}
natlResult <- readRDS(here::here("data/natlResult.rds"))
# create our own bartik instrument
if(!file.exists("data/finalBartik.RDS")){ source("rCode/replicateBartikInstrument.R")}
if(!file.exists("data/finalBartik.RDS")){ source("replicateBartikInstrument.R")}
bartikOurs <- readRDS("data/finalBartik.RDS")

########################################################
2 changes: 1 addition & 1 deletion rCode/natlCalcs.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ saveRDS(list(
whiteEmpl = whiteEmpl$whiteEmp,
nonwhiteLayoffs = nonwhiteLayoffs$nonwhiteLayoffs,
nonwhiteNetChange = nonwhiteNetChange$nonwhiteNetChange,
nonwhiteEmpl = nonwhiteEmpl$nonwhiteEmp), "data/natlResult.rds")
nonwhiteEmpl = nonwhiteEmpl$nonwhiteEmp), here::here("data/natlResult.rds"))



14 changes: 14 additions & 0 deletions rCode/preamble.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
packages <- c("censusapi", "tidycensus",
"tidyverse", "stringr",
"xlsx", "assertthat",
"tictoc", "haven",
"stargazer", "AER",
"lfe", "lmtest",
"CBPS", "here")

if(length(which(!packages %in% installed.packages())) > 0) {
install.packages(packages[!packages %in% installed.packages()])
}

library(censusapi)
library(tidycensus)
library(tidyverse)
Expand All @@ -11,6 +23,8 @@ library(AER)
library(lfe)
library(lmtest)
library(CBPS)
library(here)




Expand Down
4 changes: 2 additions & 2 deletions rCode/replicateBartikInstrument.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

################################################################
countyLevelData <- readRDS("data/censusDataByCounty.rds")
natlResult <- readRDS("data/natlResult.rds")
countyLevelData <- readRDS(here::here("data/censusDataByCounty.rds"))
natlResult <- readRDS(here::here("data/natlResult.rds"))
################################################################

aggregate <- totalData %>% left_join(mfgData) %>%
Expand Down
5 changes: 3 additions & 2 deletions rCode/replicateRegsAndExtend_short v2.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


source("rCode/preamble.R")
BWDataByCounty <- readRDS("data/BWCountyLevel.rds")
source("preamble.R")
BWDataByCounty <- readRDS(here::here("data/BWCountyLevel.rds"))

#################################################################################
# First we run our code with their data to replicate
Expand Down Expand Up @@ -524,3 +524,4 @@ saveRDS(list(
secondStageModelNetC04 = secondStageModelOurs04_3,
secondStageModelWNetC04 = secondStageModelOurs04_6),
file = "regresults.rds")