
Refit an Existing ngme Object with SGLD and Extract Samples
Source:R/batch-means.R
compute_ngme_sgld_samples.RdRun one additional SGLD stage (warm-started from an existing `ngme` fit), then extract posterior-like samples from stored trajectories.
Usage
compute_ngme_sgld_samples(
fit,
iterations = 4000,
optimizer = sgld(stepsize = 0.01, temperature = 1),
burnin = 100,
n_batch = 20,
n_parallel_chain = 4,
alpha = 0.6,
t0 = 10,
start_sd = 0.2,
seed = Sys.time(),
verbose = FALSE,
name = "all",
burnin_iter = 0,
thinning = 1,
apply_transform = TRUE,
combine_chains = TRUE,
control_opt = NULL,
...
)Arguments
- fit
existing fitted `ngme` object (can be obtained with any optimizer).
- iterations
optimization iterations for the SGLD stage.
- optimizer
optimizer for the sampling stage; must be `sgld(...)`.
- burnin
burn-in iterations before optimization.
- n_batch
number of optimization checkpoints.
- n_parallel_chain
number of parallel chains.
- alpha
polynomial schedule exponent used by `poly_decay(alpha, t0)`.
- t0
non-negative schedule offset.
- start_sd
standard deviation for randomized chain initialization.
- seed
random seed for SGLD stage.
- verbose
logical; print optimization progress.
- name
parameter block to extract: `"all"` (default), latent model name, or `"general"`.
- burnin_iter
non-negative integer used both as optimizer schedule warmup (`stepsize_schedule_burnin_iter`) and as explicit trajectory trimming before sampling.
- thinning
positive integer thinning interval.
- apply_transform
logical; apply parameter transforms to user scale.
- combine_chains
logical; if `TRUE`, return one combined data.frame, otherwise return one data.frame per chain.
- control_opt
optional pre-built `control_opt` object for the SGLD stage. If supplied, it is used directly (with `store_traj` forced to `TRUE`).
- ...
additional arguments forwarded to [control_opt()] when `control_opt` is `NULL`.