Modification Indices for Weak/Strong Invariance Model with Effects Coding

157 views
Skip to first unread message

ben warner

unread,
Jun 11, 2014, 5:00:59 PM6/11/14
to lav...@googlegroups.com
Hi All, 

I am attempting to inspect modification indices for a model with two latent variables measured at two times. I have no problem getting these for the configural invariance model but when I place equality constraints across group and time for the loadings and/or intercepts I can't figure out how to get the modification indices. I'd like to see if any of the individual constraints have a large modification index to double-check that the loadings and intercepts aren't misbehaving across time or group. 

When I ask for the modification indices I get this error:
"Error in cbind(Q22, H10, t(H)) : 
  number of rows of matrices must match (see arg 3)" 

Here is the code I'm using for the weak invariance model: 

########## Weak Invariance model ##########

Grp2 <- '
## Define Latent Variables
PIE =~ c(s11, s11, s11)*PIE1 + c(s21, s21, s21)*PIE2 + c(s31, s31, s31)*PIE3
PIEt2 =~ c(s11, s11, s11)*PIE1t2 + c(s21, s21, s21)*PIE2t2 + c(s31, s31, s31)*PIE3t2
TW =~ c(s41, s41, s41)*TW13 + c(s51, s51, s51)*TW26 + c(s61, s61, s61)*TW45
TWt2 =~ c(s41, s41, s41)*TW13t2 + c(s51, s51, s51)*TW26t2 + c(s61, s61, s61)*TW45t2

## Residual for each indicator (and correlated residuals across time)

PIE1 ~~ PIE1
PIE2 ~~ PIE2
PIE3 ~~ PIE3 
PIE1t2 ~~ PIE1t2
PIE2t2 ~~ PIE2t2
PIE3t2 ~~ PIE3t2
TW13 ~~ TW13
TW26 ~~ TW26
TW45 ~~ TW45
TW13t2 ~~ TW13t2
TW26t2 ~~ TW26t2
TW45t2 ~~ TW45t2

PIE1 ~~ PIE1t2
PIE2 ~~ PIE2t2
PIE3 ~~ PIE3t2
TW13 ~~ TW13t2
TW26 ~~ TW26t2
TW45 ~~ TW45t2

## Intercepts

PIE1 ~ c(S1, D1, C1)*1
PIE2 ~ c(S2, D2, C2)*1
PIE3 ~ c(S3, D3, C3)*1
TW13 ~ c(S4, D4, C4)*1
TW26 ~ c(S5, D5, C5)*1
TW45 ~ c(S6, D6, C6)*1
PIE1t2 ~ c(S7, D7, C7)*1
PIE2t2 ~ c(S8, D8, C8)*1
PIE3t2 ~ c(S9, D9, C9)*1
TW13t2 ~ c(S10, D10, C10)*1
TW26t2 ~ c(S11, D11, C11)*1
TW45t2 ~ c(S12, D12, C12)*1

## Latent Variances
PIE ~~ PIE
PIEt2 ~~ PIEt2
TW ~~ TW
TWt2 ~~ TWt2

## Latent Covariances
PIE ~~ PIEt2 + TW + TWt2
PIEt2 ~~ TW + TWt2
TW ~~ TWt2

## Latent Means
PIE ~ 1
PIEt2 ~ 1
TW ~ 1 
TWt2 ~ 1

## Model Constraints for effects-coding

# PIE in all 3 groups
s11 == 3 - s21 - s31


# TW in all 3 groups 
s41 == 3 - s51 - s61


# PIE means all 3 groups
S1 == 0 - S2 - S3
D1 == 0 - D2 - D3
C1 == 0 - C2 - C3
S4 == 0 - S5 - S6
D4 == 0 - D5 - D6
C4 == 0 - C5 - C6
S7 == 0 - S8 - S9
D7 == 0 - D8 - D9
C7 == 0 - C8 - C9
S10 == 0 - S11 - S12
D10 == 0 - D11 - D12
C10 == 0 - C11 - C12

'

fit2.1 <- lavaan(Grp2, data=Tw, group="Condition", std.lv=F, auto.fix.first=F)
inspect(fit2.1, "modindices")


Thanks in advance!!! 

Ben 

yrosseel

unread,
Jun 15, 2014, 6:18:39 AM6/15/14
to lav...@googlegroups.com
> When I ask for the modification indices I get this error:
> "Error in cbind(Q22, H10, t(H)) :
> number of rows of matrices must match (see arg 3)"

This looks like a bug in 0.5-16. It is related to the explicit equality
constraints (==) in the model syntax. Will fix this ASAP.

Yves.

ben warner

unread,
Jun 17, 2014, 3:16:20 PM6/17/14
to lav...@googlegroups.com
Thanks Yves! 

As an aside, I'm a recent Lavaan convert and I absolutely love using it. Thank you for all of your hard work! 

Markus Mattsson

unread,
Jul 23, 2014, 6:29:22 AM7/23/14
to lav...@googlegroups.com
Hello Yves & the group,

it seems this issue is still unresolved in lavaan 0.5-17.701. I understand, of course, that fixing issues such as this takes time, but just to schedule my own work I would greatly appreciate further info on when the issue might get fixed. I looked at the code of modificationIndices in the hopes that I could help in fixing the problem, but I'm afraid I don't have the necessary skills to help. Thanks for the great software & keep up the good work!

Markus Mattsson

Yves Rosseel

unread,
Jul 26, 2014, 12:36:14 PM7/26/14
to lav...@googlegroups.com
On 07/23/2014 12:29 PM, Markus Mattsson wrote:
> Hello Yves & the group,
>
> it seems this issue is still unresolved in lavaan 0.5-17.701.

True. The root of the problem is that we combine two different types of
equality constraints: the explicit ones (using the == operator), and the
implicit ones, using either group.equal, or labels, etc... This confuses
the modindices() function.

To fix this, I will need to merge the two 'equality constraints'
approaches that are used within lavaan. This requires a lot of work, and
some careful testing.

But today is the first day of my vacation, so it will have to wait for
at least another 4 weeks.

Yves.

Edward Rigdon

unread,
Jul 26, 2014, 3:00:20 PM7/26/14
to lav...@googlegroups.com
Yay!! Yves gets a vacation! In all seriousness, I am glad to hear that you make time for yourself.
--Ed Rigdon

Sent from my iPad
> --
> You received this message because you are subscribed to the Google Groups "lavaan" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
> To post to this group, send email to lav...@googlegroups.com.
> Visit this group at http://groups.google.com/group/lavaan.
> For more options, visit https://groups.google.com/d/optout.

Yves Rosseel

unread,
Jul 27, 2014, 1:54:24 PM7/27/14
to lav...@googlegroups.com
On 07/26/2014 09:00 PM, Edward Rigdon wrote:
> Yay!! Yves gets a vacation! In all seriousness, I am glad to hear that you make time for yourself.

Thanks. In fact, I will enjoy a completely email-free vacation starting
in a few days.

Yves.

yrosseel

unread,
Dec 5, 2015, 2:50:17 PM12/5/15
to lav...@googlegroups.com
On 07/23/2014 12:29 PM, Markus Mattsson wrote:
> Hello Yves & the group,
>
> it seems this issue is still unresolved in lavaan 0.5-17.701. I
> understand, of course, that fixing issues such as this takes time, but
> just to schedule my own work I would greatly appreciate further info on
> when the issue might get fixed. I looked at the code of
> modificationIndices in the hopes that I could help in fixing the
> problem, but I'm afraid I don't have the necessary skills to help.
> Thanks for the great software & keep up the good work!

For future reference:

Since 0.5-20, the function modindices() only gives modification indices
for 'newly added' parameters: parameters that were not included in the
original model, or parameters that were fixed to a constant (say, zero).

For (equality) constraints (either explicit constraints, using labels or
the == operator, or via the group.equal= argument) you should use the
lavTestScore() function, which provides score tests (aka Lagrange
Multiplier tests) for releasing all the constraints in the model
(multivariate), one constraint at a time (univariate), or releasing
constraints in a cumulative fashion. It also provides EPC values for all
the other parameters in the model, if all (or a selection of) the
constraints are released.

(Remember: for adding new parameters, modification indices are identical
to the test statistics of univariate score tests)

Yves.

Reply all
Reply to author
Forward
0 new messages