update.mvgam | R Documentation |
mvgam
objectThis function allows a previously fitted mvgam
model to be updated
## S3 method for class 'mvgam'
update(
object,
formula,
trend_formula,
data,
newdata,
trend_model,
trend_map,
use_lv,
n_lv,
family,
share_obs_params,
priors,
chains,
burnin,
samples,
threads,
algorithm,
lfo = FALSE,
...
)
object |
|
formula |
Optional new |
trend_formula |
An optional |
data |
A
Should also include any other variables to be included in the linear predictor of |
newdata |
Optional |
trend_model |
For all trend types apart from |
trend_map |
Optional |
use_lv |
|
n_lv |
|
family |
Note that only |
share_obs_params |
|
priors |
An optional |
chains |
|
burnin |
|
samples |
|
threads |
|
algorithm |
Character string naming the estimation approach to use.
Options are |
lfo |
Logical indicating whether this is part of a call to lfo_cv.mvgam. Returns a
lighter version of the model with no residuals and fewer monitored parameters to speed up
post-processing. But other downstream functions will not work properly, so users should always
leave this set as |
... |
Other arguments to be passed to |
A list
object of class mvgam
containing model output, the text representation of the model file,
the mgcv model output (for easily generating simulations at
unsampled covariate values), Dunn-Smyth residuals for each series and key information needed
for other functions in the package. See mvgam-class
for details.
Use methods(class = "mvgam")
for an overview on available methods.
# Simulate some data and fit a Poisson AR1 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)
summary(mod)
conditional_effects(mod, type = 'link')
# Update to an AR2 model
updated_mod <- update(mod, trend_model = AR(p = 2),
noncentred = TRUE)
summary(updated_mod)
conditional_effects(updated_mod, type = 'link')
# Now update to a Binomial AR1 by adding information on trials
# requires that we supply newdata that contains the 'trials' variable
simdat$data_train$trials <- max(simdat$data_train$y) + 15
updated_mod <- update(mod,
formula = cbind(y, trials) ~ s(season, bs = 'cc'),
noncentred = TRUE,
data = simdat$data_train,
family = binomial())
summary(updated_mod)
conditional_effects(updated_mod, type = 'link')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.