predict.exdqlmFit: Forecast Method for Dynamic 'exdqlmFit' Objects

View source: R/exdqlmFit_methods.R

predict.exdqlmFitR Documentation

Forecast Method for Dynamic exdqlmFit Objects

Description

Computes filtered and k-step-ahead forecast quantiles from a fitted dynamic quantile model. The returned exdqlmForecast object can be printed, summarized, plotted with plot(), or passed to diagnostics.

Usage

## S3 method for class 'exdqlmFit'
predict(
  object,
  start.t,
  k,
  fFF = NULL,
  fGG = NULL,
  plot = FALSE,
  add = FALSE,
  cols = c("purple", "magenta"),
  cr.percent = 0.95,
  return.draws = FALSE,
  n.samp = NULL,
  seed = NULL,
  ...
)

Arguments

object

A fitted dynamic exdqlmFit object.

start.t

Integer index at which forecasts start.

k

Integer number of steps ahead to forecast.

fFF

Optional state vector(s) for the forecast steps. A numeric matrix with q rows and either 1 column (non–time-varying) or k columns (time-varying). Its dimension must match the fitted model in object.

fGG

Optional evolution matrix/matrices for the forecast steps. Either a numeric q \times q matrix (non–time-varying) or a q \times q \times k array (time-varying). Its dimensions must match the fitted model in object.

plot

Logical; if TRUE, immediately plot the returned forecast object as a convenience shortcut. Default is FALSE.

add

Logical value indicating whether to add the forecasted quantiles to the current plot. Default is FALSE.

cols

Optional character vector of length 2 giving the colors for filtered and forecasted quantiles respectively. Default c("purple","magenta").

cr.percent

Optional numeric in (0, 1) indicating the probability mass for the credible intervals (e.g., 0.95). Default 0.95.

return.draws

Optional logical; if TRUE, the function also returns a matrix of posterior predictive forecast draws in samp.fore. Default is FALSE.

n.samp

Optional positive integer specifying how many forecast draws to return when return.draws = TRUE. If omitted, all available posterior (\sigma,\gamma) draws from m1 are used.

seed

Optional integer random seed used only for forecast-draw generation when return.draws = TRUE. If provided, the previous R RNG state is restored on exit.

...

Additional arguments (unused).

Value

An object of class "exdqlmForecast" containing the following:

  • start.t Integer index at which forecasts start (within the span of the fitted model in m1).

  • k Integer number of steps ahead forecasted.

  • m1 The fitted exDQLM model object used to initialize the forecast.

  • cr.percent The probability mass for the credible intervals (e.g., 0.95).

  • fa Forecast state mean vectors (q \times k matrix).

  • fR Forecast state covariance matrices (q \times q \times k array).

  • ff Forecast quantile means (length-k numeric).

  • fQ Forecast quantile variances (length-k numeric).

  • samp.fore Optional posterior predictive forecast draws (k x n.samp) returned when return.draws = TRUE.

Examples


 # Toy example
 data("scIVTmag", package = "exdqlm")
 old = options(exdqlm.max_iter = 20L)
 y = scIVTmag[1:100]
 model = polytrendMod(1, stats::quantile(y, 0.85), 10)
 M0 = exdqlmLDVB(y, p0 = 0.85, model, df = c(0.98), dim.df = c(1),
                  gam.init = -3.5, sig.init = 15, n.samp = 30,
                  verbose = FALSE)
 M0.forecast = predict(M0, start.t = 90, k = 10, 
                   return.draws = TRUE, n.samp = 50, seed = 123)
 M0.forecast
 plot(M0.forecast)
 dim(M0.forecast$samp.fore)
 options(old)


exdqlm documentation built on July 10, 2026, 1:08 a.m.