Learn R Programming

exdqlm (version 0.4.0)

exdqlmDiagnostics: exDQLM Diagnostics

Description

The function computes the following for the model(s) provided: the posterior predictive loss criterion based off the check loss, the CRPS from posterior predictive draws, the one-step-ahead distribution sequence, and both the forward and reversed KL divergences from normality. The function also plots the following: the qq-plot and ACF plot corresponding to the one-step-ahead distribution sequence, and a time series plot of the MAP standard forecast errors.

Usage

exdqlmDiagnostics(
  m1,
  m2 = NULL,
  plot = TRUE,
  cols = c("red", "blue"),
  ref = NULL
)

Value

An object of class "exdqlmDiagnostic" containing the following:

  • m1.uts - The one-step-ahead distribution sequence of m1.

  • m1.KL - The KL divergence of m1.uts and a standard normal.

  • m1.KL.flip - The reversed ("flipped") KL divergence of m1.uts and a standard normal.

  • m1.CRPS - The mean CRPS computed from posterior predictive draws.

  • m1.pplc - The posterior predictive loss criterion of m1 based off the check loss function.

  • m1.qq - The ordered pairs of the qq-plot comparing m1.uts with a standard normal distribution.

  • m1.acf - The autocorrelations of m1.uts by lag.

  • m1.rt - Run-time of the original model m1 in seconds.

  • m1.msfe - MAP standardized one-step-ahead forecast errors from the original model m1.

  • y - The original time-series used to fit m1.

If m2 is provided, analogous results for m2 are also included in the list.

Arguments

m1

An object of class "exdqlmLDVB", "exdqlmMCMC", or legacy "exdqlmISVB".

m2

An optional additional object of class "exdqlmLDVB", "exdqlmMCMC", or legacy "exdqlmISVB" to compare with m1.

plot

Logical value indicating whether the following will be plotted for m1 and m2 (if provided): a qq-plot and ACF plot of the MAP one-step-ahead distribution sequence, and a time series plot of the standardized forecast errors. Default is TRUE.

cols

Character vector of length 1 or 2 giving color(s) used to plot diagnostics. Default c("red","blue").

ref

Optional reference sample of size length(m1$y) from a standard normal distribution. Used to compute the KL divergences.

Examples

Run this code
# \donttest{
data("scIVTmag", package = "exdqlm")
old = options(exdqlm.max_iter = 15L)
y = scIVTmag[1:60]
model = polytrendMod(1, stats::quantile(y, 0.85), 10)
M0 = exdqlmLDVB(y, p0 = 0.85, model, df = c(0.95), dim.df = c(1),
                  gam.init = -3.5, sig.init = 15,
                  n.samp = 20, tol = 0.2, verbose = FALSE)
M0.diags = exdqlmDiagnostics(M0, plot = FALSE)
options(old)
# }

Run the code above in your browser using DataLab