View source: R/bage_mod-functions.R
set_seeds | R Documentation |
Reset random seeds stored in a model object.
When new_seeds
is NULL
(the default),
the new seeds are generated randomly; otherwise
they are taken from new_seeds
.
set_seeds(mod, new_seeds = NULL)
mod |
An object of class |
new_seeds |
|
When an object of class "bage_mod"
is first created,
values are generated four four random seeds:
seed_components
seed_augment
seed_forecast_components
seed_forecast_augment
When fit()
, components()
, augment()
,
and forecast()
are called on the model object,
the seeds are used internally to ensure that
he same inputs generate the same outputs, even
when the outputs involve random draws.
End users are unlikely to call set_seeds()
in
a data analysis, though it may occasionally by useful
when building a simulation from scratch.
A modified version of mod
.
report_sim()
Do a simulation study. (report_sim()
calls set_seeds()
internally.)
mod_pois()
, mod_binom()
, mod_norm()
Specify a model
fit()
Fit a model
unfit()
Reset model, deleting estimates
## fit model
mod <- mod_pois(injuries ~ age,
data = nzl_injuries,
exposure = popn) |>
fit()
## call 'components()'
components(mod)
## call 'components()' again - same results
components(mod)
## reset seeds
mod <- set_seeds(mod)
## calling 'set_seeds' unfits the model
is_fitted(mod)
## so we fit it again
mod <- fit(mod)
## when we call components, we get
## different results from earlier
components(mod)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.