View source: R/posterior_epred.mvgam.R
| posterior_linpred.mvgam | R Documentation |
Compute posterior draws of the linear predictor, that is draws before applying any link functions or other transformations. Can be performed for the data used to fit the model (posterior predictive checks) or for new data.
## S3 method for class 'mvgam'
posterior_linpred(
object,
transform = FALSE,
newdata,
ndraws = NULL,
data_test,
process_error = TRUE,
...
)
object |
|
transform |
|
newdata |
Optional |
ndraws |
Positive |
data_test |
Deprecated. Still works in place of |
process_error |
|
... |
Ignored |
Note that for all types of predictions for models that did not
include a trend_formula, uncertainty in the dynamic trend component can
be ignored by setting process_error = FALSE. However, if a
trend_formula was supplied in the model, predictions for this component
cannot be ignored. If process_error = TRUE, trend predictions will
ignore autocorrelation coefficients or GP length scale coefficients,
ultimately assuming the process is stationary. This method is similar to
the types of posterior predictions returned from brms models when using
autocorrelated error predictions for newdata. This function is therefore
more suited to posterior simulation from the GAM components of a
mvgam model, while the forecasting functions
plot_mvgam_fc and forecast.mvgam are better
suited to generate h-step ahead forecasts that respect the temporal
dynamics of estimated latent trends.
A matrix of dimension n_samples x n_obs, where
n_samples is the number of posterior samples from the fitted object
and n_obs is the number of observations in newdata
Nicholas J Clark
hindcast.mvgam,
posterior_epred.mvgam,
posterior_predict.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(),
noncentred = TRUE,
data = simdat$data_train,
chains = 2,
silent = 2
)
# Extract linear predictor values
linpreds <- posterior_linpred(mod)
str(linpreds)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.