| predict | R Documentation |
Compute posterior predictions from a fitted INLAvaan model,
including latent variable scores, predicted observed values, and imputed
missing data.
## S4 method for signature 'INLAvaan'
predict(
object,
type = c("lv", "yhat", "ov", "ypred", "ydist", "ymis", "ovmis"),
newdata = NULL,
level = 1L,
nsamp = 1000,
ymis_only = FALSE,
summary = FALSE,
...
)
object |
An object of class INLAvaan. |
type |
Character string specifying the type of prediction:
|
newdata |
An optional data frame of new observations. If supplied,
predictions are computed for |
level |
Integer; for |
nsamp |
Integer; number of posterior samples to use for prediction.
Defaults to |
ymis_only |
Logical; only applies when |
summary |
Logical. When |
... |
Currently unused. |
A list of nsamp posterior draws, each a matrix (or data
frame, for multiple groups) with rows corresponding to cases and columns
to variables or latent factors. When summary = TRUE, instead
returns a summary.predict.inlavaan_internal object with the
posterior mean, SD, quantiles, and mode for each case/variable.
sampling(), simulate(), summary()
HS.model <- "
visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9
"
utils::data("HolzingerSwineford1939", package = "lavaan")
fit <- acfa(HS.model, HolzingerSwineford1939, std.lv = TRUE, nsamp = 100,
test = "none", verbose = FALSE)
# Posterior latent variable scores
lv_scores <- predict(fit)
head(lv_scores)
# Predicted observed variable means
yhat <- predict(fit, type = "yhat")
head(yhat)
# Point estimates only, skipping the manual summary() step
predict(fit, type = "yhat", summary = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.