Residuals
lavResiduals.Rd‘lavResiduals’ provides model residuals and standardized residuals from a fitted lavaan object, as well as various summaries of these residuals.
The ‘residuals()’ (and ‘resid()’) methods are just shortcuts to this function with a limited set of arguments.
Usage
lavResiduals(object, type = "cor.bentler", custom.rmr = NULL,
se = FALSE, zstat = TRUE, summary = TRUE, h1.acov = "unstructured",
add.type = TRUE, add.labels = TRUE, add.class = TRUE,
drop.list.single.group = TRUE,
maximum.number = length(res.vech), output = "list")Arguments
- object
An object of class
lavaan.- type
Character. If
type = "raw", this function returns the raw (= unscaled) difference between the observed and the expected (model-implied) summary statistics, as well as the standardized version of these residualds. Iftype = "cor", ortype = "cor.bollen", the observed and model implied covariance matrices are first transformed to a correlation matrix (usingcov2cor()), before the residuals are computed. Iftype = "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.- custom.rmr
list. Not used yet.- se
Logical. If
TRUE, show the estimated standard errors for the residuals.- zstat
Logical. If
TRUE, show the standardized residuals, which are the raw residuals divided by the corresponding (estimated) standard errors.- summary
Logical. If
TRUE, show various summaries of the (possibly scaled) residuals. Whentype = "raw", we compute the RMR. Whentype = "cor.bentler", we compute the SRMR. Whentype = "cor.bollen", we compute the CRMR. An unbiased version of these summaries is also computed, as well as a standard error, a z-statistic and a p-value for the test of exact fit based on these summaries.- h1.acov
Character. If
"unstructured", the observed summary statistics are used as consistent estimates of the corresponding (unrestricted) population statistics. If"structured", the model-implied summary statistics are used as consistent estimates of the corresponding (unrestricted) population statistics. This affects the way the asymptotic variance matrix of the summary statistics is computed.- add.type
Logical. If
TRUE, show the type of residuals in the output.- add.labels
If
TRUE, variable names are added to the vectors and/or matrices.- add.class
If
TRUE, vectors are given the ‘lavaan.vector’ class; matrices are given the ‘lavaan.matrix’ class, and symmetric matrices are given the ‘lavaan.matrix.symmetric’ class. This only affects the way they are printed on the screen.- drop.list.single.group
If
FALSE, the results are returned as a list, where each element corresponds to a group (even if there is only a single group). IfTRUE, the list will be unlisted if there is only a single group.- maximum.number
Integer. Only used if
output ="table". Show only the first maximum.number rows of the data.frame.- output
Character. By default,
output = "list", and the output is a list of elements. Ifoutput = "table", only the residuals of the variance-covariance matrix are shown in a data.frame, sorted from high (in absolute value) to low.
Value
If drop.list.single.group = TRUE, a list of (residualized) summary
statistics, including type, standardized residuals, and summaries. If
drop.list.single.group = FALSE, the list of summary statistics is nested
within a list for each group.
References
Bentler, P.M. and Dijkstra, T. (1985). Efficient estimation via linearization in structural models. In Krishnaiah, P.R. (Ed.), Multivariate analysis - VI, (pp. 9–42). New York, NY: Elsevier.
Ogasawara, H. (2001). Standard errors of fit indices using residuals in structural equation modeling. Psychometrika, 66(3), 421–436. doi:10.1007/BF02294443
Maydeu-Olivares, A. (2017). Assessing the size of model misfit in structural equation models. Psychometrika, 82(3), 533–558. doi:10.1007/s11336-016-9552-7
Standardized Residuals in Mplus. Document retrieved from URL http://www.statmodel.com/download/StandardizedResiduals.pdf
Examples
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
fit <- cfa(HS.model, data = HolzingerSwineford1939)
lavResiduals(fit)
#> $type
#> [1] "cor.bentler"
#>
#> $cov
#> x1 x2 x3 x4 x5 x6 x7 x8 x9
#> x1 0.000
#> x2 -0.030 0.000
#> x3 -0.008 0.094 0.000
#> x4 0.071 -0.012 -0.068 0.000
#> x5 -0.009 -0.027 -0.151 0.005 0.000
#> x6 0.060 0.030 -0.026 -0.009 0.003 0.000
#> x7 -0.140 -0.189 -0.084 0.037 -0.036 -0.014 0.000
#> x8 -0.039 -0.052 -0.012 -0.067 -0.036 -0.022 0.075 0.000
#> x9 0.149 0.073 0.147 0.048 0.067 0.056 -0.038 -0.032 0.000
#>
#> $cov.z
#> x1 x2 x3 x4 x5 x6 x7 x8 x9
#> x1 0.000
#> x2 -1.996 0.000
#> x3 -0.997 2.689 0.000
#> x4 2.679 -0.284 -1.899 0.000
#> x5 -0.359 -0.591 -4.157 1.545 0.000
#> x6 2.155 0.681 -0.711 -2.588 0.942 0.000
#> x7 -3.773 -3.654 -1.858 0.865 -0.842 -0.326 0.000
#> x8 -1.380 -1.119 -0.300 -2.021 -1.099 -0.641 4.823 0.000
#> x9 4.077 1.606 3.518 1.225 1.701 1.423 -2.325 -4.132 0.000
#>
#> $summary
#> cov
#> srmr 0.065
#> srmr.se 0.006
#> srmr.exactfit.z 6.063
#> srmr.exactfit.pvalue 0.000
#> usrmr 0.058
#> usrmr.se 0.010
#> usrmr.ci.lower 0.042
#> usrmr.ci.upper 0.074
#> usrmr.closefit.h0.value 0.050
#> usrmr.closefit.z 0.832
#> usrmr.closefit.pvalue 0.203
#>