Skip to contents

Add fits and residuals to the data, implementing the generic augment from the package broom.

Usage

# S3 method for mvgam
augment(x, robust = FALSE, probs = c(0.025, 0.975), ...)

Arguments

x

An object of class mvgam.

robust

If FALSE (the default) the mean is used as the measure of central tendency and the standard deviation as the measure of variability. If TRUE, the median and the median absolute deviation (MAD) are applied instead.

probs

The percentiles to be computed by the quantile function.

...

Unused, included for generic consistency only.

Value

A list or tibble (see details) combining:

  • The data supplied to mvgam().

  • The outcome variable, named as .observed.

  • The fitted backcasts, along with their variability and credible bounds.

  • The residuals, along with their variability and credible bounds.

Details

A list is returned if class(x$obs_data) == 'list', otherwise a tibble is returned, but the contents of either object is the same.

The arguments robust and probs are applied to both the fit and residuals calls (see fitted.mvgam() and residuals.mvgam() for details).

Examples

if (FALSE) {
set.seed(0)
dat <- sim_mvgam(T = 80,
                 n_series = 3,
                 mu = 2,
                 trend_model = AR(p = 1),
                 prop_missing = 0.1,
                 prop_trend = 0.6)

mod1 <- mvgam(formula = y ~ s(season, bs = 'cc', k = 6),
              data = dat$data_train,
              trend_model = AR(),
              family = poisson(),
              noncentred = TRUE,
              chains = 2,
              silent = 2)

augment(mod1, robust = TRUE, probs = c(0.25, 0.75))
}