| recover | R Documentation |
Recover posterior draws of latent process terms from a fitted collapsed
stLMM model.
recover(object, ...)
## S3 method for class 'stLMM'
recover(object, n_omp_threads = NULL, verbose = FALSE,
sub_sample = list(start = 1L, thin = 1L), ...)
## S3 method for class 'stLMM_chains'
recover(object, n_omp_threads = NULL, verbose = FALSE,
sub_sample = list(start = 1L, thin = 1L), ...)
object |
An object returned by |
n_omp_threads |
Optional positive integer number of OpenMP threads for
threaded recovery setup kernels. The default |
verbose |
Logical; if |
sub_sample |
A list with optional integer entries |
... |
Currently unused. |
For Gaussian process models, the collapsed sampler integrates latent process values out during fitting. This function reconstructs the posterior conditional distribution of the latent process for selected posterior draws and samples from it using the stored backend, posterior parameter samples, and CHOLMOD sparse factorization.
By default, recovery uses the OpenMP thread count stored in the fitted object.
Use n_omp_threads to override that value for a recovery call without
refitting. The override is most relevant for NNGP terms because their
covariance-coefficient updates are threaded. Other major recovery work,
including sparse factorization and latent Gaussian random draws, is not
parallelized by this argument.
For augmented non-Gaussian process models, process draws are saved during stLMM()
by default as save_process = list(start = 1, thin = 1). In that case,
recover() only selects and labels the saved
in-chain process draws. If an augmented non-Gaussian process model was fit with
save_process = FALSE, recover() errors and the model must be
refit with save_process = TRUE or
save_process = list(start = ..., thin = ...).
Recovery is only needed for models with structured process terms such as
ar1(), gp(), nngp(), car(), dagar(), or
car_time(), or dagar_time().
Explicit iid grouped random effects are sampled during fitting and do not need
this recovery step. When the fitted data include rows with missing numeric
responses, recovered process samples are on the full latent support, including
latent nodes associated only with those missing-response rows.
For augmented non-Gaussian process models, the sampler uses warm-running internal
latent-process draws to update the augmentation variables. Those
same in-chain process draws are the process samples used by recover().
Post-fit augmented non-Gaussian process reconstruction is intentionally not supported.
The fitted object with recovered latent process draws added. User-facing
w_samples are returned by process term; NNGP and DAGAR terms are in
original support order. The internal ordered copy used by fitted values and
prediction is stored in w_samples_ordered. The object also includes
w_samples_stacked and recover_iter. The returned object has class
stLMM_recovery and can be passed to fitted() or predict().
For multi-chain input, the returned object has class
stLMM_recovery_chains and contains chains, a list of ordinary
stLMM_recovery objects. The sub_sample rule is applied within
each chain.
stLMM, fitted,
predict.stLMM_recovery, summary.stLMM_recovery
set.seed(1)
dat <- data.frame(
y = rnorm(8),
x = rnorm(8),
time = seq_len(8)
)
fit <- stLMM(
y ~ x + ar1(time),
data = dat,
n_samples = 8,
priors = list(
resid = list(tau_sq = ig(2, 1)),
ar1_1 = list(sigma_sq = ig(2, 1), phi = uniform(-0.8, 0.8))
),
warmup = FALSE,
verbose = FALSE
)
rec <- recover(fit, sub_sample = list(start = 5, thin = 1))
stats::fitted(rec)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.