View source: R/posterior_epred.mvgam.R
| fitted.mvgam | R Documentation |
This method extracts posterior estimates of the fitted values (i.e. the actual predictions, including estimates for any trend states, that were obtained when fitting the model). It also includes an option for obtaining summaries of the computed draws.
## S3 method for class 'mvgam'
fitted(
object,
process_error = TRUE,
scale = c("response", "linear"),
summary = TRUE,
robust = FALSE,
probs = c(0.025, 0.975),
...
)
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 |
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.
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.
Nicholas J Clark
hindcast.mvgam
## Not run:
# Simulate some data and fit a model
simdat <- sim_mvgam(n_series = 1, trend_model = AR())
mod <- mvgam(
y ~ s(season, bs = 'cc'),
trend_model = AR(),
data = simdat$data_train,
chains = 2,
silent = 2
)
# Extract fitted values (posterior expectations)
expectations <- fitted(mod)
str(expectations)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.