How to inspect Root Mean Square Residual (RMR)

399 views
Skip to first unread message

Torres

unread,
Oct 25, 2016, 5:06:23 PM10/25/16
to lavaan
Hello everyone,

I am conducting some CFA to inspect the fitness of some model with my dataset. I made use of the estimator of maximum likelihood (robust form) to estimate a model that is best fit with my dataset. Because I need to compare some fit indices of my current model with the ones of another model I need to have some necessary information of which there is one about the Root Mean Square Residual (RMR). Unfortunately, I could only gathered information on the Standardized Root Mean Square Residual (SRMR). Does anyone know how to get such RMR?

Thank you very much in advance!
Best regards,
Torres

kma...@aol.com

unread,
Oct 25, 2016, 11:43:18 PM10/25/16
to lavaan
Would this give you what you need?

require(lavaan)

## The famous Holzinger and Swineford (1939) example
HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9 '

fit <- cfa(HS.model, data=HolzingerSwineford1939)

getRMR <- function(fit, ...){
  # Bollen (1989) page 257
  obs.cov <- lavInspect(fit, 'sampstat')$cov
  obs.cov <- obs.cov[lower.tri(obs.cov, diag=TRUE)]
  imp.cov <- lavInspect(fit, 'cov.ov')
  imp.cov <- imp.cov[lower.tri(imp.cov, diag=TRUE)]
  rmr <- mean((obs.cov - imp.cov)^2)^.5
  return(rmr)
}

getRMR(fit)

------------------------
Keith A. Markus
John Jay College of Criminal Justice, CUNY
http://jjcweb.jjay.cuny.edu/kmarkus
Frontiers of Test Validity Theory: Measurement, Causation and Meaning.
http://www.routledge.com/books/details/9781841692203/

Yves Rosseel

unread,
Oct 26, 2016, 3:47:18 AM10/26/16
to lav...@googlegroups.com
> Does anyone know how to get such RMR?

fitMeasures(fit)

will give you along list; rmr is in the list. If you only want to see
'rmr', try

fitMeasures(fit, "rmr")

Yves.

Torres

unread,
Oct 26, 2016, 8:54:15 AM10/26/16
to lavaan
Thank you Keith

Vào 05:43:18 UTC+2 Thứ Tư, ngày 26 tháng 10 năm 2016, kma...@aol.com đã viết:

Torres

unread,
Oct 26, 2016, 9:13:03 AM10/26/16
to lavaan

Thank you Yves. I followed your instruction and I have rmr =.105 which is far greater than srmr= .045. I did not know how to explain such big difference.
Normally I get the information of some indices such as RMSEA, SRMR in the column of robust when I make use of estimator of MLM (robust form). But I could not find information of RMR at both ML as well as Robust column on the summary output. In my case, the score of rmr I got from fitMeasures(fit, "rmr") is the one that belongs to the Robust column, isn't it?

Vào 09:47:18 UTC+2 Thứ Tư, ngày 26 tháng 10 năm 2016, Yves Rosseel đã viết:

Yves Rosseel

unread,
Oct 26, 2016, 1:16:33 PM10/26/16
to lav...@googlegroups.com
On 10/26/2016 03:13 PM, Torres wrote:
> Thank you Yves. I followed your instruction and I have rmr =.105 which
> is far greater than srmr= .045. I did not know how to explain such big
> difference.

But rmr is not srmr. rmr is the square root of the mean of the squared
raw residuals, while srmr is the square root of the mean of the
*standardized* residuals.

For example,

library(lavaan)
example(cfa)

# observed S
S <- lavInspect(fit, "observed")$cov
# implied Sigma
Sigma <- lavInspect(fit, "implied")$cov

R <- lav_matrix_vech(S - Sigma)
# RMR
sqrt(mean(R^2))
# 0.08218433

# SRMR (EQS style)
sqrt.d <- 1/sqrt(diag(S))
D <- diag(sqrt.d, ncol=length(sqrt.d))
ZR <- lav_matrix_vech( D %*% (S - Sigma) %*% D )
sqrt(mean(ZR^2))
# 0.06520506

Most people would be interested in the standardized version.

> Normally I get the information of some indices such as RMSEA, SRMR in
> the column of robust when I make use of estimator of MLM (robust form).
> But I could not find information of RMR at both ML as well as Robust
> column on the summary output. In my case, the score of rmr I got from
> fitMeasures(fit, "rmr") is the one that belongs to the Robust column,
> isn't it?

It does not matter: RMR or SRMR are the same for both plain ML or robust
ML. They are just based on the residuals.

Yves.

Torres

unread,
Oct 27, 2016, 4:07:03 AM10/27/16
to lavaan
Now it's more clearly to me. Thanks you Yves.

Vào 19:16:33 UTC+2 Thứ Tư, ngày 26 tháng 10 năm 2016, Yves Rosseel đã viết:
Reply all
Reply to author
Forward
0 new messages