time invariant covariates in LGM

62 views

rothmi...@hotmail.com

Mar 1, 2019, 7:36:36 AM3/1/19
to lavaan
Hey everyone

I`m writting my masterthesis in psychology and I`m struggling with latent growth curve models....
I have a model that fits quite good. No I`d like to add a time-invariant covariate. How can I do this? The covariate is metric (communication scores)

Here`s my model:

modell_PZ_f <- "
ACSIf =~ a*acsi01.1 + b*acsi05.1 + c*acsi07.1 + d*acsi10.1
CCSIf =~ a*ccsi01.1 + b*ccsi05.1 + c*ccsi07.1 + d*ccsi10.1
HCSIf =~ a*hcsi01.1 + b*hcsi05.1 + c*hcsi07.1 + d*hcsi10.1
ICSIf =~ a*icsi01.1 + b*icsi05.1 + c*icsi07.1 + d*icsi10.1

#item intercepts, intercepts equality constraints
acsi01.1 ~ 0*1; ccsi01.1 ~ 0*1; hcsi01.1 ~ 0*1; icsi01.1 ~ 0*1
acsi05.1 ~ m2*1; ccsi05.1 ~ m2*1; hcsi05.1 ~ m2*1; icsi05.1 ~ m2*1
acsi07.1 ~ m3*1; ccsi07.1 ~ m3*1; hcsi07.1 ~ m3*1; icsi07.1 ~ m3*1
acsi10.1 ~ m4*1; ccsi10.1 ~ m4*1; hcsi10.1 ~ m4*1; icsi10.1 ~ m4*1

#item residual variances, no constraints
acsi01.1 ~~ acsi01.1; ccsi01.1 ~~ ccsi01.1; hcsi01.1 ~~ hcsi01.1; icsi01.1 ~~ icsi01.1
acsi05.1 ~~ acsi05.1; ccsi05.1 ~~ ccsi05.1; hcsi05.1 ~~ hcsi05.1; icsi05.1 ~~ icsi05.1
acsi07.1 ~~ acsi07.1; ccsi07.1 ~~ ccsi07.1; hcsi07.1 ~~ hcsi07.1; icsi07.1 ~~ icsi07.1
acsi10.1 ~~ acsi10.1; ccsi10.1 ~~ ccsi10.1; hcsi10.1 ~~ hcsi10.1; icsi10.1 ~~ icsi10.1

#item residual covariances, no constraints
acsi01.1 ~~ ccsi01.1; ccsi01.1 ~~ hcsi01.1; hcsi01.1 ~~ icsi01.1
acsi05.1 ~~ ccsi05.1; ccsi05.1 ~~ hcsi05.1; hcsi05.1 ~~ icsi05.1
acsi07.1 ~~ ccsi07.1; ccsi07.1 ~~ hcsi07.1; hcsi07.1 ~~ icsi07.1
acsi10.1 ~~ ccsi10.1; ccsi10.1 ~~ hcsi10.1; hcsi10.1 ~~ icsi10.1

#first-order factor means
ACSIf ~ 0*1
CCSIf ~ 0*1
HCSIf ~ 0*1
ICSIf ~ 0*1

#first order factor variances
ACSIf ~~ vl*ACSIf
CCSIf ~~ vl*CCSIf
HCSIf ~~ vl*HCSIf
ICSIf ~~ vl*ICSIf

#second order growth factors
i =~ 1*ACSIf + 1*CCSIf + 1*HCSIf + 1*ICSIf
s =~ 0*ACSIf + 15*CCSIf + 27*HCSIf + 53*ICSIf

#second order factor means and variances (no constraints)
i ~ 1
i ~~ i
s ~ 1
s ~~ s

#first and second order factors covariation (all fixed to 0)
ACSIf ~~ 0*CCSIf; ACSIf ~~0*HCSIf; ACSIf ~~0*ICSIf
CCSIf ~~ 0*HCSIf; CCSIf ~~0*ICSIf
HCSIf ~~ 0*ICSIf
i ~~ 0*ACSIf + 0*CCSIf + 0*HCSIf + 0*ICSIf
s ~~ 0*ACSIf + 0*CCSIf + 0*HCSIf + 0*ICSIf"

modell_PZ_f_fit <- sem(modell_PZ_f, data=mydata, meanstructure=TRUE, missing="fiml", estimator="mlr")
summary(modell_PZ_f_fit, fit.measures=TRUE, standardized=TRUE)

thank you very much in advance!
best
Michelle

Terrence Jorgensen

Mar 6, 2019, 2:16:15 PM3/6/19
to lavaan
I`d like to add a time-invariant covariate. How can I do this?

Use the regression operator: ~

`i + s ~ commscores`

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