set_seeds {bage} | R Documentation |
Reset Random Seeds in Model Object
Description
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
.
Usage
set_seeds(mod, new_seeds = NULL)
Arguments
mod |
An object of class |
new_seeds |
|
Details
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.
Value
A modified version of mod
.
See Also
-
report_sim()
Do a simulation study. (report_sim()
callsset_seeds()
internally.) -
mod_pois()
,mod_binom()
,mod_norm()
Specify a model -
fit()
Fit a model -
unfit()
Reset model, deleting estimates
Examples
## 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)