Skip to contents

For a fit started with lame(..., checkpoint_path = "X.rds") that terminated early (either via max_seconds or an external interruption), continues the chain from the most recent checkpoint. The checkpoint holds the full sampler state (latent matrix, coefficients, additive and multiplicative effects, variance components, dynamic coefficient paths, auxiliary states and adapted proposal scales) together with the seed and the original call. The continuation re-invokes lame() with that state as start_vals, completing any unfinished burn-in, and with seed advanced by the number of completed iterations, so it does not replay the first run's random stream. The result is a fresh fit whose stored draws start where the checkpointed chain stopped; draws stored before the interruption are not carried over. nscan_more requests additional production sweeps; the saved thinning setting odens determines how many draws are retained.

Usage

lame_resume(path, nscan_more = NULL, ..., .envir = NULL)

Arguments

path

Checkpoint RDS file path, as written through checkpoint_path, or a fitted lame / ame object (for instance a fit returned with fit$auto_extend$settled = FALSE). A fit is continued from the state it stopped in, with the call that produced it, burn = 0 and the seed advanced by the sweeps it ran. For a pooled multi-chain fit every chain is continued from its own final state, and the chains are checked and compared again (see ame).

nscan_more

Optional integer, the new nscan for the continuation. If NULL, the original nscan is used.

...

Additional arguments forwarded to lame() (override the saved values).

.envir

Environment in which to evaluate the saved call's data arguments. Defaults to the caller's frame; used internally when lame() forwards a resume.

Value

A fitted lame object.

Details

Equivalent consolidated entry point. lame(resume_from = path, ...) short-circuits to this function with the user-supplied overrides forwarded; pass nscan = K on the resume call to request K additional post-burn sweeps. Both call shapes evaluate saved data arguments in the caller's frame, so objects referenced by the original call must remain available there. A missing one is named in the error; data passed to lame_resume() by argument name replace the saved arguments.

Use nscan_more = K to override the nscan value to K for the continuation. A fit continued from the object runs with the arguments of its call, max_seconds included: a fit that stopped at its time limit stops again at the same limit unless max_seconds = Inf is passed. The continuation holds nscan_more / odens draws per chain (chains * nscan_more / odens pooled) when it runs to the end, plus one block of each extension. Other arguments can be overridden by passing them to .... Older checkpoints without the complete transition state are treated as warm starts with a fresh burn-in and a warning. A start_vals, burn or seed passed there replaces the checkpoint's choice.

Tempered checkpoints restore every replica and the complete primary and auxiliary RNG streams, completing any unfinished original burn-in. The returned fit contains only newly retained draws, which exactly continue an uninterrupted run. Data, priors, seed, thinning and sampler changes are refused; start a new fit to change the model. Output settings, time limits and the number of additional production sweeps may be changed.

Checkpoints retain resolved priors independently of the original call. Where the checkpoint type permits a prior override, it can be supplied explicitly. Otherwise a continuation uses those settings even if a caller variable or a package default has changed. The original user settings are retained separately for training-window refits. Complete older Gaussian bipartite AR(1) checkpoints without frozen priors retain their former persistence defaults (mean 0.9, SD 0.1) when the saved call did not supply them.

Examples

# \donttest{
ck <- tempfile(fileext = ".rds")
data(YX_bin_list)
# a run that writes a checkpoint for each chain as it goes
fit1 <- lame(lapply(YX_bin_list$Y, function(y) 1 * (y > 0)), YX_bin_list$X,
             family = "binary", R = 0, nscan = 100, burn = 20, odens = 5,
             checkpoint_path = ck, checkpoint_every = 50L, verbose = FALSE)
# each chain has its own file (ck with _chain1, _chain2 before the
# extension): continue one chain from its file
fit2 <- lame_resume(sub(".rds", "_chain1.rds", ck, fixed = TRUE), nscan_more = 50)
dim(fit2$BETA)
#> [1] 10  4
# or every chain from the returned fit
fit3 <- lame_resume(fit1, nscan_more = 50)
nrow(fit3$BETA)  # 2 chains * 50 / 5 = 20
#> [1] 20
# a run stopped by max_seconds (fit$terminated_early) continues the same way;
# max_seconds = Inf lifts the time limit of the original call
# }