How to fix a latent variance to 0

2,940 views
Skip to first unread message

mike

unread,
Sep 22, 2012, 1:47:33 PM9/22/12
to lav...@googlegroups.com
In a latent difference score model (McArdle and Hamagami, 2001) the latent true score and latent difference score variances are set to 0. But the following snip from a model doesn't achieve this and sets them to 1 instead:
    ly1 ~~ 0*ly1
I can set them to something close to 0 this way, but not exactly to 0. But I can set them exactly to 0 if I label them and use a model constraint:
    ly1 ~~ omega*ly1
    omega == 0
I couldn't see a relevant "auto*" argument. Am I missing something?
By the way can we have a "..." argument in "growth" to pass options through to lavaan?
Many thanks.

yrosseel

unread,
Sep 24, 2012, 9:34:06 AM9/24/12
to lav...@googlegroups.com
On 09/22/2012 07:47 PM, mike wrote:
> In a latent difference score model (McArdle and Hamagami, 2001) the
> latent true score and latent difference score variances are set to 0.
> But the following snip from a model doesn't achieve this and sets them
> to 1 instead:
> ly1 ~~ 0*ly1

Hm. This is either a bug, or another piece of syntax is overriding this.
This syntax should fix the variance of 'ly1' to zero. Could you provide
me with the complete syntax and perhaps a snippet of the data so that we
can reproduce this?

> By the way can we have a "..." argument in "growth" to pass options
> through to lavaan?

That would not be trivial, since growth() currently adds (and sets)
several auto.* arguments. If one of these is also passed through the
'...' argument, we may end up with duplicated arguments.

The growth() function is really only for simple growth models. I do
think it should be possible to have a custom function for latent
difference models (and only those). For everything else, we need the
lavaan() function.

Yves.


mike

unread,
Sep 24, 2012, 10:58:31 AM9/24/12
to lav...@googlegroups.com
Dear Yves,
thanks for your help and your work on this great package.
Below is the model syntax. Its a univariate dual change score LDS model. For a path diagram of this see figure 7a in:
McArdle (2009). Annual Review of Psychology, 60:577–605
For data I just used the Mplus example "ex6.1.dat", naming the variables: y1, y2, y3, y4. I run it like this:
summary(growth(model, data))
For the variances of ly1-ly4 and dy1-dy3 I get 1 instead of 0.

model =  "# Latent true scores
          ly1 =~ 1*y1           
          ly2 =~ 1*y2
          ly3 =~ 1*y3
          ly4 =~ 1*y4
          # Autoregressions
          ly2 ~ 1*ly1
          ly3 ~ 1*ly2
          ly4 ~ 1*ly3
          # Latent difference scores
          dy1 =~ 1*ly2
          dy2 =~ 1*ly3
          dy3 =~ 1*ly4
          # Proportional Change
          dy1 ~ beta*ly1
          dy2 ~ beta*ly2
          dy3 ~ beta*ly3
          # Slope (sy) and level (y0)
          sy =~ 1*dy1
          sy =~ 1*dy2
          sy =~ 1*dy3
          y0 =~ 1*ly1
          # Free means and variances
          y0 ~ 1
          sy ~ 1
          y0 ~~ y0
          sy ~~ sy
          # Observed means
          y1 ~ 0*1
          y2 ~ 0*1
          y3 ~ 0*1
          y4 ~ 0*1
          # Fix latent means at 0
          ly1 ~ 0*1
          ly2 ~ 0*1
          ly3 ~ 0*1
          ly4 ~ 0*1
          dy1 ~ 0*1
          dy2 ~ 0*1
          dy3 ~ 0*1
          # Fix latent variance at 0  
          ly1 ~~ 0*ly1       ############ HERE IS MY PROBLEM
          ly2 ~~ 0*ly2       # For some reason this sets the variances to 1
          ly3 ~~ 0*ly3       # I could make it work with something like: ly3 ~~ 0.0001*ly3
          ly4 ~~ 0*ly4       # Or better: ly4 ~~ omega*ly4
          dy1 ~~ 0*dy1       # and then:  omega == 0                                                 
          dy2 ~~ 0*dy2 
          dy3 ~~ 0*dy3                                      
          # Equality constraints on residuals
          y1 ~~ e*y1
          y2 ~~ e*y2
          y3 ~~ e*y3
          y4 ~~ e*y4"
         
best wishes, Mike


yrosseel

unread,
Sep 24, 2012, 1:17:19 PM9/24/12
to lav...@googlegroups.com
On 09/24/2012 04:58 PM, mike wrote:
> Dear Yves,
> thanks for your help and your work on this great package.
> Below is the model syntax. Its a univariate dual change score LDS model.

Thanks. The variances are indeed set to 1 (instead of zero). This is due
to some safe-guarding code that checks for zero variances (just before
the iterations start) and if found, sets them to unity.

But you should be able to override this. When I have the time (not the
first two days), I'll have a closer look at this.

Yves.

mike

unread,
Sep 24, 2012, 2:26:00 PM9/24/12
to lav...@googlegroups.com
thanks Yves.

If you were thinking a writing a function for LDS models, have you seen ZZ's program for generating Mplus scripts for these models:
http://www.psychstat.org/us/article.php/38.htm
It's tempting to take a similar approach and write functions to generate lavaan models.
A time saver for some elaborate but standard things like bivariate LDS models for instance.

best, Mike

Alex Schoemann

unread,
Sep 25, 2012, 12:28:32 PM9/25/12
to lav...@googlegroups.com
Hi Mike,

The idea of programming simple functions to help create complex models is one of the reasons I love R. If, you or someone else was interested in creating a function to generate lavaan syntax/parameter tables for complex but common models (like the LDS model), I believe we have a home for it. In collaboration with some colleagues, we've written an R package for miscellaneous but helpful functions related to SEM. The package name is semTools, and the goal of the package is for it to include contributions from anyone who is interested in writing functions. We would certainly love to have functions that make specifying LDS models in there!

Thanks,

-Alex

Yves Rosseel

unread,
Oct 11, 2012, 3:03:35 AM10/11/12
to lav...@googlegroups.com
A new package (RAMpath) appeared on CRAN the other day:

http://cran.r-project.org/web/packages/RAMpath/

and it seems to include a function (ramLCS) for fitting an (univariate) latent change score model.

Yves.

mike

unread,
Apr 24, 2013, 8:46:41 AM4/24/13
to lav...@googlegroups.com

RAMpath feels like a work in progress. For example a simple gotcha happens if you pass observed data with column names y1, y2, y3., ... to the ramLCS function. Avoid "y" because it uses it in the function to build the model string, so it gets mixed up with your column names. Yves, any joy with overriding the safe-guarding code so I can fix a latent variance to 0? Cheers.

yrosseel

unread,
Apr 24, 2013, 11:55:00 AM4/24/13
to lav...@googlegroups.com
This was fixed a couple of months (I think 0.5-11, released in december
2012). Can you install the latest version of R and lavaan and see if you
still get this?

Yves.

mike allerhand

unread,
Apr 26, 2013, 7:32:51 AM4/26/13
to lav...@googlegroups.com

the safeguarding code that prevented fixing a latent variance to 0 is now fixed (version 0.5-12) and the LDS model (above) works fine. The safeguard is now a warning message that the covariance matrix of latent variables is not positive definite. All is well, thanks Yves.  

Michael Paul Grosz

unread,
Dec 1, 2014, 8:19:26 AM12/1/14
to lav...@googlegroups.com
Hi everybody,

As I received the warning message "some estimated variances are negative", I tried to fix the (residual) variance of item narq14.y to zero. Item narq14.y had the negative variance.
However, the variance remains negative for item 14. How can I fix the variance to zero?
Any other idea what I could do to get rid of the negative variance?

Here is the code (all items are specified as categorical variables):

RIV.RIV.STAI.model<- '
riv_d.x =~ narq13.x + narq14.x + narq17.x
riv_s.x =~ narq6.x+ narq9.x + narq10.x
riv_a.x =~ narq4.x + narq11.x + narq12.x
RIV.men =~ riv_s.x+riv_d.x+riv_a.x
riv_d.y =~ narq13.y + narq14.y + narq17.y
riv_s.y =~ narq6.y + narq9.y + narq10.y
riv_a.y =~ narq4.y + narq11.y + narq12.y
RIV.women =~ riv_s.y+riv_d.y+riv_a.y
STAI.women =~ STAI4.y+ STAI2.y+ STAI3.y+ STAI1r.y+ STAI5.y+ STAI6r.y+ STAI7r.y+ STAI8.y+ STAI9.y+ STAI10r.y+ STAI11.y+ STAI12.y+ STAI13r.y+ STAI14.y+ STAI15.y+ STAI16r.y+ STAI17.y+ STAI18.y+ STAI19r.y+ STAI20.y
RIV.men ~ RIV.women + STAI.women
narq14.y ~~ 0*narq14.y'
RIV.RIV.STAI.fit <- cfa(RIV.RIV.STAI.model,Couples,meanstructure=T,zero.cell.warn=F,std.lv=TRUE)

yrosseel

unread,
Dec 1, 2014, 8:44:07 AM12/1/14
to lav...@googlegroups.com
On 12/01/2014 02:19 PM, Michael Paul Grosz wrote:
> Hi everybody,
>
> As I received the warning message "some estimated variances are
> negative", I tried to fix the (residual) variance of item narq14.y to
> zero. Item narq14.y had the negative variance.
> However, the variance remains negative for item 14. How can I fix the
> variance to zero?

The residual variance of 'y*' is not a free parameter under the default
parameterization ("delta"), so you can not 'fix' it. You can try
parameterization="theta".

Yves.

Reply all
Reply to author
Forward
0 new messages