adh <- fread("autordornhanson.csv")

Table 2 of Autor, David H., David Dorn, and Gordon H. Hanson. “The China syndrome: Local labor market effects of import competition in the United States.” American economic review 103.6 (2013): 2121-2168.

r <- list()

r[[1]] <- felm( d_sh_empl_mfg~1|0|(d_tradeusch_pw~d_tradeotch_pw_lag)|statefip,data=adh[yr==1990] ,weights = adh[yr==1990]$timepwt48)
r[[2]] <- felm( d_sh_empl_mfg~1|0|(d_tradeusch_pw~d_tradeotch_pw_lag)|statefip,data=adh[yr==2000] ,weights = adh[yr==2000]$timepwt48)
r[[3]] <- felm( d_sh_empl_mfg~1|yr|(d_tradeusch_pw~d_tradeotch_pw_lag)|statefip,data=adh[yr>=1990] ,weights = adh[yr>=1990]$timepwt48)

stargazer(r,type="text",no.space = T,omit.stat = "ser")
## 
## ===================================================
##                            Dependent variable:     
##                       -----------------------------
##                               d_sh_empl_mfg        
##                          (1)       (2)       (3)   
## ---------------------------------------------------
## `d_tradeusch_pw(fit)` -0.888*** -0.718*** -0.746***
##                        (0.183)   (0.065)   (0.069) 
## Constant              -1.056*** -0.846***          
##                        (0.195)   (0.258)           
## ---------------------------------------------------
## Observations             722       722      1,444  
## R2                     -0.136     0.139     0.066  
## Adjusted R2            -0.138     0.138     0.065  
## ===================================================
## Note:                   *p<0.1; **p<0.05; ***p<0.01
CZ_crosswalk <- fread("C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/Crosswalk Files/cz00_eqv_v1.csv")
setnames(CZ_crosswalk,c("FIPS","Commuting Zone ID, 1990"),c("fips","cz"))
CZ_crosswalk <- CZ_crosswalk[,c("fips","cz")]
CZ_crosswalk[,fips:=str_pad(fips,5,"left","0")]
sod <- list()
i=1
for(fl in list.files(path="C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/SOD/data",full.names = T)){
  sod[[i]] <- fread(fl,select = c("YEAR","CERT","DEPSUMBR","DEPSUM","RSSDHCR","RSSDID","STCNTYBR","ASSET"))
  i=i+1
}

sod <- rbindlist(sod,fill=T)

sod[,DEPSUMBR:=str_remove_all(DEPSUMBR,",")]
sod[,DEPSUM:=str_remove_all(DEPSUM,",")]
sod[,ASSET:=str_remove_all(ASSET,",")]

sod[,DEPSUMBR:= as.numeric(DEPSUMBR)]
sod[,DEPSUM:= as.numeric(DEPSUM)]
sod[,ASSET:= as.numeric(ASSET)]

sod[,fips:=str_pad(STCNTYBR,5,"left","0")]

sod <- merge(sod,CZ_crosswalk,by="fips")

sod_cz <- sod[,.(total_deposits=sum(DEPSUMBR,na.rm=T),no_branches=.N),by=.(YEAR,cz)]

sod_cz_1994 <- sod_cz[YEAR==1994]
setnames(sod_cz_1994,c("total_deposits","no_branches"),c("total_deposits_1994","no_branches_1994"))
sod_cz_2000 <- sod_cz[YEAR==2000]
setnames(sod_cz_2000,c("total_deposits","no_branches"),c("total_deposits_2000","no_branches_2000"))
sod_cz_2007 <- sod_cz[YEAR==2007]
setnames(sod_cz_2007,c("total_deposits","no_branches"),c("total_deposits_2007","no_branches_2007"))

sod_cz <- merge(sod_cz_1994,sod_cz_2000,by="cz")
sod_cz <- merge(sod_cz,sod_cz_2007,by="cz")

sod_cz <- sod_cz[!is.na(cz)]

sod_cz[,total_deposits_chg:=((total_deposits_2007/total_deposits_2000)^(1/(2007-2000)))-1]
sod_cz[,no_branches_chg:=((no_branches_2007/no_branches_2000)^(1/(2007-2000)))-1]


sod_yr_2000 <- sod_cz[,c("cz","total_deposits_chg","no_branches_chg")]
sod_yr_2000[,yr:=2000]

sod_cz[,total_deposits_chg:=((total_deposits_2000/total_deposits_1994)^(1/(2000-1994)))-1]
sod_cz[,no_branches_chg:=((no_branches_2000/no_branches_1994)^(1/(2000-1994)))-1]

sod_yr_1990 <- sod_cz[,c("cz","total_deposits_chg","no_branches_chg")]
sod_yr_1990[,yr:=1990]

sod_cz <- rbind(sod_yr_2000,sod_yr_1990)
sod_cz <- merge(sod_cz,adh,by.x=c("cz","yr"),by.y=c("czone","yr"))

Change in commuting Zone level deposits

r <- list()

r[[1]] <- felm( I(total_deposits_chg*1000)~1|0|(d_tradeusch_pw~d_tradeotch_pw_lag)|statefip,data=sod_cz[yr==1990] ,weights = sod_cz[yr==1990]$timepwt48)
r[[2]] <- felm( I(total_deposits_chg*1000)~1|0|(d_tradeusch_pw~d_tradeotch_pw_lag)|statefip,data=sod_cz[yr==2000] ,weights = sod_cz[yr==2000]$timepwt48)
r[[3]] <- felm( I(total_deposits_chg*1000)~1|yr|(d_tradeusch_pw~d_tradeotch_pw_lag)|statefip,data=sod_cz[yr>=1990] ,weights = sod_cz[yr>=1990]$timepwt48)

stargazer(r,type="text",no.space = T,omit.stat = "ser")
## 
## ====================================================
##                            Dependent variable:      
##                       ------------------------------
##                        I(total_deposits_chg * 1000) 
##                          (1)        (2)       (3)   
## ----------------------------------------------------
## `d_tradeusch_pw(fit)`   0.308    -8.373*** -6.953***
##                        (1.608)    (2.663)   (2.281) 
## Constant              37.416***  90.570***          
##                        (3.227)    (9.080)           
## ----------------------------------------------------
## Observations             721        721      1,442  
## R2                      -0.001     0.002     0.141  
## Adjusted R2             -0.002     0.001     0.140  
## ====================================================
## Note:                    *p<0.1; **p<0.05; ***p<0.01


#### Change in commuting Zone level number of branches

r <- list()

r[[1]] <- felm( I(no_branches_chg*1000)~1|0|(d_tradeusch_pw~d_tradeotch_pw_lag)|statefip,data=sod_cz[yr==1990] ,weights = sod_cz[yr==1990]$timepwt48)
r[[2]] <- felm( I(no_branches_chg*1000)~1|0|(d_tradeusch_pw~d_tradeotch_pw_lag)|statefip,data=sod_cz[yr==2000] ,weights = sod_cz[yr==2000]$timepwt48)
r[[3]] <- felm( I(no_branches_chg*1000)~1|yr|(d_tradeusch_pw~d_tradeotch_pw_lag)|statefip,data=sod_cz[yr>=1990] ,weights = sod_cz[yr>=1990]$timepwt48)

stargazer(r,type="text",no.space = T,omit.stat = "ser")
## 
## ===================================================
##                            Dependent variable:     
##                       -----------------------------
##                         I(no_branches_chg * 1000)  
##                          (1)       (2)       (3)   
## ---------------------------------------------------
## `d_tradeusch_pw(fit)`  -4.227*  -1.959*** -2.329***
##                        (2.269)   (0.720)   (0.711) 
## Constant              12.757**  25.790***          
##                        (5.227)   (2.981)           
## ---------------------------------------------------
## Observations             721       721      1,442  
## R2                     -0.029    0.0004     0.089  
## Adjusted R2            -0.031    -0.001     0.087  
## ===================================================
## Note:                   *p<0.1; **p<0.05; ***p<0.01