| residuals | R Documentation |
Extract the difference between the observed and model-implied (fitted)
sample statistics from a fitted INLAvaan model. As in lavaan
and blavaan, residuals are computed at the parameter estimates –
here the posterior means – not as a posterior distribution over residuals.
## S4 method for signature 'INLAvaan'
residuals(object, type = "raw", labels = TRUE, ...)
## S4 method for signature 'INLAvaan'
resid(object, type = "raw", ...)
object |
An object of class INLAvaan. |
type |
Character. |
labels |
Logical. Attach variable names to the output. Default
|
... |
Currently unused. |
This delegates to lavaan's own residuals() machinery, so the
return structure matches lavaan exactly. Because INLAvaan stores the
posterior means as the point estimates of the fitted object, the residuals
are the observed statistics minus the posterior-mean model-implied
statistics (mirroring blavaan, which likewise inherits lavaan's
residuals() without overriding it).
For moment-based types, a list with elements
type, cov, and (when relevant) mean. For
type = "casewise", a numeric matrix of observed-minus-fitted
values.
fitted(), predict(), fitMeasures()
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)
# Raw residual covariance matrix (posterior means)
residuals(fit)
# SRMR-basis residuals
residuals(fit, type = "cor.bentler")
# Casewise observed-minus-fitted values
head(residuals(fit, type = "casewise"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.