fitted.mvgam {mvgam} | R Documentation |
Expected Values of the Posterior Predictive Distribution
Description
This method extracts posterior estimates of the fitted values (i.e. the actual predictions, included estimates for any trend states, that were obtained when fitting the model). It also includes an option for obtaining summaries of the computed draws.
Usage
## S3 method for class 'mvgam'
fitted(
object,
process_error = TRUE,
scale = c("response", "linear"),
summary = TRUE,
robust = FALSE,
probs = c(0.025, 0.975),
...
)
Arguments
object |
An object of class |
process_error |
Logical. If |
scale |
Either |
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 the actual fitted values from the model (i.e. what you
will see if you generate hindcasts from the fitted model using hindcast.mvgam
with type = 'expected'
). These
predictions can be overly precise if a flexible dynamic trend component was included
in the model. This is in contrast to the set of predict functions (i.e.
posterior_epred.mvgam
or predict.mvgam
), which will assume
any dynamic trend component has reached stationarity when returning hypothetical predictions
Value
An array
of predicted mean response 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
.
See Also
Examples
## Not run:
# 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 = 'AR1',
data = simdat$data_train,
chains = 2,
burnin = 300,
samples = 300)
# Extract fitted values (posterior expectations)
expectations <- fitted(mod)
str(expectations)
## End(Not run)