plot.bsts.mixed {bsts} | R Documentation

## Plotting functions for mixed frequency Bayesian structural time series

### Description

Functions for plotting the output of a mixed frequency time series regression.

### Usage

      ## S3 method for class 'bsts.mixed'
    plot(x,
                                y = c("state", "components",
                                      "coefficients", "predictors", "size"),
                                ...)

       PlotBstsMixedState(bsts.mixed.object,
                          burn = SuggestBurn(.1, bsts.mixed.object),
                          time = NULL,
                          fine.scale = FALSE,
                          style = c("dynamic", "boxplot"),
                          trim.left = NULL,
                          trim.right = NULL,
                          ...)

       PlotBstsMixedComponents(bsts.mixed.object,
                               burn = SuggestBurn(.1, bsts.mixed.object),
                               time = NULL,
                               same.scale = TRUE,
                               fine.scale = FALSE,
                               style = c("dynamic", "boxplot"),
                               layout = c("square", "horizontal", "vertical"),
                               ylim = NULL,
                               trim.left = NULL,
                               trim.right = NULL,
                               ...)

### Arguments

`x` | An object of class `bsts.mixed`.
`bsts.mixed.object` | An object of class `bsts.mixed`.
`y` | A character string indicating the aspect of the model that should be plotted.
`burn` | The number of MCMC iterations to discard as burn-in.
`time` | An optional vector of values to plot against. If missing, the default is to obtain the time scale from the original time series.
`fine.scale` | Logical. If `TRUE` then the plots will be at the weekly level of granularity. If `FALSE` they will be at the monthly level.
`same.scale` | Logical. If `TRUE` then all the state components will be plotted with the same scale on the vertical axis. If `FALSE` then each component will get its own scale for the vertical axis.
`style` | character. If "dynamic" then a dynamic distribution plot will be shown. If "box" then boxplots will be shown.
`layout` | A character string indicating whether the plots showing components of state should be laid out in a square, horizontally, or vertically.
`trim.left` | A logical indicating whether the first (presumedly partial) observation in the aggregated state time series should be removed.
`trim.right` | A logical indicating whether the last (presumedly partial) observation in the aggregated state time series should be removed.
`ylim` | Limits for the vertical axis. Optional.
`...` | Additional arguments to be passed to `PlotDynamicDistribution` or `TimeSeriesBoxplot`

### Details

`PlotBstsMixedState` plots the aggregate state contribution (including regression effects) to the mean, while `PlotBstsComponents` plots the contribution of each state component separately. `PlotBstsCoefficients` creates a significance plot for the predictors used in the state space regression model.

### Value

These functions are called for their side effect, which is to produce a plot on the current graphics device.

### See Also

`bsts.mixed` `PlotDynamicDistribution` `plot.lm.spike` `PlotBstsSize`

### Examples

    ## Not run:
    ## This example is flaky and needs to be fixed
      data <- SimulateFakeMixedFrequencyData(nweeks = 104, xdim = 20)
      state.specification <- AddLocalLinearTrend(list(), data$coarse.target)
      weeks <- index(data$predictor)
      months <- index(data$coarse.target)
      which.month <- MatchWeekToMonth(weeks, months[1])
      membership.fraction <- GetFractionOfDaysInInitialMonth(weeks)
      contains.end <- WeekEndsMonth(weeks)

      model <- bsts.mixed(target.series = data$coarse.target,
                          predictors = data$predictors,
                          membership.fraction = membership.fraction,
                          contains.end = contains.end,
                          which.coarse = which.month,
                          state.specification = state.specification,
                          niter = 500)

      plot(model, "state")
      plot(model, "components")

    ## End(Not run)

[Package bsts version 0.9.1 Index]