Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Effects coding to receive mean values

219 views
Skip to first unread message

Sabrina D

unread,
Jun 11, 2018, 5:20:27 AM6/11/18
to lavaan

Hi,

I'm quite new to SEM in general and to lavaan, so maybe my general idea here is wrong, but I am trying to use effects-coding to get mean values for my latent factors that are of the same scale as my indicators. (I would like to use those within my discussion/interpretation)

Below is my code. 

I have a higher order model, so I was not sure if I need to add effects coding in the same way for the second order factors or not. (as I would like to have a mean value for the second order factors as well)

After adding effects coding the model converged normally and I got the same fit measures as before, but I still get 0.000 as estimates for all latent factors. 

Can anyone advise me on how to change my code? Or how to get mean values for the latent factors.

Thanks in advance
/S


```{r, echo=TRUE}
myModel10<-'
# measurement model
knowledge       =~ NA*C1_SQ1 + a1*C1_SQ1 + a2*C1_SQ2 + a3*C1_SQ3 + a4*C1_SQ4 + a5*C1_SQ5 + a6*C1_SQ6 + a7*C1_SQ7 + a8*C1_SQ8 + a9*C1_SQ9 + a10*C1_SQ10 + a11*C1_SQ11 + a12*C1_SQ12 + a13*C1_SQ13
resources        =~ NA*E3_SQ1 + b1*E3_SQ1 + b2*E3_SQ2 + b3*E3_SQ3
fairness         =~ NA*F2_SQ1 + c1*F2_SQ1 + c2*F2_SQ2 + c3*F2_SQ3 + c4*F2_SQ4
uppward_trustVD  =~ NA*G5_SQ1 + d1*G5_SQ1 + d2*G5_SQ2 + d3*G5_SQ3 + d4*G6 
uppward_trustLS  =~ NA*G7_SQ1 + e1*G7_SQ1 + e2*G7_SQ2 + e3*G7_SQ3 + e4*G8
communication    =~ NA*D1_SQ1 + f1*D1_SQ1 + f2*D1_SQ2 + f3*D1_SQ3 + f4*D1_SQ4 
internal_collab  =~ NA*D4_SQ1 + g1*D4_SQ1 + g2*D4_SQ2 + g3*D4_SQ3 
internal_trust   =~ NA*G1_SQ1 + h1*G1_SQ1 + h2*G1_SQ2 + h3*G1_SQ3 + h4*G2
downward_trust   =~ NA*G3_SQ1 + i1*G3_SQ1 + i2*G3_SQ2 + i3*G3_SQ3 + i4*G4
external_collab  =~ NA*D2_SQ1 + j1*D2_SQ1 + j2*D2_SQ2 + j3*D2_SQ3 + j4*D3_SQ1 + j5*D3_SQ2 + j6*D3_SQ3
perceived_AC     =~ NA*I6_SQ1 + k1*I6_SQ1 + k2*I6_SQ2 + k3*I6_SQ3

a1 == 13 - a2 - a3 - a4 - a5 - a6 - a7 - a8 - a9 - a10 - a11 - a12 - a13
b1 == 3 - b2 - b3
c1 == 4 - c2 - c3 - c4
d1 == 4 - d2 - d3 - d4
e1 == 4 - e2 - e3 - e4
f1 == 4 - f2 - f3 - f4
g1 == 3 - g2 - g3
h1 == 4 - h2 - h3 - h4
i1 == 4 - i2 - i3 - i4
j1 == 6 - j2 - j3 - j4 - j5 - j6
k1 == 3 - k2 - k3


#higher order factors
trust_above =~ uppward_trustVD + uppward_trustLS
Groupsense =~ communication + internal_collab + internal_trust


# regression part
perceived_AC ~ knowledge + resources + fairness + trust_above + Groupsense + downward_trust + external_collab   

'
```
```{r}
fit10 <- sem(myModel10, data = df_sub, std.lv=TRUE,  missing="fiml", estimator="MLR")
fit10
summary(fit10, fit.measures=TRUE)
```

Terrence Jorgensen

unread,
Jun 13, 2018, 9:51:57 AM6/13/18
to lavaan
I am trying to use effects-coding to get mean values for my latent factors that are of the same scale as my indicators.

Well, that's not really what effects-coding does, despite what you may have read.  That assumption is based on the same misunderstanding that fixing the first factor loading to 1 and intercept to zero would put the latent variable on the scale of that indicator.  Not the case.  The latent variable is latent, it does not have a scale or location.  At best, choosing a marker variable simply puts the construct on the scale of the common part of the indicator that is shared among the other indicators, but that itself is latent.  Effects coding is just as arbitrary as the other possible identification methods, so I'm not discouraging you from using it, just from over-interpreting the latent means/intercepts as being directly interpretable on the scale of the indicators.


I have a higher order model, so I was not sure if I need to add effects coding in the same way for the second order factors or not. (as I would like to have a mean value for the second order factors as well)

In that case, yes.

After adding effects coding the model converged normally and I got the same fit measures as before, but I still get 0.000 as estimates for all latent factors. 

Because you have set std.lv = TRUE, lavaan is fixing all the latent means/intercepts to 0 and latent (residual) variances to 1 by default.  You can override that in the syntax by telling lavaan to freely estimate them.  For example, to free the latent variances:

knowledge ~~ NA*knowledge

Since you want the latent mean estimates, you also need to actually put the mean structure in your model syntax, using the same logic to constrain the intercepts to average zero, and freeing the latent mean.  For example:

I6_SQ1 ~ m1*1
I6_SQ2
~ m2*1
I6_SQ3
~ m3*1
k1
== 0 - k2 - k3
perceived_AC
~ NA*1


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

Sabrina D

unread,
Jun 15, 2018, 7:57:40 AM6/15/18
to lavaan
Dear  Terrence,
Thanks a lot for your answer. I feel like I'm one step closer! 

I freed my latent variances and added the mean structure to free the latent mean. Looking at the results I see that it worked partly, but not for those latent that are part of a higher order factor. I would like to get latent mean estimates for the first and second order factors. (If this is even possible?) Could you please have another look at my model code below?  

Best,
S

```{r, echo=TRUE}
myModel10<-'
# measurement model
knowledge       =~ NA*C1_SQ1 + a1*C1_SQ1 + a2*C1_SQ2 + a3*C1_SQ3 + a4*C1_SQ4 + a5*C1_SQ5 + a6*C1_SQ6 + a7*C1_SQ7 + a8*C1_SQ8 + a9*C1_SQ9 + a10*C1_SQ10 + a11*C1_SQ11 + a12*C1_SQ12 + a13*C1_SQ13
resources        =~ NA*E3_SQ1 + b1*E3_SQ1 + b2*E3_SQ2 + b3*E3_SQ3
fairness         =~ NA*F2_SQ1 + c1*F2_SQ1 + c2*F2_SQ2 + c3*F2_SQ3 + c4*F2_SQ4
uppward_trustVD  =~ NA*G5_SQ1 + d1*G5_SQ1 + d2*G5_SQ2 + d3*G5_SQ3 + d4*G6 
uppward_trustLS  =~ NA*G7_SQ1 + e1*G7_SQ1 + e2*G7_SQ2 + e3*G7_SQ3 + e4*G8
communication    =~ NA*D1_SQ1 + f1*D1_SQ1 + f2*D1_SQ2 + f3*D1_SQ3 + f4*D1_SQ4 
internal_collab  =~ NA*D4_SQ1 + g1*D4_SQ1 + g2*D4_SQ2 + g3*D4_SQ3 
internal_trust   =~ NA*G1_SQ1 + h1*G1_SQ1 + h2*G1_SQ2 + h3*G1_SQ3 + h4*G2
downward_trust   =~ NA*G3_SQ1 + i1*G3_SQ1 + i2*G3_SQ2 + i3*G3_SQ3 + i4*G4
external_collab  =~ NA*D2_SQ1 + j1*D2_SQ1 + j2*D2_SQ2 + j3*D2_SQ3 + j4*D3_SQ1 + j5*D3_SQ2 + j6*D3_SQ3
perceived_AC     =~ NA*I6_SQ1 + k1*I6_SQ1 + k2*I6_SQ2 + k3*I6_SQ3

#higher order factors
trust_above      =~ NA*uppward_trustVD + l1*uppward_trustVD + l2*uppward_trustLS
Groupsense       =~ NA*communication + m1*communication + m2*internal_collab + m3*internal_trust

#effects coding method for mean and covariance structures of latent variables
#set loading structure -> loadings for a given construct should average to 1, which is the same as having them sum to the muber of indicators  
a1 == 13 - a2 - a3 - a4 - a5 - a6 - a7 - a8 - a9 - a10 - a11 - a12 - a13
b1 == 3 - b2 - b3
c1 == 4 - c2 - c3 - c4
d1 == 4 - d2 - d3 - d4
e1 == 4 - e2 - e3 - e4
f1 == 4 - f2 - f3 - f4
g1 == 3 - g2 - g3
h1 == 4 - h2 - h3 - h4
i1 == 4 - i2 - i3 - i4
j1 == 6 - j2 - j3 - j4 - j5 - j6
k1 == 3 - k2 - k3
l1 == 2 - l2
m1 == 3 - m2 - m3

#set intercept structure for indicators -> they should sum to zero for each construct
C1_SQ1  ~ n1*1
C1_SQ2  ~ n2*1
C1_SQ3  ~ n3*1
C1_SQ4  ~ n4*1
C1_SQ5  ~ n5*1 
C1_SQ6  ~ n6*1 
C1_SQ7  ~ n7*1  
C1_SQ8  ~ n8*1 
C1_SQ9  ~ n9*1 
C1_SQ10 ~ n10*1 
C1_SQ11 ~ n11*1 
C1_SQ12 ~ n12*1 
C1_SQ13 ~ n13*1
n1 == 0 - n2 - n3 - n4 - n5 - n6 - n7 - n8 - n9 - n10 - n11 - n12 - n13

E3_SQ1  ~ o1*1 
E3_SQ2  ~ o2*1 
E3_SQ3  ~ o3*1
o1 == 0 - o2 - o3

F2_SQ1  ~ p1*1
F2_SQ2  ~ p2*1 
F2_SQ3  ~ p3*1 
F2_SQ4  ~ p4*1
p1 == 0 - p2 - p3 - p4

G5_SQ1  ~ q1*1 
G5_SQ2  ~ q2*1 
G5_SQ3  ~ q3*1 
G6      ~ q4*1
q1 == 0 - q2 - q3 - q4

G7_SQ1  ~ r1*1 
G7_SQ2  ~ r2*1 
G7_SQ3  ~ r3*1 
G8      ~ r4*1
r1 == 0 - r2 - r3 - r4

D1_SQ1  ~ s1*1 
D1_SQ2  ~ s2*1 
D1_SQ3  ~ s3*1
D1_SQ4  ~ s4*1 
s1 == 0 - s2 - s3 - s4

D4_SQ1  ~ t1*1
D4_SQ2  ~ t2*1
D4_SQ3  ~ t3*1 
t1 == 0 - t2 - t3

G1_SQ1  ~ u1*1 
G1_SQ2  ~ u2*1 
G1_SQ3  ~ u3*1 
G2      ~ u4*1
u1 == 0 - u2 - u3 - u4

G3_SQ1  ~ v1*1 
G3_SQ2  ~ v2*1 
G3_SQ3  ~ v3*1 
G4      ~ v4*1
v1 == 0 - v2 - v3 - v4

D2_SQ1  ~ w1*1 
D2_SQ2  ~ w2*1 
D2_SQ3  ~ w3*1 
D3_SQ1  ~ w4*1 
D3_SQ2  ~ w5*1 
D3_SQ3  ~ w6*1
w1 == 0 - w2 - w3 - w4 - w5 - w6

I6_SQ1  ~ z1*1 
I6_SQ2  ~ z2*1 
I6_SQ3  ~ z3*1
z1 == 0 - z2 - z3

#free latent variance
knowledge       ~~ NA*knowledge
resources       ~~ NA*resources
fairness        ~~ NA*fairness
uppward_trustVD ~~ NA*uppward_trustVD
uppward_trustLS ~~ NA*uppward_trustLS
communication   ~~ NA*communication 
internal_collab ~~ NA*internal_collab
internal_trust  ~~ NA*internal_trust
downward_trust  ~~ NA*downward_trust
external_collab ~~ NA*external_collab
perceived_AC    ~~ NA*perceived_AC
trust_above     ~~ NA*trust_above
Groupsense      ~~ NA*Groupsense

#free latent means
knowledge       ~ NA*1
resources       ~ NA*1
fairness        ~ NA*1
uppward_trustVD ~ NA*1
uppward_trustLS ~ NA*1
communication   ~ NA*1 
internal_collab ~ NA*1
internal_trust  ~ NA*1
downward_trust  ~ NA*1
external_collab ~ NA*1
perceived_AC    ~ NA*1
trust_above     ~ NA*1
Groupsense      ~ NA*1

# regression part
perceived_AC ~ knowledge + resources + fairness + trust_above + Groupsense + downward_trust + external_collab   


#residual correlation  because of measurement
#knowledge scale ungulate
C1_SQ1 ~~ C1_SQ2
C1_SQ1 ~~ C1_SQ3
C1_SQ2 ~~ C1_SQ3
C1_SQ3 ~~ C1_SQ4
#knowledge scale damage
C1_SQ5 ~~ C1_SQ6
C1_SQ5 ~~ C1_SQ7
C1_SQ5 ~~ C1_SQ8
C1_SQ6 ~~ C1_SQ7
C1_SQ6 ~~ C1_SQ8
C1_SQ7 ~~ C1_SQ8
#knowledge scale neg population effects
C1_SQ9 ~~ C1_SQ10
C1_SQ9 ~~ C1_SQ11
C1_SQ10 ~~ C1_SQ11

#levels within external collaboration
D2_SQ2 ~~ D2_SQ3
D3_SQ2 ~~ D3_SQ3
D2_SQ1 ~~ D3_SQ1 
D2_SQ2 ~~ D3_SQ2
D2_SQ3 ~~ D3_SQ3 
#negative statements in trust
G1_SQ1 ~~ G1_SQ3
G3_SQ1 ~~ G3_SQ3
G5_SQ1 ~~ G5_SQ3
G7_SQ1 ~~ G7_SQ3
#positive statements in trust
G1_SQ2 ~~ G2
G3_SQ2 ~~ G4
G5_SQ2 ~~ G6
G7_SQ2 ~~ G8
#neg/pos statements in fairness
F2_SQ1 ~~ F2_SQ3
F2_SQ2 ~~ F2_SQ4
#communication with similar stem
D1_SQ2 ~~ D1_SQ3
#same trust question used 
G1_SQ1 ~~ G3_SQ1
G1_SQ2 ~~ G3_SQ2
G1_SQ3 ~~ G3_SQ3
G2 ~~ G4
G1_SQ1 ~~ G5_SQ1
G1_SQ2 ~~ G5_SQ2
G1_SQ3 ~~ G5_SQ3
G2 ~~ G6
G1_SQ1 ~~ G7_SQ1
G1_SQ2 ~~ G7_SQ2
G1_SQ3 ~~ G7_SQ3
G2 ~~ G8
G3_SQ1 ~~ G5_SQ1
G3_SQ2 ~~ G5_SQ2
G3_SQ3 ~~ G5_SQ3
G4 ~~ G6
G3_SQ1 ~~ G7_SQ1
G3_SQ2 ~~ G7_SQ2
G3_SQ3 ~~ G7_SQ3
G4 ~~ G8
G5_SQ1 ~~ G7_SQ1
G5_SQ2 ~~ G7_SQ2
G5_SQ3 ~~ G7_SQ3
G6 ~~ G8
'

Terrence Jorgensen

unread,
Jun 24, 2018, 8:50:40 AM6/24/18
to lavaan
Looking at the results I see that it worked partly, but not for those latent that are part of a higher order factor.

That's because all you did was free those estimates (e.g., uppward_trustVD ~ NA*1)

I would like to get latent mean estimates for the first and second order factors. (If this is even possible?) 

Yes, do the same thing for second-order indicators (which are first-order common factors) that you did for the first-order indicators: provide labels when you free them, and apply the effects-coding constraints using the labels.

uppward_trustVD ~ NA*1 + arbitraryLabel*1
Reply all
Reply to author
Forward
0 new messages