lavResiduals.mi: Covariance and Correlation Residuals

View source: R/pool-residuals.R

lavResiduals.miR Documentation

Covariance and Correlation Residuals

Description

This function calculates residuals for sample moments (e.g., means and (co)variances, means) from a lavaan model fitted to multiple imputed data sets, along with summary and inferential statistics about the residuals.

Usage

## S4 method for signature 'lavaan.mi'
residuals(object, type = "raw", omit.imps = c("no.conv", "no.se"), ...)

## S4 method for signature 'lavaan.mi'
resid(object, type = "raw", omit.imps = c("no.conv", "no.se"), ...)

lavResiduals.mi(object, omit.imps = c("no.conv", "no.se"), ...)

Arguments

object

An object of class lavaan.mi

type

character indicating whether/how to standardize the covariance residuals. If type = "raw", the raw (= unscaled) difference between the observed and expected (model-implied) summary statistics are returned. The observed summary statistics are averaged across imputations, and the model-implied statistics are calculated from pooled parameter estimates (as returned by fitted.values()). If type = "cor" or "cor.bollen", the observed and model-implied covariance matrices are first transformed to correlation matrices (using stats::cov2cor()); then correlation residuals are computed. If type = "cor.bentler", both the observed and model-implied covariance matrices are rescaled by dividing the elements by the square roots of the corresponding variances of the observed covariance matrix.

omit.imps

character indicating criteria for excluding imputations from pooled results. See lavaan.mi for argument details.

...

Arguments passed to lavaan::lavResiduals().

Value

A list of residuals and other information (see lavaan::lavResiduals()). The standard residuals() (and resid() alias) method simply calls lavResiduals.mi(..., zstat=FALSE, summary=FALSE).

Author(s)

Terrence D. Jorgensen (University of Amsterdam; TJorgensen314@gmail.com)

See Also

lavaan::lavResiduals() for details about other arguments.

Examples


data(HS20imps) # import a list of 20 imputed data sets

## specify CFA model from lavaan's ?cfa help page
HS.model <- '
  visual  =~ x1 + x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9
'
## fit model to 20 imputed data sets
fit <- cfa.mi(HS.model, data = HS20imps)

## default type = "cor.bentler" (standardized covariance residuals)
lavResiduals.mi(fit, zstat = FALSE)
## SRMR is in the $summary

## correlation residuals
lavResiduals.mi(fit, zstat = FALSE, type = "cor")
## CRMR is in the $summary

## raw covariance residuals
lavResiduals.mi(fit, type = "raw") # zstat=TRUE by default
## RMR is in the $summary
## "normalized" residuals are in $cov.z


## The standard resid() and residuals() method simply call lavResiduals.mi()
## with arguments to display only the residuals ("raw" by default).

resid(fit)
residuals(fit, type = "cor.bollen") # same as type = "cor"



lavaan.mi documentation built on April 3, 2025, 9:36 p.m.