Skip to contents

This function takes either a fitted mvgam object or a data_train object and produces plots of observed time series, ACF, CDF and histograms for exploratory data analysis

Usage

plot_mvgam_series(
  object,
  data,
  data_train,
  newdata,
  data_test,
  y = "y",
  lines = TRUE,
  series = 1,
  n_bins,
  log_scale = FALSE
)

Arguments

object

Optional list object returned from mvgam. Either object or data_train must be supplied.

data

Optional dataframe or list of training data containing at least 'series' and 'time'. Use this argument if training data have been gathered in the correct format for mvgam modelling but no model has yet been fitted.

data_train

Deprecated. Still works in place of data but users are recommended to use data instead for more seamless integration into R workflows

newdata

Optional dataframe or list of test data containing at least 'series' and 'time' for the forecast horizon, in addition to any other variables included in the linear predictor of formula. If included, the observed values in the test data are compared to the model's forecast distribution for exploring biases in model predictions.

data_test

Deprecated. Still works in place of newdata but users are recommended to use newdata instead for more seamless integration into R workflows

y

Character. What is the name of the outcome variable in the supplied data? Defaults to 'y'

lines

Logical. If TRUE, line plots are used for visualising time series. If FALSE, points are used.

series

Either a integer specifying which series in the set is to be plotted or the string 'all', which plots all series available in the supplied data

n_bins

integer specifying the number of bins to use for binning observed values when plotting a the histogram. Default is to use the number of bins returned by a call to hist in base R

log_scale

logical. If series == 'all', this flag is used to control whether the time series plot is shown on the log scale (using log(Y + 1)). This can be useful when visualising many series that may have different observed ranges. Default is FALSE

Value

A set of base R graphics plots. If series is an integer, the plots will show observed time series, autocorrelation and cumulative distribution functions, and a histogram for the series. If series == 'all', a set of observed time series plots is returned in which all series are shown on each plot but only a single focal series is highlighted, with all remaining series shown as faint gray lines.

Author

Nicholas J Clark