compPlot: Plot a component of an exDQLM

View source: R/compPlot.R

compPlotR Documentation

Plot a component of an exDQLM

Description

The function plots the dynamic MAP estimates and 95% credible intervals (CrIs) of a specified component of an exDQLM. Alternatively, if just.theta=TRUE the MAP estimates and 95% credible intervals (CrIs) of a single element of the dynamic state vector are plotted.

Usage

compPlot(
  m1,
  index,
  add = FALSE,
  col = "purple",
  just.theta = FALSE,
  cr.percent = 0.95,
  plot = TRUE,
  xlim = NULL,
  ylim = NULL,
  xlab = "time",
  ylab = NULL,
  lwd = 1.5,
  lwd.interval = 0.75,
  lty.interval = 2
)

Arguments

m1

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

index

Vector of consecutive integers in \{1,\dots,q\} indicating the component or element of the state vector to be plotted.

add

Logical value indicating whether the dynamic component will be added to existing plot. Default is FALSE.

col

Character vector of length 1 giving color of the dynamic component to be plotted. Default is purple.

just.theta

Logical; if TRUE, the function plots the dynamic distribution of the index element of the state vector. If just.theta=TRUE, index must have length 1.

cr.percent

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

plot

Logical value indicating whether to draw the plot. If FALSE, the function only returns the plotted summaries. Default is TRUE.

xlim, ylim

Optional limits passed to the base plotting call when plot = TRUE.

xlab, ylab

Optional axis labels passed to the base plotting call when plot = TRUE.

lwd, lwd.interval

Line widths for the dynamic component and credible interval bounds, respectively.

lty.interval

Line type for the credible interval bounds.

Value

A list of the following is returned:

  • map.comp - MAP estimate of the dynamic component (or element of the state vector).

  • lb.comp - Lower bound of the 95% CrIs of the dynamic component (or element of the state vector).

  • ub.comp - Upper bound of the 95% CrIs of the dynamic component (or element of the state vector).

  • x - Time/index values used for plotting.

Examples


data("scIVTmag", package = "exdqlm")
old = options(exdqlm.max_iter = 15L)
y = scIVTmag[1:80]
trend.comp = polytrendMod(2, rep(0, 2), 10*diag(2))
seas.comp = seasMod(365, c(1, 2), C0 = 10*diag(4))
model = trend.comp + seas.comp
M0 = exdqlmLDVB(y, p0 = 0.85, model, df = c(0.98, 1), dim.df = c(2, 4),
                   gam.init = -3.5, sig.init = 15,
                   n.samp = 20, tol = 0.2, verbose = FALSE)
# plot first harmonic component
compPlot(M0, index = c(3, 4), col = "blue")
c.summary = compPlot(M0, index = c(3, 4), plot = FALSE)
options(old)



exdqlm documentation built on June 5, 2026, 1:06 a.m.