| erri | R Documentation |
Constructs a counterfactual path from observations before a shock and measures the magnitude, persistence, and reversal of subsequent deviations.
erri(
data,
time,
outcome,
shock_time,
unit = NULL,
method = c("trend", "mean", "ar1"),
scale = c("sd", "mean", "none"),
epsilon = 0.25,
consecutive = 2L,
weights = NULL,
level = 0.95
)
data |
A data frame containing regularly ordered observations. |
time |
Character string naming the time column. |
outcome |
Character string naming the numeric outcome column. |
shock_time |
One common shock time or a named vector of group-specific shock times. |
unit |
Optional character string naming the grouping column. |
method |
Counterfactual method: |
scale |
Gap scaling based on the pre-shock standard deviation, absolute mean, or no scaling. |
epsilon |
Non-negative recovery tolerance in scaled-gap units. |
consecutive |
Positive number of consecutive observations required to declare recovery. |
weights |
Named non-negative weights for |
level |
Confidence level for counterfactual prediction intervals. |
For outcome Y_t, counterfactual Y_t^0, and pre-shock scale
s, the adverse gap is G_t=(Y_t^0-Y_t)/s. Shock depth is the
largest positive gap and cumulative loss is the sum of positive post-shock gaps.
Recovery occurs when the absolute gap remains within epsilon for the
specified number of observations. The remaining components measure the rate
of gap closure, relative post-shock instability, and positive transformation.
With multiple units, component scores use cross-unit min-max scaling. A single-unit analysis uses bounded absolute transformations. The composite ERRI is the weighted mean of component scores multiplied by 100.
An object of class erri containing component estimates, scores,
the composite index, trajectories, settings, and fitted models.
dat <- erri_example_data()
fit <- erri(dat, time = "year", outcome = "income",
unit = "region", shock_time = 2020)
fit
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.