long.equal="resid.autocov" does not work
Closed this issue · 2 comments
Hi, I have found that in longitudinal invariance, constraining of residual autocovariances (and also of latent autocovariances) does not work. I am not sure if I am doing something wrong, but I cannot handle with it. Here is the syntax:
long_model <- "
## model pre
Understand1 =~ ersqPRE_11+ersqPRE_20+ersqPRE_3+ersqPRE_13+ersqPRE_25+ersqPRE_6
Bodysens1 =~ ersqPRE_7+ersqPRE_14+ersqPRE_24
ResilAccept1 =~ ersqPRE_18+ersqPRE_26+ersqPRE_4+ersqPRE_5+ersqPRE_17
Selfsupport1 =~ ersqPRE_15+ersqPRE_9+ersqPRE_27
Modification1 =~ ersqPRE_2+ersqPRE_10+ersqPRE_21
Confront1 =~ ersqPRE_8+ersqPRE_16+ersqPRE_22
Emoawareness1 =~ ersqPRE_12+ersqPRE_19+ersqPRE_1
## W2
Understand2 =~ ersqW2_11+ersqW2_20+ersqW2_3+ersqW2_13+ersqW2_25+ersqW2_6
Bodysens2 =~ ersqW2_7+ersqW2_14+ersqW2_24
ResilAccept2 =~ ersqW2_18+ersqW2_26+ersqW2_4+ersqW2_5+ersqW2_17
Selfsupport2 =~ ersqW2_15+ersqW2_9+ersqW2_27
Modification2 =~ ersqW2_2+ersqW2_10+ersqW2_21
Confront2 =~ ersqW2_8+ersqW2_16+ersqW2_22
Emoawareness2 =~ ersqW2_12+ersqW2_19+ersqW2_1
## W3
Understand3 =~ ersqW3_11+ersqW3_20+ersqW3_3+ersqW3_13+ersqW3_25+ersqW3_6
Bodysens3 =~ ersqW3_7+ersqW3_14+ersqW3_24
ResilAccept3 =~ ersqW3_18+ersqW3_26+ersqW3_4+ersqW3_5+ersqW3_17
Selfsupport3 =~ ersqW3_15+ersqW3_9+ersqW3_27
Modification3 =~ ersqW3_2+ersqW3_10+ersqW3_21
Confront3 =~ ersqW3_8+ersqW3_16+ersqW3_22
Emoawareness3 =~ ersqW3_12+ersqW3_19+ersqW3_1
"
long_fac <- list(Understand = paste0("Understand", c(1:3)),
Bodysens = paste0("Bodysens", c(1:3)),
ResilAccept = paste0("ResilAccept", c(1:3)),
Selfsupport = paste0("Selfsupport", c(1:3)),
Modification = paste0("Modification", c(1:3)),
Confront = paste0("Confront", c(1:3)),
Emoawareness = paste0("Emoawareness", c(1:3)))
And the respective fitting function:
system.time(config <- measEq.syntax(configural.model = long_model,
data=ERSQ_data, estimator="MLR", missing= "FIML",
ID.fac = "std.lv",
longFacNames = long_fac,
return.fit = T, verbose = T,
auto = T,
long.equal = "resid.autocov"))
I know that I cannot compare residual autocovariances between timepoints unless the residual invariance, but I need to simplify the model as I have originally eight measurement and the sample size is too small considering the complexity of the model.
I ran your syntax without the data:
config <- measEq.syntax(configural.model = long_model,
longFacNames = long_fac,
auto = TRUE, long.equal = "resid.autocov")
It works fine for me. For example, cat(as.character(config))
shows me:
## UNIQUE-FACTOR COVARIANCES:
ersqPRE_11 ~~ NA*ersqW2_11 + theta.27_1*ersqW2_11
ersqPRE_11 ~~ NA*ersqW3_11 + theta.53_1*ersqW3_11
...
ersqW2_11 ~~ NA*ersqW3_11 + theta.27_1*ersqW3_11
The same label theta.27_1
is used for both Lag-1 autocovariances, and the Lag-2 autocovariance has a different label theta.53_1
. If you extend your syntax to 4 (or more) occasions, you will notice the same Lag-2 label used for the other Lag-2 autocovariance(s).
I recall fixing an autocov
bug in the past, but I don't remember whether this is it or whether the fix is already on CRAN. Try installing the development version if your output does not match mine.
devtools::install_github("simsem/semTools/semTools")
I am using version 0.5-3.910 on R 4.0.3
It works, thank you. I assumed the same covariances across all the residuals, but the function constrained them only for the same lags. This approach is obviously more appropriate, however, it needs more parameters.