View source: R/bage_mod-methods.R
fit.bage_mod | R Documentation |
Calculate the posterior distribution for a model.
## S3 method for class 'bage_mod'
fit(
object,
method = c("standard", "inner-outer"),
vars_inner = NULL,
optimizer = c("multi", "nlminb", "BFGS", "CG"),
quiet = TRUE,
start_oldpar = FALSE,
...
)
object |
A |
method |
Estimation method. Current
choices are |
vars_inner |
Names of variables to use
for inner model when |
optimizer |
Which optimizer to use.
Current choices are |
quiet |
Whether to suppress warnings and
progress messages from the optimizer.
Default is |
start_oldpar |
Whether the optimizer should start
at previous estimates. Used only
when |
... |
Not currently used. |
A bage_mod
object
"standard"
All parameters, other than
the lowest-level rates, probabilities, or
means are jointly estimated within TMB.
The default.
"inner-outer"
. Multiple-stage estimation,
which can be faster than "standard"
for
models with many parameters. In Step 1, the
data is aggregated across all dimensions other
than those specified in var_inner
, and a model
for the inner
variables is fitted to the data.
In Step 2, the data is aggregated across the
remaining variables, and a model for the
outer
variables is fitted to the data.
In Step 3, values for dispersion are calculated.
Parameter estimtes from steps 1, 2, and 3
are then combined. "inner-outer"
methods are
still experimental, and may change in future,
eg dividing calculations into chunks in Step 2.
The choices for the optimizer
argument are:
"multi"
Try "nlminb"
, and if that fails,
retart from the value where "nlminb"
stopped,
using "BFGS"
. The default.
"nlminb"
stats::nlminb()
"BFGS"
stats::optim()
using method "BFGS"
.
"GC"
stats::optim()
using method "CG"
(conjugate gradient).
mod_pois()
, mod_binom()
, mod_norm()
Specify a model
augment()
, components()
, tidy()
Examine
output from a model
forecast()
Forecast, based on a model
report_sim()
Simulation study of a model
unfit()
Reset a model
is_fitted()
Check if a model has been fitted
## specify model
mod <- mod_pois(injuries ~ age + sex + year,
data = nzl_injuries,
exposure = popn)
## examine unfitted model
mod
## fit model
mod <- fit(mod)
## examine fitted model
mod
## extract rates
aug <- augment(mod)
aug
## extract hyper-parameters
comp <- components(mod)
comp
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.