plot_predict | R Documentation |
Plots sample quantiles and posterior means of the predictions
of the predict.walker_fit
output.
plot_predict(object, draw_obs = NULL, level = 0.05, alpha = 0.33)
object |
An output from |
draw_obs |
Either |
level |
Level for intervals. Default is 0.05, leading to 90% intervals. |
alpha |
Transparency level for |
set.seed(1)
n <- 60
slope <- 0.0001 + cumsum(rnorm(n, 0, sd = 0.01))
beta <- numeric(n)
beta[1] <- 1
for(i in 2:n) beta[i] <- beta[i-1] + slope[i-1]
ts.plot(beta)
x <- rnorm(n, 1, 0.5)
alpha <- 2
ts.plot(beta * x)
signal <- alpha + beta * x
y <- rnorm(n, signal, 0.25)
ts.plot(cbind(signal, y), col = 1:2)
data_old <- data.frame(y = y[1:(n-10)], x = x[1:(n-10)])
# note very small number of iterations for the CRAN checks!
rw2_fit <- walker(y ~ 1 +
rw2(~ -1 + x,
beta = c(0, 10),
nu = c(0, 10)),
beta = c(0, 10), data = data_old,
iter = 300, chains = 1, init = 0, refresh = 0)
pred <- predict(rw2_fit, newdata = data.frame(x=x[(n-9):n]))
data_new <- data.frame(t = (n-9):n, y = y[(n-9):n])
plot_predict(pred) +
ggplot2::geom_line(data = data_new, ggplot2:: aes(t, y),
linetype = "dashed", colour = "red", inherit.aes = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.