did_estimate_yearly_effects {fixest} | R Documentation |
This facility helps to estimate yearly treatment effects in a difference-in-difference setup without having to manually make the estimation. It is made as general as possible such that non-fixest
estimation functions can also be used.
did_estimate_yearly_effects(fml, data, treat_time, reference, returnData = FALSE, ..., estfun = feols)
fml |
A formula containing the variables WITHOUT the yearly treatment effects (which will be added by this function). |
data |
A |
treat_time |
Either a character vector of length two containing the name of the treatment variable and the name of the time variable (e.g. |
reference |
The time period of reference. It should be a numeric scalar. The treatment will not be included for this time period so that it serves as reference. |
returnData |
Logical, default is |
... |
Other arguments to be passed to |
estfun |
The estimation function. Defaults to |
It returns an estimation object. In case of fixest
estimations, it will return a fixest
object.
Laurent Berge
did_plot_yearly_effects
, errbar
.
# Sample data illustrating the DiD data(base_did) # Estimation of yearly effect (they are automatically added) est = did_estimate_yearly_effects(y ~ x1 + treat + post, base_did, treat_time = ~treat+period, reference = 5) # Now we plot the results did_plot_yearly_effects(est) # Now with fixed-effects: est_fe = did_estimate_yearly_effects(y ~ x1 | id + period, base_did, treat_time = ~treat+period, reference = 5) did_plot_yearly_effects(est_fe) # you can change the type of SE to be plotted: did_plot_yearly_effects(est_fe, se = "cluster") # default did_plot_yearly_effects(est_fe, se = "standard")