MyNixOS website logo
Description

Visual Diagnostic Checks for Vector Autoregressive Models.

Provides model-agnostic visual diagnostics for vector autoregressive (VAR) models. Given empirical data, model predictions, residuals, and optionally simulated data, the package assembles a multi-panel diagnostic grid: empirical vs. predicted time series, residual inspection, residuals vs. predictions scatter, and posterior predictive style checks via simulated trajectories. Output is a 'patchwork' object composed of 'ggplot2' plots, allowing further customisation via standard 'ggplot2' theme calls. Follows the approach described in Haslbeck et al. (2026) <doi:10.31234/osf.io/k6uz4_v3>.

VARcheck

Codecov test coverage R-CMD-check

VARcheck produces diagnostic grids for vector autoregressive (VAR) models. Given your model's empirical data, predictions, and residuals, it assembles a multi-panel figure that makes the quality of the fit visible.

The package is model-agnostic: it works with any VAR implementation (mlVAR, vars, DSEM, custom code) as long as you can supply a matrix of empirical values, a matrix of predictions, and a matrix of residuals.

The package website includes a getting started guide with a full walkthrough, and an example analyses vignette that reproduces the simulated misfit examples from Haslbeck et al. (2026).

Installation

Install the released version from CRAN:

install.packages("VARcheck")

Or install the development version from GitHub:

# install.packages("devtools")
devtools::install_github("bsiepe/VARcheck")

Usage

Wrap your data in a var_data object, then call plot_var_check(). We provide a longer instruction in the package vignette, but the basic workflow looks like this:

library(VARcheck)

vd <- new_var_data(
  empirical  = emp,     # T × p matrix of observed values
  predicted  = pred,    # T × p matrix of model predictions
  residuals  = res,     # T × p matrix of residuals
  simulated  = sim,     # T × p matrix of posterior-predictive simulations (optional)
  var_names  = c("Mood", "Energy", "Fatigue", "Anxiety")
)

plot_var_check(vd)

Each row of the output corresponds to one variable and contains four column groups:

ColumnContent
Empirical & PredictedTime series of observed vs. predicted values, annotated with R² and RMSE
ResidualsResiduals over time, annotated with AR(1) coefficient and 95% CI
Residuals vs. PredictedScatter of residuals against predictions
SimulatedTime series simulated from the fitted model

Marginal histograms with a Gaussian overlay appear next to each time-series panel.

Options

Select variables or panels

# Show only two variables
plot_var_check(vd, vars = c("Mood", "Energy"))

# Drop the simulated column
plot_var_check(vd, panels = c("data", "residuals", "scatter"))

Multiple subjects

Pass a list of matrices (one per subject) to new_var_data(). Use the subject argument to select which one to plot.

vd_multi <- new_var_data(
  empirical = list(emp_s1, emp_s2, emp_s3),
  predicted = list(pred_s1, pred_s2, pred_s3),
  residuals = list(res_s1, res_s2, res_s3)
)

plot_var_check(vd_multi, subject = 2)

Colours and theme

# Change line colours (partial override merges with defaults)
plot_var_check(vd, colors = list(predicted = "steelblue"))

# Override any theme element
plot_var_check(vd, theme = ggplot2::theme(text = ggplot2::element_text(size = 9)))

The default theme is theme_varcheck(), which is a minimal ggplot2 theme you can use on its own.

Reference

Please cite the following paper when using this package:

Haslbeck, J. M. B., Jongerling, J., Siepe, B. S., Epskamp, S., & Waldorp, L. (2026). Model Checking for Vector Autoregressive Modelshttps://doi.org/10.31234/osf.io/k6uz4_v3

Metadata

Version

0.1.0

License

Unknown

Platforms (80)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows