Random-intercept CLPM -- error

312 views
Skip to first unread message

Ros

unread,
Nov 30, 2020, 12:08:37 PM11/30/20
to lavaan
Hey there,

I've been trying to run the RI-CLPM specified here, using the multiple indicator extension: https://ellenhamaker.github.io/RI-CLPM/lavaan.html#ext_3:_multiple_indicator  

I used three categorical variables in my model (att_1/2/3 below), with 6 further latents, across three time points. As I have binary data for three variables, I used DWLS estimation.

My code is as follows: 

 riclpm <- '

# Create between factors (random intercepts) for each indicator separately.

####################################
#between part with random intercept#
####################################

#ri = random intercept


risdes_t1 =~ 1*sdes_q1 + 1*sdes_q4 + 1*sdes_q6 + 1*sdes_q8 + 1*sdes_q2 + 1*sdes_q3 + 1*sdes_q5 + 1*sdes_q7

riideation_t1 =~ 1*dssis_q1r + 1*dssis_q2r + 1*dssis_q3r + 1*dssis_q4r

risdes_t2 =~ 1*sdes_q1_2 + 1*sdes_q4_2 + 1*sdes_q6_2 + 1*sdes_q8_2 + 1*sdes_q2_2 + 1*sdes_q3_2 + 1*sdes_q5_2 + 1*sdes_q7_2

riideation_t2 =~ 1*dssis_q1r_2 + 1*dssis_q2r_2 + 1*dssis_q3r_2 + 1*dssis_q4r_2

risdes_t3 =~ 1*sdes_q1_3 + 1*sdes_q4_3 + 1*sdes_q6_3 + 1*sdes_q8_3 + 1*sdes_q2_3 + 1*sdes_q3_3 + 1*sdes_q5_3 + 1*sdes_q7_3

riideation_t3 =~ 1*dssis_q1r_3 + 1*dssis_q2r_3 + 1*dssis_q3r_3 + 1*dssis_q4r_3

##################################
# WITHIN PART: MEASUREMENT MODEL #
##################################


#wf = within factor
#create factor models for each construct at 3 waves

wfsdes_t1 =~ sdes_q1 + sdes_q4 + sdes_q6 + sdes_q8 + sdes_q2 + sdes_q3 + sdes_q5 + sdes_q7

wfideation_t1 =~ dssis_q1r + dssis_q2r + dssis_q3r + dssis_q4r

wfsdes_t2 =~ sdes_q1_2 + sdes_q4_2 + sdes_q6_2 + sdes_q8_2 + sdes_q2_2 + sdes_q3_2 + sdes_q5_2 + sdes_q7_2

wfideation_t2 =~ dssis_q1r_2 + dssis_q2r_2 + dssis_q3r_2 + dssis_q4r_2

wfsdes_t3 =~ sdes_q1_3 + sdes_q4_3 + sdes_q6_3 + sdes_q8_3 + sdes_q2_3 + sdes_q3_3 + sdes_q5_3 + sdes_q7_3

wfideation_t3 =~ dssis_q1r_3 + dssis_q2r_3 + dssis_q3r_3 + dssis_q4r_3


#########################
# WITHIN PART: DYNAMICS #
#########################

# Specify the lagged effects between the within-person centered latent variables.

wfideation_t2 + wfsdes_t2 + att_2 ~ wfideation_t1 + wfsdes_t1 + att_1

wfideation_t3 + wfsdes_t3 + att_3 ~ wfideation_t2 + wf sdes_t2 + att_2


# Estimate the correlations within the same wave.


wfsdes_t1 ~~ wfideation_t1  
wfideation_t1 ~~ att_1

wfsdes_t2 ~~ wfideation_t2 
wfideation_t2 ~~ att_2

wfsdes_t3 ~~ wfideation_t3 
wfideation_t3 ~~ att_3

##########################
# ADDITIONAL CONSTRAINTS #
##########################
  
# Constrain covariance of the between factors and exogenous within factors to 0. 
  
risdes_t1 + riideation_t1 + risdes_t2 + riideation_t2 + risdes_t3 + riideation_t3 ~~ 0*wfsdes_t1 + 0*wfideation_t1 + 0*att_1

'

# model identification and estimation
modelfit_riclpm <- sem(riclpm, data = clpm_sa_full2, ordered = "att_1", "att_2", "att_3")

summary(modelfit_riclpm, fit.measures = T, standardized = T, rsquare = T) 
```

However, I get the following errors: 

lavaan WARNING: trouble constructing W matrix; used generalized inverse for A11 submatrixlavaan WARNING:
    The variance-covariance matrix of the estimated parameters (vcov)
    does not appear to be positive definite! The smallest eigenvalue
    (= -8.072969e-12) is smaller than zero. This may be a symptom that
    the model is not identified.

lavaan WARNING: some estimated lv variances are negative


I've run the same model without the binary variables (att_), but I get the same errors, so I think it could be mostly due to the three Heywood cases in the model for the latter part of the error block above. 

However, I'm struggling to understand the earlier error for 'trouble constructing W matrix' and haven't been able to find much guidance online - can anyone help with this please?

It's very possible that I've also coded my model incorrectly above as I'm very new to this so any critical feedback would be hugely appreciated!

Thanks in advance. 


Terrence Jorgensen

unread,
Dec 3, 2020, 4:37:41 AM12/3/20
to lavaan
lavaan WARNING: trouble constructing W matrix; used generalized inverse for A11 submatrix
I'm struggling to understand the earlier error for 'trouble constructing W matrix' and haven't been able to find much guidance online - can anyone help with this please?

Looks like the weight matrix used in the default DWLS estimator was not positive definite, so lavaan needed to obtain its generalized (Moore-Penrose) inverse using the ginv() function instead of solve().

If you want to investigate why, you can extract the weight matrix using lavInspect(fit, "WLS.V")

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Yuanyuan Hu

unread,
Sep 20, 2023, 1:39:23 PM9/20/23
to lavaan
Hi,

I have similar problem here: RI-CLPMs with binary variables (CF: 1 or 0).  How should I proceed?

Warning messages:
1: In muthen1984(Data = X[[g]], wt = WT[[g]], ov.names = ov.names[[g]],  :

  lavaan WARNING: trouble constructing W matrix; used generalized inverse for A11 submatrix
2: In lavaan(fit.RICLPMEnjCF2, data = dat, estimator = "WLSMV", fixed.x = TRUE,  :
  lavaan WARNING:
    the optimizer warns that a solution has NOT been found!
3: In lav_test_satorra_bentler(lavobject = NULL, lavsamplestats = lavsamplestats,  :
  lavaan WARNING: could not invert information matrix needed for robust test statistic

fit.RICLPMEnjCF2 <- '
# 1b) Regression of random intercepts on time-invariant predictor z1
RIEnj ~ preEnj
RICF ~ preTest

# Residual variance and covariance z1
preEnj ~~ preEnj
preTest ~~ preTest
preEnj ~~ preTest

# Create between components (random intercepts)
RIEnj =~ 1*Enj1+1*Enj2+1*Enj3+1*Enj4+1*Enj5+1*Enj6+1*Enj7+1*Enj8+1*Enj9+1*Enj10+1*Enj11+1*Enj12+1*Enj13
RICF =~ 1*CF1+1*CF2+1*CF3+1*CF4+1*CF5+1*CF6+1*CF7+1*CF8+1*CF9+1*CF10+1*CF11+1*CF12+1*CF13

# Create within-person centered variables
wEnj1=~ 1*Enj1
wEnj2=~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wEnj9 ~ wCF9
wEnj10 ~ wCF10
wEnj11 ~ wCF11
wEnj12 ~ wCF12
wEnj13 ~ wCF13

# Estimate covariance between within-person centered variables at first wave
# wEnj1 ~~ wCF1  # Covariance
# Estimate covariances between residuals of within-person centered variables
# (i.e., innovations)

# Estimate variance and covariance of random intercepts
RIEnj ~~ RIEnj
RICF ~~ RICF
RICF ~~ RIEnj

# Estimate (residual) variance of within-person centered variables
wEnj1 ~~ wEnj1 # Variances
#wCF1 ~~ wCF1
wEnj2 ~~ wEnj2 # Residual variances
wEnj3 ~~ wEnj3
wEnj4 ~~ wEnj4
wEnj5 ~~ wEnj5
wEnj6 ~~ wEnj6
wEnj7 ~~ wEnj7
wEnj8 ~~ wEnj8
wEnj9 ~~ wEnj9
wEnj10 ~~ wEnj10
wEnj11 ~~ wEnj11
wEnj12 ~~ wEnj12
wEnj13 ~~ wEnj13

#wCF2 ~~ wCF2
#wCF3 ~~ wCF3
#wCF4 ~~ wCF4
#wCF5 ~~ wCF5
#wCF6 ~~ wCF6
#wCF7 ~~ wCF7
#wCF8 ~~ wCF8
#wCF9 ~~ wCF9
#wCF10 ~~ wCF10
#wCF11 ~~ wCF11
#wCF12 ~~ wCF12
#wCF13 ~~ wCF13
'
######################## 2a Robust RI-CLPM
fit.RICLPMEnjCF2L <- lavaan(fit.RICLPMEnjCF2,
                            data = dat,
                            estimator = "WLSMV", 
                            fixed.x = TRUE,
                            missing = "pairwise",
                            int.ov.free = T,
                            ordered=c("CF1","CF2","CF3","CF4","CF5","CF6","CF7","CF8","CF9","CF10","CF11","CF12","CF13"))
summary(fit.RICLPMEnjCF2L, fit.measures=TRUE)


Best,
Yuan

Yves Rosseel

unread,
Oct 13, 2023, 10:41:57 AM10/13/23
to lavaan
I have no experience with RI-CLPM models myself. But see:


It would seem you need to use parameterization = "theta".

Yves.

Yuanyuan Hu

unread,
Oct 14, 2023, 1:48:05 PM10/14/23
to lavaan
Thank you!
I added parameterization = "theta" and got:
Warning message:
In lavaan(fit.RICLPMEnjCF2, data = dat, estimator = "WLSMV", fixed.x = FALSE,  :
  lavaan WARNING:
    the optimizer (NLMINB) claimed the model converged, but not all
    elements of the gradient are (near) zero; the optimizer may not
    have found a local solution use check.gradient = FALSE to skip
    this check.

Based on your response on 
I added bounds = TRUE and got:
Warning messages:
1: In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats,  :
  lavaan WARNING:
    Could not compute standard errors! The information matrix could
    not be inverted. This may be a symptom that the model is not
    identified.
2: In lav_test_satorra_bentler(lavobject = NULL, lavsamplestats = lavsamplestats,  :

  lavaan WARNING: could not invert information matrix needed for robust test statistic

Yves Rosseel

unread,
Oct 17, 2023, 6:16:02 AM10/17/23
to lav...@googlegroups.com
On 10/14/23 19:48, Yuanyuan Hu wrote:
> Thank you!
> I added parameterization = "theta" and got:
> Warning message:
> In lavaan(fit.RICLPMEnjCF2, data = dat, estimator = "WLSMV", fixed.x =
> FALSE,  :
>   lavaan WARNING:
>     the optimizer (NLMINB) claimed the model converged, but not all
>     elements of the gradient are (near) zero; the optimizer may not
>     have found a local solution use check.gradient = FALSE to skip
>     this check.
>
> Based on your response on
> https://groups.google.com/g/lavaan/c/ASycfFKS56g
> I added bounds = TRUE

Hm. I would not use bounds here. They work well (only?) for single-level
models with continuous variables. If the results (without the bounds)
look reasonable, you can probably ignore the warning, and rerun the
model with check.gradient = FALSE.

It could also be that more work (than just adding parameterization =
"theta") is needed to properly identify this model in the presence of
categorical data. Perhaps Jeroen Mulder will have more information. As I
mentioned before, I have zero experience with the RI_CLPM model, but
perhaps these papers may be helpful:

Barendse, M., & Rosseel, Y. (2020). Multilevel Modeling in the ‘Wide
Format’ Approach with Discrete Data: A Solution for Small Cluster Sizes.
Structural Equation Modeling-A Multidisciplinary Journal, 27(5),
696-721. https://doi.org/10.1080/10705511.2019.1689366

Barendse, M. T., & Rosseel, Y. (2023). Multilevel SEM with random slopes
in discrete data using the pairwise maximum likelihood. British Journal
of Mathematical and Statistical Psychology, 76(2), 327-352.

Yves.
Reply all
Reply to author
Forward
0 new messages