Skip to content

Instantly share code, notes, and snippets.

@jdingel
Created May 8, 2020 02:51
Show Gist options
  • Save jdingel/b139b4ba65a9ac4efc904dfada09b165 to your computer and use it in GitHub Desktop.
Save jdingel/b139b4ba65a9ac4efc904dfada09b165 to your computer and use it in GitHub Desktop.
Compare Georgia's DEX to rest of country
import delimited using "https://raw.githubusercontent.com/COVIDExposureIndices/COVIDExposureIndices/master/dex_data/state_dex.csv", clear
keep state date dex num_devices dex_a num_devices_a
gen date_stata = date(date,"YMD")
format %td date_stata
gen baseline_date = mod(date_stata - 21934,7)
bys state baseline_date (date_stata): egen baseline_dex_a = total(dex_a * inrange(date_stata,0,21954))
by state baseline_date (date_stata): egen baseline_denom = total(inrange(date_stata,0,21954))
gen dex_a_relative = dex_a / (baseline_dex_a / baseline_denom)
gen byte Georgia = (state=="GA")
collapse (mean) dex_a_relative [w=num_devices], by(date_stata Georgia)
twoway (line dex_a_relative date_stata if Georgia==1, lcol(red)) (line dex_a_relative date_stata if Georgia==0, lcol(blue) lpattern(dash)) ///
, graphregion(color(white)) ytitle("Device exposure as share of average for 20 Jan - 9 Feb") xlabel(#6) xtitle("") legend(label(1 "Georgia") label(2 "All other states") lwidth(none)) ///
note("Device exposure index from Couture, Dingel, Green, Handbury, and Williams (2020)." "Device exposure is measured relative to its average level on the same day of the week in Jan 20 – Feb 9." "State-level DEX values are weighted by their number of devices to produce a non-Georgia average.")
graph export "~/Desktop/Georgia.png", replace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment