DD_manu | R Documentation |
Diff Diff manual table
DD_manu(
data,
y_var = "y",
time.index = "Time",
treat = "tr",
unit.index = "unit",
control_gr = "0_0",
treat_gr = "0_1",
time_subset = NULL,
subperiod = NULL
)
data |
A data frame containing the variables of itnerest, should have names |
y_var |
The name of the y variable |
time.index |
The name of the variable describing the time index (date, year, etc) |
treat |
The name of the treatment variable. |
unit.index |
The name of the units (individual, county, household, etc). |
control_gr |
The control group of interest |
treat_gr |
The treatment group of interest |
time_subset |
The restriction of time period (if gave more than 2 periods) |
subperiod |
A variable indicating how to group, exclude time periods. See details. |
dat_DiD_1 <- sim_dat_staggered(Time=2, timing_treatment=2)
DD_manu(data=dat_DiD_1)
## Compare with felm
library(lfe)
felm(y~tr|unit+Time, data=dat_DiD_1)
## DiD for longer sequences
dat_DiD_long <- sim_dat_staggered(Time=10, timing_treatment=6)
DD_manu(data=dat_DiD_long, control_gr=paste(rep(0, 10), collapse = "_"),
treat_gr=paste(c(rep(0, 5), rep(1,5)), collapse = "_"),
subperiod= rep(c("pre", "post"), each=5))
DD_manu(data=dat_DiD_long, control_gr=paste(rep(0, 10), collapse = "_"),
treat_gr=paste(c(rep(0, 5), rep(1,5)), collapse = "_"),
subperiod= rep(c("placebo", "pre", "post", "dynamic"), c(4,1,1,4)))
felm(y~tr|unit+Time, data=dat_DiD_long)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.