plot.bsts  R Documentation 
Functions to plot the results of a model fit using
bsts
.
## S3 method for class 'bsts' plot(x, y = c("state", "components", "residuals", "coefficients", "prediction.errors", "forecast.distribution", "predictors", "size", "dynamic", "seasonal", "monthly", "help"), ...) PlotBstsCoefficients(bsts.object, burn = SuggestBurn(.1, bsts.object), inclusion.threshold = 0, number.of.variables = NULL, ...) PlotBstsComponents(bsts.object, burn = SuggestBurn(.1, bsts.object), time, same.scale = TRUE, layout = c("square", "horizontal", "vertical"), style = c("dynamic", "boxplot"), ylim = NULL, components = 1:length(bsts.object$state.specification), ...) PlotDynamicRegression(bsts.object, burn = SuggestBurn(.1, bsts.object), time = NULL, same.scale = FALSE, style = c("dynamic", "boxplot"), layout = c("square", "horizontal", "vertical"), ylim = NULL, zero.width = 2, zero.color = "green", ...) PlotBstsState(bsts.object, burn = SuggestBurn(.1, bsts.object), time, show.actuals = TRUE, style = c("dynamic", "boxplot"), scale = c("linear", "mean"), ylim = NULL, ...) PlotBstsResiduals(bsts.object, burn = SuggestBurn(.1, bsts.object), time, style = c("dynamic", "boxplot"), means = TRUE, ...) PlotBstsPredictionErrors(bsts.object, cutpoints = NULL, burn = SuggestBurn(.1, bsts.object), style = c("dynamic", "boxplot"), xlab = "Time", ylab = "", main = "", ...) PlotBstsForecastDistribution(bsts.object, cutpoints = NULL, burn = SuggestBurn(.1, bsts.object), style = c("dynamic", "boxplot"), xlab = "Time", ylab = "", main = "", show.actuals = TRUE, col.actuals = "blue", ...) PlotBstsSize(bsts.object, burn = SuggestBurn(.1, bsts.object), style = c("histogram", "ts"), ...) PlotSeasonalEffect(bsts.object, nseasons = 7, season.duration = 1, same.scale = TRUE, ylim = NULL, get.season.name = NULL, burn = SuggestBurn(.1, bsts.object), ...) PlotMonthlyAnnualCycle(bsts.object, ylim = NULL, same.scale = TRUE, burn = SuggestBurn(.1, bsts.object), ...)
x 
An object of class 
bsts.object 
An object of class 
y 
A character string indicating the aspect of the model that should be plotted. 
burn 
The number of MCMC iterations to discard as burnin. 
col.actuals 
The color to use for the actual data when comparing actuals vs forecasts. 
components 
A numeric vector indicating which components to plot. Component indices correspond to elements of the state specification that was used to build the bsts model being plotted. 
cutpoints 
A numeric vector of integers, or 
get.season.name 
A function that can be used to infer the title
of each seasonal plot. It should take a single

inclusion.threshold 
An inclusion probability that individual
coefficients must exceed in order to be displayed when 
layout 
For controlling the layout of functions that generate mutiple plots. 
main 
Main title for the plot. 
means 
Logical. If TRUE then the mean of each residual is plotted as a blue dot. If false only the distribution of the residuals is plotted. 
nseasons 
If there is only one seasonal component in the model,
this argument is ignored. If there are multiple seasonal
components then 
number.of.variables 
If non 
same.scale 
Logical. If 
scale 
The scale on which to plot the state. If the error family is "logit" or "poisson" then the state can either be plotted on the scale of the linear predictor (e.g. trend + seasonal + regression) or the linear predictor can be passed through the link function so as to plot the distribution of the conditional mean. 
season.duration 
If there is only one seasonal component in the
model, this argument is ignored. If there are multiple seasonal
components then 
show.actuals 
Logical. If 
style 
The desired plot style. Partial matching is allowed, so "dyn" would match "dynamic", for example. 
time 
An optional vector of values to plot against. If missing, the default is to diagnose the time scale of the original time series. 
xlab 
Label for the horizontal axis. 
ylab 
Label for the vertical axis. 
ylim 
Limits for the vertical axis. If 
zero.width 
A numerical value for the width of the reference
line at zero. If 
zero.color 
A color for the width of the reference line at zero.
If 
... 
Additional arguments to be passed to

PlotBstsState
, PlotBstsComponents
, and
PlotBstsResiduals
all produce dynamic distribution
plots. PlotBstsState
plots the aggregate state
contribution (including regression effects) to the mean, while
PlotBstsComponents
plots the contribution of each state
component. PlotBstsResiduals
plots the posterior
distribution of the residuals given complete data (i.e. looking
forward and backward in time). PlotBstsPredictionErrors
plots filtering errors (i.e. the onestepahead prediction errors
given data up to the previous time point).
PlotBstsForecastDistribution
plots the onestepahead
forecasts instead of the prediction errors.
PlotBstsCoefficients
creates a significance plot for
the predictors used in the state space regression model. It is
obviously not useful for models with no regressors.
PlotBstsSize
plots the distribution of the number of
predictors included in the model.
PlotSeasonalEffect
generates an array of plots showing
how the distibution of the seasonal effect changes, for each season,
for models that include a seasonal state component.
PlotMonthlyAnnualCycle
produces an array of plots much
like PlotSeasonalEffect
, for models that include a
MonthlyAnnualCycle
state component.
These functions are called for their side effect, which is to produce a plot on the current graphics device.
PlotBstsState
invisibly returns the state object being plotted.
bsts
PlotDynamicDistribution
plot.lm.spike
data(AirPassengers) y < log(AirPassengers) ss < AddLocalLinearTrend(list(), y) ss < AddSeasonal(ss, y, nseasons = 12) model < bsts(y, state.specification = ss, niter = 500) plot(model, burn = 100) plot(model, "residuals", burn = 100) plot(model, "components", burn = 100) plot(model, "forecast.distribution", burn = 100)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.