synthdid_est_per.Rd
Given the output from the synthdid::synthdid_estimate
method, this function computes the
treatment effects (TEs) for each post-treatment period, along with the cumulative
average treatment effect (ATE). It also provides observed and predicted outcomes
for treated units, synthetic control weights, and counts of treated and control units.
synthdid_est_per(Y, N0, T0, weights)
Data matrix with units as rows and time periods as columns.
Number of control units.
Number of pre-treatment periods.
Output from synthdid
, containing lambda and omega weights.
A list containing:
est: TEs for each post-treatment period and cumulative ATEs.
y_obs: Observed outcomes for treated units.
y_pred: Predicted outcomes for treated units.
lambda.synth: Synthetic control lambda weights.
Ntr: Number of treated units.
Nco: Number of control units.
if (FALSE) {
library(tidyverse)
library(synthdid)
library(fixest)
setup <- base_did |>
mutate(
id = as.factor(id),
period = as.integer(period),
y = as.double(y),
post = as.integer(post)
) |>
# Correct treatment
dplyr::mutate(treatment = as.integer(if_else(treat == 0, 0, post))) |>
synthdid::panel.matrices(unit = "id", time = "period", outcome = "y", treatment = "treatment")
sdid <- synthdid::synthdid_estimate(setup$Y, setup$N0, setup$T0)
synthdid_est_per(setup$Y, setup$N0, setup$T0, weights = attr(sdid, 'weights'))
}