compute_residual_diagnostics: Residual diagnostics for a forecast

View source: R/diagnostics.R

compute_residual_diagnosticsR Documentation

Residual diagnostics for a forecast

Description

Whether a fitted model's error looks like unpredictable noise, or still has structure left in it: a Ljung-Box test for residual autocorrelation, a Shapiro-Wilk normality test, and the residual ACF with its Box-Jenkins confidence band. Generic across every registered model – only needs fc_tib's ds/yhat and test_df's ds/y.

Usage

compute_residual_diagnostics(fc_tib, test_df)

Arguments

fc_tib

A tibble with ds/yhat columns – a model's forecast.

test_df

A tibble with ds/y columns – the held-out actuals.

Value

A list with residuals (tibble of ds/resid), ljung_box_p, shapiro_p (each NA if there isn't enough overlapping data), acf_df (tibble of lag/acf), ci (the confidence bound), and n.

Examples

ds <- as.Date("2024-01-01") + 0:29
fc_tib <- tibble::tibble(ds = ds, yhat = 100)
test_df <- tibble::tibble(ds = ds, y = 100 + rnorm(30))
compute_residual_diagnostics(fc_tib, test_df)

forecastsuite documentation built on Oct. 18, 2026, 5:08 p.m.