refit_model()
View source ↗On this page
Fit the model again from the inputs and settings stored in a fit or a saved fit, with some arguments changed if needed.
Usage
refit_model(fit, ...)
Arguments
| Argument | Default | Description |
|---|---|---|
fit | required | An ACL or ALSCL fit, or a saved fit read with |
... | … | Named arguments of |
Value
A new fit with a TMB object in the current session, whose stored inputs and settings include the arguments given.
Details
The refit starts from the stored starting values and uses the stored inputs and the recorded speed and standard-error settings; the speed options of the session are restored afterwards. No files are written unless output = TRUE is given. A named NULL entry of the stored map for a parameter that the model does not have is dropped before refitting, unless map is given in the call.
When the fit records its software (recipe$implementation), a change in the model or R source hashes, the source revision or the versions of ALSCL, TMB, Matrix or RcppEigen gives a warning before fitting. A refit with other software versions can give slightly different numbers, and the same records do not guarantee the same numbers on another platform.
Additional details from R help
The recorded framework and standard-error settings are applied during the fit and restored afterwards. The refit starts from the recorded original starting values, and a refit with other software can give other results. When the recipe records them, a change in the hashes of the model or R sources, in the source revision or in the version of ALSCL, TMB, Matrix or RcppEigen gives a warning before fitting; a recipe without these records is accepted. Platform and build information is kept for inspection and does not show that results agree across platforms. A stored map can hold a named NULL entry for a parameter that the model does not have; such an entry is dropped before refitting unless map is given in the call.
Examples
Run the setup before the example. Fitting examples require an R-compatible C++ toolchain; simulation and export examples may write files.
Example setup
library(ALSCL)
library(ggplot2)
library(patchwork)
data("YTF_example")
x <- YTF_example
inputs <- x[c("data.CatL", "data.wgt", "data.mat")]
dat <- x$data.CatL
a <- run_acl(x, silent = TRUE)
b <- run_alscl(x, silent = TRUE)
updated <- refit_model(a, M = 0.25, silent = TRUE)
summary(updated)