# CFA lavaan Interpreting NA standardized residuals

I am implementing CFA at the moment and looking at the residuals of model to determine how to improve the model fit When i take the raw scores from the model, i get residuals for everything When i take a look at the standardized/z-score residuals, I can see NA between some of the questions which have large residuals in the raw score

I would like to examine the standardized residuals because i know those residuals are statistically significant at 1.96 (p<0.05) and 2.58(p<0.01) Can anyone explain to me why the null values exist?

Below is a reproducible example where x3 and x2 have raw residual scores of 0.126 but when i standardize them i get NA

# Stackoverflow Question
library(lavaan)

mydf <- HolzingerSwineford1939

# First Create the CFA model for both groups combined
HS.model <- ' visual  =~ x1 + x2 + x3
textual =~ x4 + x5 + x6'

# Fit the model Standardizing on the latent variable
fit <- cfa(HS.model, data = mydf, meanstructure = TRUE, std.lv = TRUE, estimator = 'MLR')

# Get the standardized residuals
res_raw <- residuals(fit, type = 'raw')$cov # Get the standardized residuals res <- residuals(fit, type = 'standardized')$cov


If you check the documentation for lavaan-class, you will see a reference to Standardized Residuals in Mplus. This document explains how the normalized and standardized residuals computed in Mplus and I think lavaan follows Mplus in this computation (see documentation of lavaan-class: "For more information about the normalized and standardized residuals, see the Mplus reference below.")

According to this document, the standardized mean residual is

$$\frac{m_i-\hat \mu_i}{\sqrt{Var(m_i-\hat \mu_i)}}$$

and the standardized covariance residual is

$$\frac{s_{ij}-\hat \sigma_{ij}}{\sqrt{Var(s_{ij}-\hat \sigma_{ij})}}.$$

And in both cases, Hausman's theorem is used for the calculation of variance, so

\begin{align} Var(m_i-\hat \mu_i) &= Var(m_i) -Var(\hat \mu_i) \\ Var(s_{ij}-\hat \sigma_{ij}) &= Var(s_{ij}) -Var(\hat \sigma_{ij}). \end{align}

At the end of the document, it is explained that

One problem with Hausman’s (1978) approach to computing the residual variance is that sometimes the variance estimates given by [the above equations] can be negative. In that case the standardized residual is not computed and Mplus prints 999. Typically in such situation the normalized residual can be used.

Similarly, lavaan returns NA. It is also recommended in lavaan documentation to use normalized residuals.