Accessor generics that return the outcome series stored in a fitted
coresynth object under a uniform interface, regardless of the estimation
method:
Usage
treated_outcomes(x, ...)
# S3 method for class 'coresynth'
treated_outcomes(x, na.rm = FALSE, ...)
synthetic_outcomes(x, ...)
# S3 method for class 'coresynth'
synthetic_outcomes(x, na.rm = FALSE, ...)
# S3 method for class 'coresynth_tasc'
synthetic_outcomes(x, na.rm = FALSE, ...)
donor_outcomes(x, ...)
# S3 method for class 'coresynth_scm'
donor_outcomes(x, ...)
# S3 method for class 'coresynth_sdid'
donor_outcomes(x, ...)
# S3 method for class 'coresynth_si'
donor_outcomes(x, ...)
# S3 method for class 'coresynth_gsc'
donor_outcomes(x, ...)
# S3 method for class 'coresynth_mc'
donor_outcomes(x, ...)
# S3 method for class 'coresynth_tasc'
donor_outcomes(x, ...)
# S3 method for class 'coresynth'
donor_outcomes(x, ...)Arguments
- x
A
coresynthobject fromscm_fit().- ...
Passed to methods.
- na.rm
Logical; passed to the per-period averaging over multiple treated units (default
FALSE).
Value
For treated_outcomes() and synthetic_outcomes(), a numeric
vector of length \(T\), or NULL. For donor_outcomes(), a
\(T \times N_{co}\) numeric matrix (donors in columns, named when unit
names are available), or NULL.
Details
treated_outcomes(): the treated unit's observed outcome series (length \(T\)). When several units are treated, their per-period mean.synthetic_outcomes(): the estimated counterfactual series (length \(T\)), i.e. the synthetic control or model-fitted outcome.donor_outcomes(): the \(T \times N_{co}\) matrix of observed donor (control unit) outcomes over all periods.
Each accessor returns NULL when the requested series is not stored in
the fit. In particular, staggered-adoption fits keep their data per cohort
(in fit$cohort_fits), so the sharp-fit accessors return NULL for them.
Examples
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 = "scm")
#> predictors = NULL: using the outcome in each of the 15 pre-treatment periods as predictors (outcomes-only SCM).
y1 <- treated_outcomes(fit) # observed treated series
y1_0 <- synthetic_outcomes(fit) # synthetic counterfactual
Yco <- donor_outcomes(fit) # donor outcome matrix
all.equal(y1 - y1_0, unname(fit$gap))
#> [1] TRUE
