| effect | R Documentation |
Calculates cumulative or average treatment effects for specified units and time periods based on a fitted fect object. The function supports both cumulative effects over time and period-specific average treatment effects, with bootstrap-based uncertainty estimates.
effect(
x,
cumu = TRUE,
id = NULL,
period = NULL,
plot = FALSE,
count = TRUE,
xlab = NULL,
ylab = NULL,
main = NULL
)
x |
A |
cumu |
Logical. If |
id |
Character vector or NULL. Unit identifiers to include in the analysis. If |
period |
Numeric vector of length 2 specifying the time window |
plot |
Logical. If |
count |
Logical. If |
xlab |
Character. X-axis label for the plot. |
ylab |
Character. Y-axis label for the plot. |
main |
Character. Main title for the plot. |
The function processes treatment effects in several steps:
1. Selects units based on the id parameter or includes all treated units if id = NULL.
2. Calculates relative time to treatment for each unit.
3. If cumu = TRUE, computes cumulative effects by summing average effects up to each period.
4. Performs bootstrap analysis to estimate uncertainty (standard errors, confidence intervals, and p-values).
The function supports different inference methods (bootstrap, jackknife, parametric) and adjusts calculations accordingly.
Note: The function requires bootstrap results in the input fect object (keep.sims = TRUE must be set when fitting the model).
Returns a list containing:
eff |
Vector of point estimates for cumulative or average treatment effects. |
est.eff |
Matrix containing the following columns:
|
The function will stop with an error if:
No bootstrap results are available in the input object
The panel contains treatment reversals
The specified ending period exceeds the maximum available period
Shiyun Hu, Licheng Liu, Ye Wang, and Yiqing Xu
Liu, L., Wang, Y., & Xu, Y. (2022). A Practical Guide to Counterfactual Estimators for Causal Inference with Time-Series Cross-Sectional Data. American Journal of Political Science, 68(1), 160-176.
fect, plot.fect
## Not run:
# Fit fect model with bootstrap
fit <- fect(Y ~ D + X, data = panel_data, keep.sims = TRUE)
# Calculate cumulative effects for all treated units
results <- effect(fit)
# Calculate period-specific effects for specific units
results_specific <- effect(fit,
cumu = FALSE,
id = c("unit1", "unit2"),
period = c(1, 4))
# View results
print(results$est.catt)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.