## ----setup, include=FALSE----------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4.5) ## ----------------------------------------------------------------------------- library(ERRI) dat <- erri_example_data() head(dat) ## ----------------------------------------------------------------------------- fit <- erri(dat, time = "year", outcome = "income", unit = "region", shock_time = 2020, method = "trend", scale = "sd", epsilon = 0.25, consecutive = 2) fit ## ----fig.cap="Observed and counterfactual paths with a prediction interval."---- plot(fit, type = "trajectory", unit = "North") ## ----fig.cap="Comparison of composite ERRI estimates."------------------------ plot(fit, type = "index") ## ----------------------------------------------------------------------------- boot <- erri_bootstrap(fit, R = 99, seed = 2026) subset(boot$intervals, measure == "ERRI") rank_probability(boot) ## ----------------------------------------------------------------------------- sens <- erri_sensitivity(fit, R = 250, seed = 2026) aggregate(ERRI ~ unit, sens, function(x) c(mean = mean(x), sd = sd(x)))