Learn R Programming

bsts (version 0.6.1)

plot.bsts.predictors: Plot the most likely predictors

Description

Creates a time series plot showing the most likely predictors of a time series used to fit a bsts object.

Usage

PlotBstsPredictors(bsts.object,
                     burn = SuggestBurn(.1, bsts.object),
                     inclusion.threshold = .1,
                     ylim = NULL,
                     flip.signs = TRUE,
                     show.legend = TRUE,
                     grayscale = TRUE,
                     short.names = TRUE,
                     ...)

Arguments

bsts.object
An object of class bsts.
burn
The number of observations you wish to discard as burn-in.
inclusion.threshold
Plot predictors with marginal inclusion probabilities above this threshold.
ylim
Scale for the vertical axis.
flip.signs
If true then a predictor with a negative sign will be flipped before being plotted, to better align visually with the target series.
show.legend
Should a legend be shown indicating which predictors are plotted?
grayscale
Logical. If TRUE then lines for different predictors grow progressively lighter as their inclusion probability decreases. If FALSE then lines are drawn in black.
short.names
Logical. If TRUE then a common prefix or suffix shared by all the variables will be discarded.
...
Extra arguments to be passed to plot.

See Also

bsts PlotDynamicDistribution plot.lm.spike

Examples

Run this code
data(AirPassengers)
  y <- log(AirPassengers)
  lag.y <- c(NA, head(y, -1))
  ss <- AddLocalLinearTrend(list(), y)
  ss <- AddSeasonal(ss, y, nseasons = 12)
  ## Call bsts with na.action = na.omit to omit the leading NA in lag.y
  model <- bsts(y ~ lag.y, state.specification = ss, niter = 500,
                na.action = na.omit)
  plot(model, "predictors")

Run the code above in your browser using DataLab