Skip to contents

Computes posterior fitted values for the original data used to fit an stLMM model. These fitted values include all model components that were fit: formula offsets, fixed effects, explicit grouped random effects, and saved or recovered structured latent process effects. Binomial and probit fitted values default to posterior fitted probabilities, and negative-binomial fitted values default to posterior fitted mean counts.

Usage

# S3 method for class 'stLMM'
fitted(object, summary = TRUE,
  sub_sample = list(start = 1L, thin = 1L), scale = c("response", "link"),
  ...)

Arguments

object

An object returned by stLMM or recover.

summary

Logical; if TRUE, return posterior mean fitted values. If FALSE, return the posterior fitted-value sample matrix.

sub_sample

List with optional start and thin entries used to subset posterior draws. For models with structured process terms, this subsets the saved or recovered latent-process draw indices in object$recover_iter.

scale

For family = "binomial", return fitted probabilities on the "response" scale or the linear predictor on the "link" scale. For family = "probit", return fitted probabilities on the "response" scale or the probit linear predictor on the "link" scale. For family = "negative_binomial", return fitted mean counts on the "response" scale or the log mean on the "link" scale. For Gaussian models these scales are identical.

...

Currently unused.

Value

If summary = TRUE, a numeric vector of posterior mean fitted values for the original fitted data rows, including rows whose response was missing at fit time. If summary = FALSE, a matrix with posterior draws in rows and original data rows in columns. The matrix has a draw_index attribute giving the original MCMC iteration indices used and, for summary = FALSE non-Gaussian fits, a scale attribute.

Details

This method does not predict at new locations. For models with structured process terms, fitted values require saved or recovered latent process samples. For augmented non-Gaussian process models, stLMM() saves in-chain process draws by default as save_process = list(start = 1, thin = 1) and recover() subsets them. For Gaussian process models, call recover() on the fitted object to make those samples available.