compare.bsts.models: Compare bsts models

Description Usage Arguments Value Author(s) Examples

Description

Produce a set of line plots showing the cumulative absolute one step ahead prediction errors for different models. This plot not only shows which model is doing the best job predicting the data, it highlights regions of the data where the predictions are particularly good or bad.

Usage

1
2
3
4
5
6
7
8
CompareBstsModels(model.list,
                  burn = SuggestBurn(.1, model.list[[1]]),
                  filename = "",
                  colors = NULL,
                  lwd = 2,
                  xlab = "Time",
                  main = "",
                  grid = TRUE)

Arguments

model.list

A list of bsts models.

burn

The number of initial MCMC iterations to remove from each model as burn-in.

filename

A string. If non-empty string then a pdf of the plot will be saved in the specified file.

colors

A vector of colors to use for the different lines in the plot. If NULL then the rainbow pallette will be used.

lwd

The width of the lines to be drawn.

xlab

Label for the horizontal axis.

main

Main title for the plot.

grid

Logical. Should gridlines be drawn in the background?

Value

Invisibly returns the matrix of cumulative one-step ahead prediction errors (the lines in the top panel of the plot). Each row in the matrix corresponds to a model in model.list.

Author(s)

Steven L. Scott stevescott@google.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
  data(AirPassengers)
  y <- log(AirPassengers)
  ss <- AddLocalLinearTrend(list(), y)
  trend.only <- bsts(y, ss, niter = 500)

  ss <- AddSeasonal(ss, y, nseasons = 12)
  trend.and.seasonal <- bsts(y, ss, niter = 500)

  CompareBstsModels(list(trend = trend.only,
                         "trend and seasonal" = trend.and.seasonal))

Example output

Loading required package: BoomSpikeSlab
Loading required package: Boom
Loading required package: MASS

Attaching package: 'Boom'

The following object is masked from 'package:stats':

    rWishart

Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: xts
=-=-=-=-= Iteration 0 Mon Jun 19 23:40:13 2017 =-=-=-=-=
=-=-=-=-= Iteration 50 Mon Jun 19 23:40:13 2017 =-=-=-=-=
=-=-=-=-= Iteration 100 Mon Jun 19 23:40:13 2017 =-=-=-=-=
=-=-=-=-= Iteration 150 Mon Jun 19 23:40:13 2017 =-=-=-=-=
=-=-=-=-= Iteration 200 Mon Jun 19 23:40:13 2017 =-=-=-=-=
=-=-=-=-= Iteration 250 Mon Jun 19 23:40:13 2017 =-=-=-=-=
=-=-=-=-= Iteration 300 Mon Jun 19 23:40:13 2017 =-=-=-=-=
=-=-=-=-= Iteration 350 Mon Jun 19 23:40:13 2017 =-=-=-=-=
=-=-=-=-= Iteration 400 Mon Jun 19 23:40:13 2017 =-=-=-=-=
=-=-=-=-= Iteration 450 Mon Jun 19 23:40:13 2017 =-=-=-=-=
=-=-=-=-= Iteration 0 Mon Jun 19 23:40:13 2017 =-=-=-=-=
=-=-=-=-= Iteration 50 Mon Jun 19 23:40:13 2017 =-=-=-=-=
=-=-=-=-= Iteration 100 Mon Jun 19 23:40:13 2017 =-=-=-=-=
=-=-=-=-= Iteration 150 Mon Jun 19 23:40:14 2017 =-=-=-=-=
=-=-=-=-= Iteration 200 Mon Jun 19 23:40:14 2017 =-=-=-=-=
=-=-=-=-= Iteration 250 Mon Jun 19 23:40:14 2017 =-=-=-=-=
=-=-=-=-= Iteration 300 Mon Jun 19 23:40:14 2017 =-=-=-=-=
=-=-=-=-= Iteration 350 Mon Jun 19 23:40:14 2017 =-=-=-=-=
=-=-=-=-= Iteration 400 Mon Jun 19 23:40:14 2017 =-=-=-=-=
=-=-=-=-= Iteration 450 Mon Jun 19 23:40:14 2017 =-=-=-=-=

bsts documentation built on May 29, 2017, 10:28 p.m.