| Title: | Economic Resilience and Recovery Index |
|---|---|
| Description: | Estimates multidimensional economic resilience following a disruption by comparing observed outcomes with a counterfactual path. Components describe shock depth, cumulative loss, recovery time, recovery strength, post-shock stability, and positive transformation. The package supports grouped analysis, residual-bootstrap uncertainty, alternative weighting schemes, ranking probabilities, sensitivity analysis, shock screening, and diagnostic plots. Methods are designed for regional, sectoral, market, and other regularly observed economic time series. |
| Authors: | Anbukkani Perumal [aut], Mrinmoy Ray [aut], Chiranjit Mazumder [aut, cre, cph] |
| Maintainer: | Chiranjit Mazumder <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-09-28 15:53:35 UTC |
| Source: | https://github.com/cran/ERRI |
Counterfactual measurement of resistance, loss, recovery, stability, and transformation following an economic disruption.
The main function is erri(). Bootstrap uncertainty is
available through erri_bootstrap(), while erri_sensitivity()
examines dependence on component weights.
Anbukkani Perumal, Mrinmoy Ray, and Chiranjit Mazumder
Evaluates admissible split points using the proportional reduction in residual sum of squares from separate linear trends. This is a screening diagnostic and not a causal identification procedure.
detect_shocks(data, time, outcome, min_segment = 5L, direction = c("any", "down", "up"))detect_shocks(data, time, outcome, min_segment = 5L, direction = c("any", "down", "up"))
data |
A data frame. |
time |
Character string naming the ordered time column. |
outcome |
Character string naming the numeric outcome column. |
min_segment |
Minimum observations on each side of a candidate split. |
direction |
Whether to retain any, downward, or upward shifts. |
A data frame of candidate times, scores, and estimated level shifts, sorted from strongest to weakest.
dat <- subset(erri_example_data(), region == "North") head(detect_shocks(dat, "year", "income"))dat <- subset(erri_example_data(), region == "North") head(detect_shocks(dat, "year", "income"))
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 )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 , counterfactual , and pre-shock scale
, the adverse gap is . 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) fitdat <- erri_example_data() fit <- erri(dat, time = "year", outcome = "income", unit = "region", shock_time = 2020) fit
Uses a residual bootstrap of the pre-shock counterfactual model and propagates counterfactual uncertainty to components and ERRI.
erri_bootstrap(object, R = 499L, block_length = 1L, level = 0.95, seed = NULL) ## S3 method for class 'erri_bootstrap' print(x, digits = 2, ...)erri_bootstrap(object, R = 499L, block_length = 1L, level = 0.95, seed = NULL) ## S3 method for class 'erri_bootstrap' print(x, digits = 2, ...)
object |
An object returned by |
R |
Number of bootstrap replications; at least 20. |
block_length |
Positive integer residual-block length. |
level |
Confidence level. |
seed |
Optional integer seed. |
x |
An |
digits |
Number of digits to display. |
... |
Additional arguments, currently unused. |
An object of class erri_bootstrap containing replicate
estimates and percentile confidence intervals.
fit <- erri(erri_example_data(), "year", "income", 2020, "region") boot <- erri_bootstrap(fit, R = 49, seed = 1) bootfit <- erri(erri_example_data(), "year", "income", 2020, "region") boot <- erri_bootstrap(fit, R = 49, seed = 1) boot
Reads the installed example data containing annual real-income indices for three fictional regions from 2010 through 2025. A disruption begins in 2020 and the regions have heterogeneous recovery paths.
erri_example_data()erri_example_data()
A data frame with region, year, and income.
dat <- erri_example_data() head(dat)dat <- erri_example_data() head(dat)
Generates random non-negative weights on the simplex and recalculates the index and rank of each unit.
erri_sensitivity(object, R = 1000L, seed = NULL)erri_sensitivity(object, R = 1000L, seed = NULL)
object |
An object returned by |
R |
Number of random weight vectors. |
seed |
Optional integer seed. |
A data frame containing sampled weights, indices, and ranks.
fit <- erri(erri_example_data(), "year", "income", 2020, "region") sens <- erri_sensitivity(fit, R = 100, seed = 3) head(sens)fit <- erri(erri_example_data(), "year", "income", 2020, "region") sens <- erri_sensitivity(fit, R = 100, seed = 3) head(sens)
Plots the observed and counterfactual paths with a prediction interval, compares composite indices, or compares component scores.
## S3 method for class 'erri' plot(x, type = c("trajectory", "index", "components"), unit = NULL, ...)## S3 method for class 'erri' plot(x, type = c("trajectory", "index", "components"), unit = NULL, ...)
x |
An object returned by |
type |
Trajectory, index, or component-score plot. |
unit |
Unit to display for a trajectory; defaults to the first unit. |
... |
Additional arguments passed to the base plotting function. |
The object invisibly.
fit <- erri(erri_example_data(), "year", "income", 2020, "region") plot(fit, type = "index")fit <- erri(erri_example_data(), "year", "income", 2020, "region") plot(fit, type = "index")
Displays the principal ERRI component estimates and returns a structured summary.
## S3 method for class 'erri' print(x, digits = 2, ...) ## S3 method for class 'erri' summary(object, ...)## S3 method for class 'erri' print(x, digits = 2, ...) ## S3 method for class 'erri' summary(object, ...)
x |
An object returned by |
digits |
Number of digits to display. |
object |
An object returned by |
... |
Additional arguments, currently unused. |
The object invisibly for print; a summary list for
summary.
Calculates pairwise probabilities that one unit's bootstrapped ERRI exceeds another unit's ERRI.
rank_probability(object)rank_probability(object)
object |
An object returned by |
A square matrix of pairwise probabilities.
fit <- erri(erri_example_data(), "year", "income", 2020, "region") boot <- erri_bootstrap(fit, R = 49, seed = 2) rank_probability(boot)fit <- erri(erri_example_data(), "year", "income", 2020, "region") boot <- erri_bootstrap(fit, R = 49, seed = 2) rank_probability(boot)