residuals.mvgam {mvgam} | R Documentation |
Posterior draws of mvgam
residuals
Description
This method extracts posterior draws of Dunn-Smyth (randomized quantile) residuals in the order in which the data were supplied to the model. It included additional arguments for obtaining summaries of the computed residuals
Usage
## S3 method for class 'mvgam'
residuals(object, summary = TRUE, robust = FALSE, probs = c(0.025, 0.975), ...)
Arguments
object |
An object of class |
summary |
Should summary statistics be returned
instead of the raw values? Default is |
robust |
If |
probs |
The percentiles to be computed by the |
... |
Further arguments passed to |
Details
This method gives residuals as Dunn-Smyth (randomized quantile) residuals. Any
observations that were missing (i.e. NA
) in the original data will have missing values
in the residuals
Value
An array
of randomized quantile residual values.
If summary = FALSE
the output resembles those of
posterior_epred.mvgam
and predict.mvgam
.
If summary = TRUE
the output is an n_observations
x E
matrix. The number of summary statistics E
is equal to 2 +
length(probs)
: The Estimate
column contains point estimates (either
mean or median depending on argument robust
), while the
Est.Error
column contains uncertainty estimates (either standard
deviation or median absolute deviation depending on argument
robust
). The remaining columns starting with Q
contain
quantile estimates as specified via argument probs
.
Examples
# Simulate some data and fit a model
simdat <- sim_mvgam(n_series = 1, trend_model = 'AR1')
mod <- mvgam(y ~ s(season, bs = 'cc'),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
chains = 2)
# Extract posterior residuals
resids <- residuals(mod)
str(resids)