Negative variances in Autoregressive Latent Trajectory Model w

20 views
Skip to first unread message

Kinga Bierwiaczonek

unread,
Apr 9, 2020, 6:00:52 PM4/9/20
to lavaan
Dear all, 

I am trying to fit an autoregressive latent trajectory model with structured residuals on a 3-wave dataset. I used the lavaan code for two waves from Mund, & Nestler (2017) and I adapted it to three waves. I am getting close fit and large negative variances for both intercepts and slopes. The issue does not seem to be with the data; I assume it's some mistake I made when adapting the code, but I cannot find it. 

Thanks in advance for any help. 
Best, 
Kinga 

altsr <- '
# Define intercept and growth factors
ix =~ 1*x1+1*x2+1*x3
iy1 =~ 1*y1.1+1*y1.2+1*y1.3
iy2 =~ 1*y2.1+1*y2.2+1*y2.3

sx =~ 0*x1+1*x2+2*x3
sy1 =~ 0*y1.1+1*y1.2+2*y1.3
sy2 =~ 0*y2.1+1*y2.2+2*y2.3

# Define phantom latent variables
etax1 =~ 1*x1
etax2 =~ 1*x2
etax3 =~ 1*x3

etay1.1 =~ 1*y1.1
etay1.2 =~ 1*y1.2
etay1.3 =~ 1*y1.3

etay2.1 =~ 1*y2.1
etay2.2 =~ 1*y2.2
etay2.3 =~ 1*y2.3

# Autoregressive effects
etax2 ~ a1*etax1
etax3 ~ a1*etax2

etay1.2 ~ a2*etay1.1
etay1.3 ~ a2*etay1.2

etay2.2 ~ a3*etay2.1
etay2.3 ~ a3*etay2.2

# Crosslagged effects
etay1.2 ~ c1*etax1
etay1.3 ~ c1*etax2

etax2 ~ c2*etay1.1
etax3 ~ c2*etay1.2

etay2.2 ~ c3*etax1
etay2.3 ~ c3*etax2

etax2 ~ c4*etay2.1
etax3 ~ c4*etay2.2

etay2.2 ~ c5*etay1.1
etay2.3 ~ c5*etay1.2

etay1.2 ~ c6*etay2.1
etay1.3 ~ c6*etay2.2

#  Set error variances of the observed variables to zero
x1 ~~ 0*x1
x2 ~~ 0*x2
x3 ~~ 0*x3

y1.1 ~~ 0*y1.1
y1.2 ~~ 0*y1.2
y1.3 ~~ 0*y1.3

y2.1 ~~ 0*y2.1
y2.2 ~~ 0*y2.2
y2.3 ~~ 0*y2.3

# Estimate the variance of the latent variables
etax1 ~~ varx1*etax1
etax2 ~~ varx2*etax2
etax3 ~~ varx3*etax3

etay1.1 ~~ vary1.1*etay1.1
etay1.2 ~~ vary1.2*etay1.2
etay1.3 ~~ vary1.3*etay1.3

etay2.1 ~~ vary2.1*etay2.1
etay2.2 ~~ vary2.2*etay2.2
etay2.3 ~~ vary2.3*etay2.3

# Estimate intercept factor variances, the slope variances and covariances
ix ~~ varix*ix
iy1 ~~ variy1*iy1
iy2 ~~ variy2*iy2
sx ~~ varsx*sx
sy1 ~~ varsy1*sy1
sy2 ~~ varsy2*sy2


ix ~~ covi1*iy1
ix ~~ covi2*iy2
ix ~~ covixsx*sx
ix ~~ covixsy1*sy1
ix ~~ covixsy2*sy2
sx ~~ covsxsy1*sy1
sx ~~ covsxsy2*sy2

iy1 ~~ coviy1iy2*iy2
iy1 ~~ coviy1sx*sx
iy1 ~~ coviy1sy1*sy1
iy1 ~~ coviy1sy2*sy2
sy1 ~~ covsy1sy2*sy2

iy2 ~~ coviy2sx*sx
iy2 ~~ coviy2sy1*sy1
iy2 ~~ coviy2sy2*sy2


# Covariance between the intercepts and
#    the slopes and the latents of the first time point set to zero
etax1 ~~ 0*ix
etay1.1 ~~ 0*ix
etay2.1 ~~ 0*ix

etax1 ~~ 0*sx
etay1.1 ~~ 0*sx
etay2.1 ~~ 0*sx

etax1 ~~ 0*iy1
etay1.1 ~~ 0*iy1
etay2.1 ~~ 0*iy1

etax1 ~~ 0*sy1
etay1.1 ~~ 0*sy1
etay2.1 ~~ 0*sy1

etax1 ~~ 0*iy2
etay1.1 ~~ 0*iy2
etay2.1 ~~ 0*iy2

etax1 ~~ 0*sy2
etay1.1 ~~ 0*sy2
etay2.1 ~~ 0*sy2

# Covariance between the latents of x and y

etax1 ~~ cov1*etay1.1
etax2 ~~ e1*etay1.2
etax3 ~~ e1*etay1.3

etax1 ~~ cov2*etay2.1
etax2 ~~ e2*etay2.2
etax3 ~~ e2*etay2.3

etay1.1 ~~ cov3*etay2.1
etay1.2 ~~ e3*etay2.2
etay1.3 ~~ e3*etay2.3

# Mean structure

x1 ~ 0*1
x2 ~ 0*1
x3 ~ 0*1

y1.1 ~ 0*1
y1.2 ~ 0*1
y1.3 ~ 0*1

y2.1 ~ 0*1
y2.2 ~ 0*1
y2.3 ~ 0*1

etax1 ~ 0*1
etax2 ~ 0*1
etax3 ~ 0*1

etay1.1 ~ 0*1
etay1.2 ~ 0*1
etay1.3 ~ 0*1

etay2.1 ~ 0*1
etay2.2 ~ 0*1
etay2.3 ~ 0*1

ix ~ 1
iy1 ~ 1
iy2 ~ 1

sx ~ 1
sy1 ~ 1
sy2 ~ 1
'


Output: 

Variances:
                   Estimate  Std.Err  z-value   P(>|z|)
   .x1                0.000                            
   .x2                0.000                            
   .x3                0.000                            
   .y1.1              0.000                            
   .y1.2              0.000                            
   .y1.3              0.000                            
   .y2.1              0.000                            
   .y2.2              0.000                            
   .y2.3              0.000                            
    etax1   (vrx1)  210.773    0.090  2348.260    0.000
   .etax2   (vrx2)    3.334    0.185    18.051    0.000
   .etax3   (vrx3)    3.242    0.204    15.919    0.000
    etay1.1 (v1.1)   60.928    0.159   382.545    0.000
   .etay1.2 (v1.2)    0.882    0.373     2.362    0.018
   .etay1.3 (v1.3)    0.664    0.442     1.501    0.133
    etay2.1 (v2.1)  217.734    0.071  3063.569    0.000
   .etay2.2 (v2.2)    1.375    0.077    17.790    0.000
   .etay2.3 (v2.3)    1.423    0.086    16.462    0.000
    ix      (varx) -206.781    0.105 -1970.834    0.000
    iy1     (vry1)  -54.890    0.332  -165.183    0.000
    iy2     (vry2) -214.591    0.096 -2235.964    0.000
    sx      (vrsx)   -1.915    0.163   -11.781    0.000
    sy1     (vrs1)    0.040    0.184     0.219    0.827
    sy2     (vrs2)   -0.756    0.084    -9.003    0.000


Reply all
Reply to author
Forward
0 new messages