Package {ERRI}


Type: Package
Title: Economic Resilience and Recovery Index
Version: 0.1.0
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.
License: GPL (≥ 3)
Encoding: UTF-8
Depends: R (≥ 4.1.0)
Suggests: knitr, rmarkdown, testthat (≥ 3.0.0)
VignetteBuilder: knitr
Config/testthat/edition: 3
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2026-09-18 08:43:28 UTC; majum
Author: Anbukkani Perumal [aut], Mrinmoy Ray [aut], Chiranjit Mazumder [aut, cre, cph]
Maintainer: Chiranjit Mazumder <majumder.chira@icar.org.in>
Repository: CRAN
Date/Publication: 2026-09-28 10:50:02 UTC

ERRI: Economic Resilience and Recovery Index

Description

Counterfactual measurement of resistance, loss, recovery, stability, and transformation following an economic disruption.

Details

The main function is erri(). Bootstrap uncertainty is available through erri_bootstrap(), while erri_sensitivity() examines dependence on component weights.

Author(s)

Anbukkani Perumal, Mrinmoy Ray, and Chiranjit Mazumder


Screen a Series for a Single Structural Shock

Description

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.

Usage

detect_shocks(data, time, outcome, min_segment = 5L,
  direction = c("any", "down", "up"))

Arguments

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.

Value

A data frame of candidate times, scores, and estimated level shifts, sorted from strongest to weakest.

Examples

dat <- subset(erri_example_data(), region == "North")
head(detect_shocks(dat, "year", "income"))

Estimate the Economic Resilience and Recovery Index

Description

Constructs a counterfactual path from observations before a shock and measures the magnitude, persistence, and reversal of subsequent deviations.

Usage

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
)

Arguments

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: "trend", "mean", or "ar1".

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 resistance, loss, recovery, strength, stability, and transformation.

level

Confidence level for counterfactual prediction intervals.

Details

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.

Value

An object of class erri containing component estimates, scores, the composite index, trajectories, settings, and fitted models.

Examples

dat <- erri_example_data()
fit <- erri(dat, time = "year", outcome = "income",
            unit = "region", shock_time = 2020)
fit

Bootstrap Uncertainty for ERRI

Description

Uses a residual bootstrap of the pre-shock counterfactual model and propagates counterfactual uncertainty to components and ERRI.

Usage

erri_bootstrap(object, R = 499L, block_length = 1L, level = 0.95,
  seed = NULL)

## S3 method for class 'erri_bootstrap'
print(x, digits = 2, ...)

Arguments

object

An object returned by erri().

R

Number of bootstrap replications; at least 20.

block_length

Positive integer residual-block length.

level

Confidence level.

seed

Optional integer seed.

x

An erri_bootstrap object.

digits

Number of digits to display.

...

Additional arguments, currently unused.

Value

An object of class erri_bootstrap containing replicate estimates and percentile confidence intervals.

Examples

fit <- erri(erri_example_data(), "year", "income", 2020, "region")
boot <- erri_bootstrap(fit, R = 49, seed = 1)
boot

Example Regional Economic Data

Description

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.

Usage

erri_example_data()

Value

A data frame with region, year, and income.

Examples

dat <- erri_example_data()
head(dat)

Weight-Sensitivity Analysis for ERRI

Description

Generates random non-negative weights on the simplex and recalculates the index and rank of each unit.

Usage

erri_sensitivity(object, R = 1000L, seed = NULL)

Arguments

object

An object returned by erri().

R

Number of random weight vectors.

seed

Optional integer seed.

Value

A data frame containing sampled weights, indices, and ranks.

Examples

fit <- erri(erri_example_data(), "year", "income", 2020, "region")
sens <- erri_sensitivity(fit, R = 100, seed = 3)
head(sens)

Plot an ERRI Trajectory or Index Comparison

Description

Plots the observed and counterfactual paths with a prediction interval, compares composite indices, or compares component scores.

Usage

## S3 method for class 'erri'
plot(x, type = c("trajectory", "index", "components"),
  unit = NULL, ...)

Arguments

x

An object returned by erri().

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.

Value

The object invisibly.

Examples

fit <- erri(erri_example_data(), "year", "income", 2020, "region")
plot(fit, type = "index")

Print and Summarize ERRI Results

Description

Displays the principal ERRI component estimates and returns a structured summary.

Usage

## S3 method for class 'erri'
print(x, digits = 2, ...)

## S3 method for class 'erri'
summary(object, ...)

Arguments

x

An object returned by erri().

digits

Number of digits to display.

object

An object returned by erri().

...

Additional arguments, currently unused.

Value

The object invisibly for print; a summary list for summary.


Ranking Probabilities from Bootstrap Estimates

Description

Calculates pairwise probabilities that one unit's bootstrapped ERRI exceeds another unit's ERRI.

Usage

rank_probability(object)

Arguments

object

An object returned by erri_bootstrap().

Value

A square matrix of pairwise probabilities.

Examples

fit <- erri(erri_example_data(), "year", "income", 2020, "region")
boot <- erri_bootstrap(fit, R = 49, seed = 2)
rank_probability(boot)