| scm_fit | R Documentation |
Unified formula interface for Synthetic Control and related causal inference methods. The formula syntax is:
scm_fit(
formula,
data,
method = c("scm", "sdid", "gsc", "mc", "tasc", "si"),
predictors = NULL,
covariates = NULL,
v_selection = c("insample", "oos"),
donor_mspe_threshold = Inf,
lambda_pen = NULL,
v_optim = c("auto", "coord_descent", "bfgs", "multistart"),
qp_solver = c("active_set", "wolfe"),
v_window = NULL,
nu = NULL,
fixedeff = FALSE,
...
)
formula |
A |
data |
A |
method |
One of |
predictors |
A |
covariates |
An optional named |
v_selection |
V matrix selection method for |
donor_mspe_threshold |
Donor pool filtering threshold (Abadie 2021 S.4).
For |
lambda_pen |
Penalised SCM parameter (Abadie & L'Hour 2021, JASA).
For |
v_optim |
Outer V-optimisation method for |
qp_solver |
Inner-QP solver for |
v_window |
Optional vector of pre-treatment time values (matching the
time index in |
nu |
Partial pooling parameter for staggered SCM fits
(Ben-Michael, Feller & Rothstein 2022, JRSS-B). |
fixedeff |
If |
... |
Additional arguments forwarded to the specific method
(e.g. |
outcome ~ treatment | unit_id + time_id
An object of classes c("coresynth_<method>", "coresynth").
Fits with staggered adoption additionally inherit from
"coresynth_staggered", and multi-arm SI fits from
"coresynth_multiarm"; S3 methods such as tidy() and augment()
dispatch on these subclasses.
All methods return at minimum:
method: estimator name
estimate: average treatment effect (ATT)
times: time index vector
T_pre: number of pre-treatment periods
Y_treat: treated unit outcome series
gap: treatment effect series (Y_treat - counterfactual)
# Synthetic balanced panel: 10 units over 20 periods, unit 1 treated
# after period 15.
set.seed(1)
panel <- expand.grid(unit = 1:10, year = 1:20)
panel$treated <- as.integer(panel$unit == 1 & panel$year > 15)
panel$gdp <- panel$unit + 0.5 * panel$year +
rnorm(nrow(panel)) + 3 * panel$treated
fit <- scm_fit(gdp ~ treated | unit + year, data = panel, method = "sdid")
summary(fit)
# Visualise the estimated gap (requires ggplot2)
plot(fit, type = "gap")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.