knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4.5)
Economic resilience is not a single observed variable. ERRI represents it as
six complementary dimensions calculated relative to an estimated no-shock
counterfactual. Let the observed outcome for unit $i$ at time $t$ be $Y_{it}$
and its counterfactual be $Y^{(0)}_{it}$. The scaled adverse gap is
$$ G_{it}=\frac{Y^{(0)}{it}-Y{it}}{s_i}, $$
where $s_i$ is the pre-shock standard deviation, absolute mean, or one.
The package measures maximum adverse gap (depth), summed adverse gap (cumulative loss), time required to remain within a tolerance, strength of recovery, post-shock residual volatility relative to pre-shock volatility, and positive performance beyond the counterfactual after recovery.
library(ERRI) dat <- erri_example_data() head(dat)
The example contains three fictional regional income series. The shock begins in 2020.
fit <- erri(dat, time = "year", outcome = "income", unit = "region", shock_time = 2020, method = "trend", scale = "sd", epsilon = 0.25, consecutive = 2) fit
plot(fit, type = "trajectory", unit = "North")
plot(fit, type = "index")
Residual bootstrap intervals propagate uncertainty in the pre-shock counterfactual. At least several hundred replications are recommended for an empirical study.
boot <- erri_bootstrap(fit, R = 99, seed = 2026) subset(boot$intervals, measure == "ERRI") rank_probability(boot)
The default weights are equal. The following analysis draws random weights from the simplex and recalculates scores and rankings.
sens <- erri_sensitivity(fit, R = 250, seed = 2026) aggregate(ERRI ~ unit, sens, function(x) c(mean = mean(x), sd = sd(x)))
A higher score denotes stronger measured resilience under the selected model, scale, tolerance, and weights. The score is not automatically causal. A shock date must be substantively justified, and a trend, mean, or AR(1) counterfactual may be inadequate when other events affect the outcome. Report component estimates, bootstrap intervals, and weight sensitivity rather than only the composite index.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.