-
Notifications
You must be signed in to change notification settings - Fork 25
/
plot.bsts.prediction.Rd
executable file
·106 lines (83 loc) · 3.32 KB
/
plot.bsts.prediction.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
% Copyright 2011 Google Inc. All Rights Reserved.
% Author: [email protected] (Steve Scott)
\name{plot.bsts.prediction}
\title{Plot predictions from Bayesian structural time series}
\alias{plot.bsts.prediction}
\description{Plot the posterior predictive distribution from a
\code{\link{bsts}} prediction object.}
\usage{
\method{plot}{bsts.prediction}(x,
y = NULL,
burn = 0,
plot.original = TRUE,
median.color = "blue",
median.type = 1,
median.width = 3,
interval.quantiles = c(.025, .975),
interval.color = "green",
interval.type = 2,
interval.width = 2,
style = c("dynamic", "boxplot"),
ylim = NULL,
...)
}
\arguments{
\item{x}{An object of class \code{\link{bsts.prediction}}
created by calling \code{predict} on a \code{\link{bsts}} object.}
\item{y}{A dummy argument necessary to match the signature of the
\code{\link{plot}} generic function. This argument is unused.}
\item{plot.original}{Logical or numeric. If \code{TRUE} then the
prediction is plotted after a time series plot of the original
series. If \code{FALSE}, the prediction fills the entire plot.
If numeric, then it specifies the number of trailing observations
of the original time series to plot in addition to the
predictions.}
\item{burn}{The number of observations you wish to discard as burn-in
from the posterior predictive distribution. This is in addition
to the burn-in discarded using \code{\link{predict.bsts}}.}
\item{median.color}{The color to use for the posterior median of the
prediction.}
\item{median.type}{The type of line (lty) to use for the posterior median
of the prediction.}
\item{median.width}{The width of line (lwd) to use for the posterior median
of the prediction.}
\item{interval.quantiles}{The lower and upper limits of the credible
interval to be plotted.}
\item{interval.color}{The color to use for the upper and lower limits
of the 95\% credible interval for the prediction.}
\item{interval.type}{The type of line (lty) to use for the upper and
lower limits of the 95\% credible inerval for of the
prediction.}
\item{interval.width}{The width of line (lwd) to use for the upper and
lower limits of the 95\% credible inerval for of the
prediction.}
\item{style}{Either "dynamic", for dynamic distribution plots, or
"boxplot", for box plots. Partial matching is allowed, so "dyn" or
"box" would work, for example.}
\item{ylim}{Limits on the vertical axis.}
\item{...}{Extra arguments to be passed to
\code{\link[Boom]{PlotDynamicDistribution}}
and \code{\link{lines}}.}
}
\details{ Plots the posterior predictive distribution described by
\code{x} using a dynamic distribution plot generated by
\code{\link[Boom]{PlotDynamicDistribution}}. Overlays the
posterior median and 95\% prediction limits for the predictive
distribution. }
\value{
Returns NULL.
}
\examples{
data(AirPassengers)
y <- log(AirPassengers)
ss <- AddLocalLinearTrend(list(), y)
ss <- AddSeasonal(ss, y, nseasons = 12)
model <- bsts(y, state.specification = ss, niter = 500)
pred <- predict(model, horizon = 12, burn = 100)
plot(pred)
}
\seealso{
\code{\link{bsts}}
\code{\link[Boom]{PlotDynamicDistribution}}
\code{\link[BoomSpikeSlab]{plot.lm.spike}}
}