Created
April 15, 2020 01:38
-
-
Save jdingel/964e34fa439d86c39f5564161ff2ff5f to your computer and use it in GitHub Desktop.
Scatterplot of DEX against WFH for MSAs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear all | |
import delimited using "https://raw.githubusercontent.com/jdingel/DingelNeiman-workathome/master/MSA_measures/output/MSA_workfromhome.csv", clear | |
drop if substr(area_name,-4,4)==", PR" //Drop Puerto Rico | |
clonevar cbsa = area | |
recode cbsa (70900=12700) (71650=14460) (78100=44140) (79600 = 49340) (70750 = 12620) (71950 = 14860) (72400 = 15540) (73450 = 25540) (94650=30340) (75700 = 35300) (76450 = 35980) (76750 = 38860) (77200 = 39300) (76600=38340) //Recode NECTAs to work with CBSA 2013 definitions | |
tempfile tf_msa_wfh | |
label variable teleworkable_emp "Share of jobs that can be done at home" | |
save `tf_msa_wfh' | |
import excel cbsa = A fips_st = J fips_co = K cbsa_name = D county_name = H metro = E using "https://www2.census.gov/programs-surveys/metro-micro/geographies/reference-files/2013/delineation-files/list1.xls", clear cellrange(A4) | |
drop if missing(fips_st)==1 & missing(fips_co)==1 | |
drop if fips_st=="72" | |
keep if metro=="Metropolitan Statistical Area" | |
compress | |
gen fips = fips_st + fips_co | |
destring cbsa fips, replace | |
order fips county_name cbsa cbsa_name | |
keep fips county_name cbsa cbsa_name | |
tempfile tf_county_msa | |
save `tf_county_msa' | |
assert _N==1167 //Only 1167 counties assigned to MSAs by this file | |
import delimited using "https://raw.githubusercontent.com/COVIDExposureIndices/COVIDExposureIndices/master/dex_data/county_dex.csv", clear | |
gen date_stata = date(date,"YMD") | |
format %td date_stata | |
clonevar fips = county | |
keep if inlist(date_stata,date("2020-02-14","YMD"),date("2020-03-27","YMD")) | |
merge m:1 fips using `tf_county_msa', keep(match) nogen | |
collapse (mean) dex (first) cbsa_name [w=num_devices], by(cbsa date_stata) | |
reshape wide dex, i(cbsa) j(date_stata) | |
gen DEX_lockdown = dex22001/ dex21959 | |
label variable DEX_lockdown "Device exposure on March 27 as share of Feb 14" | |
merge 1:1 cbsa using `tf_msa_wfh' | |
regress DEX_lockdown teleworkable_emp | |
predict residual, residual | |
replace residual = abs(residual) | |
summarize residual, d | |
gen byte outlier = inrange(residual,`r(p90)',.)==1 | |
twoway (scatter DEX_lockdown teleworkable_emp, msym(X) mcol(black)) (lfit DEX_lockdown teleworkable_emp, lcol(red) lstyle(dash)) /// | |
(scatter DEX_lockdown teleworkable_emp if outlier==1, msym(X) mcol(black) mlab(cbsa_name) mlabcol(gray) mlabsize(tiny)) /// | |
, graphregion(color(white)) legend(off) ytitle("Device exposure on March 27 as share of Feb 14 exposure") name(DEX_WFH_scatter_long_outliers, replace) /// | |
note("Device exposure index from Couture, Dingel, Green, Handbury, and Williams (2020)" "Work-at-home measure from Dingel and Neiman (2020)") | |
graph export "../output/DEX_WFH_scatter_long_labels.png", replace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment