Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot.emfx #54

Merged
merged 8 commits into from
Dec 16, 2024
Merged

plot.emfx #54

merged 8 commits into from
Dec 16, 2024

Conversation

grantmcdermott
Copy link
Owner

Closes #53

Examples borrowed from the updated vignette.

library(etwfe)

data("mpdta", package = "did")

mod_es2 = etwfe(
  lemp ~ lpop, tvar = year, gvar = first.treat, data = mpdta, vcov = ~countyreal,
  cgroup = "never" # <= use never treated as control group
) |>
  emfx(type = "event")

plot(mod_es2)

# args passed to tinyplot
plot(
  mod_es2,
  type = "ribbon",
  col  = "darkcyan",
  xlab = "Years post treatment",
  main = "Minimum wage effect on (log) teen employment",
  sub  = "Note: Using never-treated as control group"
)

#
# Fancier heterogeneous treatment effects example 
#
gls_fips = c("IL" = 17, "IN" = 18, "MI" = 26, "MN" = 27,
             "NY" = 36, "OH" = 39, "PA" = 42, "WI" = 55)
mpdta$gls = substr(mpdta$countyreal, 1, 2) %in% gls_fips
etwfe(
  lemp ~ lpop, tvar = year, gvar = first.treat, data = mpdta,
  cgroup = "never",
  vcov = ~countyreal,
  xvar = gls           ## <= het. TEs by gls
) |>
  emfx("event") |>
  plot()

Created on 2024-12-16 with reprex v2.1.1

@grantmcdermott grantmcdermott merged commit 081d5d8 into main Dec 16, 2024
5 of 6 checks passed
@grantmcdermott grantmcdermott deleted the plot branch December 16, 2024 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add native plot.emfx method
1 participant