mssm (version 0.1.3)

plot.mssm: Plot Predicted State Variables for mssm Object.

Description

Plots the predicted mean and pointwise prediction interval of the state variables for the filtering distribution or smoothing distribution.

Usage

# S3 method for mssm
plot(x, y, qs = c(0.05, 0.95), do_plot = TRUE,
  which_weights = c("filter", "smooth"), ...)

Arguments

x

an object of class mssm.

y

un-used.

qs

two-dimensional numeric vector with bounds of the prediction interval.

do_plot

TRUE to create a plot with the mean and quantiles.

which_weights

character of which weights to use. Either "filter" for filter weights or "smooth" for smooth for smooth weights. The latter requires that smooth element has been used.

...

un-used.

Value

List with means and quantiles.

Examples

Run this code
# NOT RUN {
if(require(Ecdat)){
  # load data and get object to perform particle filtering
  data("Gasoline", package = "Ecdat")

  library(mssm)
  ll_func <- mssm(
    fixed = lgaspcar ~ factor(country) + lincomep + lrpmg + lcarpcap,
    random = ~ 1, family = Gamma("log"), data = Gasoline, ti = year,
    control = mssm_control(N_part = 1000L, n_threads = 1L))

  # run particle filter
  cfix <- c(0.612, -0.015, 0.214, 0.048, -0.013, -0.016, -0.022, 0.047,
            -0.046, 0.007, -0.001, 0.008, -0.117, 0.075, 0.048, -0.054, 0.017,
            0.228, 0.077, -0.056, -0.139)
  pf <- ll_func$pf_filter(
    cfix = cfix, Q = as.matrix(2.163e-05), F. = as.matrix(0.9792),
    disp = 0.000291)

  # plot predicted values and prediction intervals
  plot(pf)
  plot(pf, qs = c(.01, .99))
  pf <- ll_func$smoother(pf)
  plot(pf, which_weights = "smooth")
}
# }

Run the code above in your browser using DataCamp Workspace