Learn R Programming

exdqlm (version 0.4.0)

exalStaticDiagnostics: exAL Diagnostics

Description

Static diagnostics companion for exalStaticLDVB() and exalStaticMCMC(). The function summarizes fitted quantiles on a shared design matrix, reports mean check loss against observed responses when available, and can optionally compare the fitted quantile curve against a known reference quantile function.

Usage

exalStaticDiagnostics(
  m1,
  m2 = NULL,
  X = NULL,
  y = NULL,
  ref = NULL,
  plot = TRUE,
  cols = c("red", "blue"),
  cr.percent = 0.95
)

Value

An object of class "exalStaticDiagnostic" containing fitted-quantile summaries, residual summaries (when y is provided), optional reference-curve error metrics, and run-time metadata for m1 and m2 (if supplied).

Arguments

m1

An object of class "exalStaticLDVB" or "exalStaticMCMC".

m2

Optional second fitted static model to compare against m1.

X

Optional design matrix. If omitted, the function uses m1$X when available.

y

Optional response vector. If omitted, the function uses m1$y when available.

ref

Optional reference quantile vector on the same rows as X.

plot

Logical; if TRUE, produce a compact static-diagnostics plot.

cols

Character vector of length 1 or 2 giving colors for plotted diagnostics.

cr.percent

Credible-interval mass used when summarizing fitted quantiles.

Details

Unlike exdqlmDiagnostics, which is built around one-step-ahead dynamic forecast diagnostics, exalStaticDiagnostics() is designed for the static regression setting. It reports fitted quantile summaries on a common design matrix, optional mean check loss against observed responses, optional truth/reference errors, and compact comparison plots.

Examples

Run this code
# \donttest{
set.seed(1)
x <- seq(-2, 2, length.out = 60)
X <- cbind(1, x)
y <- 0.5 * x + (1.2 + 0.35 * x) * stats::rnorm(length(x))
q_true <- 0.5 * x + (1.2 + 0.35 * x) * stats::qnorm(0.25)

fit_ldvb <- exalStaticLDVB(
  y = y, X = X, p0 = 0.25,
  max_iter = 60, tol = 1e-3,
  verbose = FALSE
)
fit_mcmc <- exalStaticMCMC(
  y = y, X = X, p0 = 0.25,
  n.burn = 60, n.mcmc = 60,
  mh.proposal = "slice",
  verbose = FALSE
)
out <- exalStaticDiagnostics(fit_ldvb, fit_mcmc, ref = q_true, plot = FALSE)
print(out)
# }

Run the code above in your browser using DataLab