Random Intercept model

726 views
Skip to first unread message

Kamal Kishore

unread,
Nov 27, 2012, 2:03:19 AM11/27/12
to lav...@googlegroups.com
Hi lavaan users,
                          I have a question which I hope someone will answer. Below mentioned model is equivalent to Random Intercept and Slope model of lmer package. My question is how to specify Random Intercept model in lavvan and what command has to be used for calculating var-cov and Corr matrix so that I can compare these for both models? I am comparing performaces of both the models for various criterias.
  
Model<- ' 
          # INTERCEPT AND SLOPE EQUATIONS
          i=~1*Neuro1+1*Neuro2+1*Neuro3+1*Neuro4+1*Neuro5+1*Neuro6
          s1=~0*Neuro1+1*Neuro2+2*Neuro3+3*Neuro4+4*Neuro5+5*Neuro6
          s2=~0*Neuro1+1*Neuro2+4*Neuro3+9*Neuro4+16*Neuro5+25*Neuro6

       # REGRESSSION EQUATION OF FACTORS ON INTERCEPT AND SLOPE
      i~ Sex+Edu
      s1~ Sex+Edu
      s2~ Sex+Edu 
           '   
  fit.1<- growth ( Model.1, data=CD4, missing="ml")
 
  summary(fit.1, fit.measures = TRUE, rsq = TRUE ) 
 
 Thanks in advance!
          
 

yrosseel

unread,
Nov 28, 2012, 3:03:04 AM11/28/12
to lav...@googlegroups.com
On 11/27/2012 08:03 AM, Kamal Kishore wrote:
> Hi lavaan users,
> I have a question which I hope someone will
> answer. Below mentioned model is equivalent to Random Intercept and
> Slope model of lmer package.

No, it isn't. lmer will assume compount symmetry, and this means that
the all residual variances of the observed variables are constrained to
be equal. You, you need to add this in your syntax:

Neuro1 ~~ v1*Neuro1
Neuro2 ~~ v1*Neuro2
Neuro3 ~~ v1*Neuro3
Neuro4 ~~ v1*Neuro4
Neuro5 ~~ v1*Neuro5
Neuro6 ~~ v1*Neuro6

(same label, same value).

My question is how to specify Random
> Intercept model in lavvan

You already did. The 'i' factor in your syntax is a random intercept.


and what command has to be used for
> calculating var-cov and Corr matrix

VarCov of the observed variables?

fitted(fit.l)

or did you mean the random components? These are automatically part of
the output.


Hope this helps,

Yves.

Kamal Kishore

unread,
Nov 28, 2012, 11:58:26 AM11/28/12
to lav...@googlegroups.com
 First of all thank you for clarification and speedy response. I am interested in var-cov of Observed variables . Now coming to question.
 
 Random Intercept model in Lmer is:
    
    Lmer10<- lmer(Neuro~1+Time+I(Time^2)+Sex+Edu+(1|Sub), data=CD4.C, REML=FALSE)     ---------------------(1`)

Random Intercept and slope Model in Lmer is:
 
    Lmer10<- lmer(Neuro~1+Time+I(Time^2)+Sex+Edu+(1+Time|Sub), data=CD4.C,REML=FALSE)      -------------(2)


  As per your response I specified the Random Intercept model by fixing Intercept. How to specify the lavaan equivalent of equation (2).          

Robert Miller

unread,
Nov 28, 2012, 3:01:07 PM11/28/12
to lav...@googlegroups.com
Dear Kamal,

again, you already did it ;)
specifically - none of the latent variables you specified (i, s1, s2) were fixed, but comprised variability. in order to specify the lmer-models you invoked, you need to add more constraints.

contraints to create your lmer random intercept model:
s1 ~~ 0*s1
s2 ~~ 0*s2

contraints to create your lmer random intercept-slope model:
s2 ~~ 0*s2

hope this helps.
best, robert
Message has been deleted

Kamal Kishore

unread,
Nov 28, 2012, 11:03:28 PM11/28/12
to lav...@googlegroups.com
 Thank you Rosseel and Miller for all the clarifications.
 

On Tuesday, 27 November 2012 12:33:19 UTC+5:30, Kamal Kishore wrote:

Kamal Kishore

unread,
Nov 29, 2012, 5:36:22 AM11/29/12
to lav...@googlegroups.com
Rosseel and Miller,  sorry to  trouble you again as I have one doubt here. In mixed models(Random intercept ) and GEE(Excangeable)   VarCov structure produce homogeneous Var. and Cov. On running lavaan I am not getting This type of VarCov. If reqired I can provide some more details about my problem.
 
 Model.1b<- ' 

           # INTERCEPT AND SLOPE EQUATIONS
           i=~1*Neuro1+1*Neuro2+1*Neuro3+1*Neuro4+1*Neuro5+1*Neuro6
           s1=~0*Neuro1+1*Neuro2+2*Neuro3+3*Neuro4+4*Neuro5+5*Neuro6 
           s2=~0*Neuro1+1*Neuro2+4*Neuro3+9*Neuro4+16*Neuro5+25*Neuro6
  
  
        # REGRESSSION EQUATION OF FACTORS ON INTERCEPT AND SLOPE
       i~ Sex+Edu+Income+Locality+Family+Mstatus+CD4C+BDI+MMSE
      s1~ Sex+Edu+Income+Locality+Family+Mstatus+CD4C+BDI+MMSE
      s2~ Sex+Edu+Income+Locality+Family+Mstatus+CD4C+BDI+MMSE

       s1~~0*s1
       s2~~0*s2        
                ' 
Var-Cov  matrix is:
 
 Neuro1   40.423                                                              
 Neuro2   30.873 37.332                                                       
 Neuro3   29.005 29.092 34.776                                                
 Neuro4   26.255 26.689 26.188 39.359                                         
 Neuro5   22.623 23.276 23.197 22.384 37.216                                  
 Neuro6   18.108 18.855 19.179 19.081 18.559 26.903 
 
   Is it because of Univariate nature of Mixed and GEE models whereas Growth models using SEM is multivariate by nature or some other reasons.
 

On Tuesday, 27 November 2012 12:33:19 UTC+5:30, Kamal Kishore wrote:

yrosseel

unread,
Nov 29, 2012, 6:15:09 AM11/29/12
to lav...@googlegroups.com
On 11/29/2012 11:36 AM, Kamal Kishore wrote:
> Rosseel and Miller, sorry to trouble you again as I have one doubt
> here. In mixed models(Random intercept ) and GEE(Excangeable) VarCov
> structure produce homogeneous Var. and Cov. On running lavaan I am not
> getting This type of VarCov. If reqired I can provide some more details
> about my problem.
> Model.1b<- '
> # INTERCEPT AND SLOPE EQUATIONS
> i=~1*Neuro1+1*Neuro2+1*Neuro3+1*Neuro4+1*Neuro5+1*Neuro6
> s1=~0*Neuro1+1*Neuro2+2*Neuro3+3*Neuro4+4*Neuro5+5*Neuro6
> s2=~0*Neuro1+1*Neuro2+4*Neuro3+9*Neuro4+16*Neuro5+25*Neuro6
>
>
> # REGRESSSION EQUATION OF FACTORS ON INTERCEPT AND SLOPE
> i~ Sex+Edu+Income+Locality+Family+Mstatus+CD4C+BDI+MMSE
> s1~ Sex+Edu+Income+Locality+Family+Mstatus+CD4C+BDI+MMSE
> s2~ Sex+Edu+Income+Locality+Family+Mstatus+CD4C+BDI+MMSE
>
> s1~~0*s1
> s2~~0*s2

You forgot to fix the residual variance to be equal. You need to add
this to your syntax:

Neuro1 ~~ v1*Neuro1
Neuro2 ~~ v1*Neuro2
Neuro3 ~~ v1*Neuro3
Neuro4 ~~ v1*Neuro4
Neuro5 ~~ v1*Neuro5
Neuro6 ~~ v1*Neuro6

and also

i ~~ 0*s1
i ~~ 0*s2
s1 ~~ 0*s2

Yves.

Kamal Kishore

unread,
Nov 29, 2012, 11:05:05 PM11/29/12
to lav...@googlegroups.com
 Thankyou for all the help.


 


--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at http://groups.google.com/group/lavaan?hl=en.





--
Thanks & Regards,

Kamal Kishore
Research  Scholar
Department of Biostatistics
National Institute of Mental Health and Neuro Sciences (NIMHANS) 
Banglore-560029
Mob-+91-9591349768
Email:kamalkis...@gmail.com

Kamal Kishore

unread,
Nov 30, 2012, 1:15:57 AM11/30/12
to lav...@googlegroups.com
  Dear lavaan users,
                              Even after incorporating the suggestions made by you, I am unable to get VarCov matrix with homogeneous Var and Cov.  Am I doing something wrong?
 
 Model.1b<- ' 

           # INTERCEPT AND SLOPE EQUATIONS
            i=~1*Neuro1+1*Neuro2+1*Neuro3+1*Neuro4+1*Neuro5+1*Neuro6
           s1=~0*Neuro1+1*Neuro2+2*Neuro3+3*Neuro4+4*Neuro5+5*Neuro6 
           s2=~0*Neuro1+1*Neuro2+4*Neuro3+9*Neuro4+16*Neuro5+25*Neuro6
  
 
        # REGRESSSION EQUATION OF FACTORS ON INTERCEPT AND SLOPE
        i~ Sex+Edu+Income+Locality+Family+Mstatus+CD4C+BDI+MMSE
       s1~ Sex+Edu+Income+Locality+Family+Mstatus+CD4C+BDI+MMSE
       s2~ Sex+Edu+Income+Locality+Family+Mstatus+CD4C+BDI+MMSE
        Neuro1 ~~ 1*Neuro1 
        Neuro2 ~~ 1*Neuro2 
        Neuro3 ~~ 1*Neuro3 
        Neuro4 ~~ 1*Neuro4 
        Neuro5 ~~ 1*Neuro5 
        Neuro6 ~~ 1*Neuro6 
 
         i~~0*s1 
         i~~0*s2 
       s1~~0*s1
       s1~~0*s2 
       s2~~0*s2        
               ' 
  
   fit.1b<- growth(Model.1b, data=ExcelW, missing="ml")
  Warning message:
 In lavaan(model = Model.1b, data = ExcelW, missing = "ml", model.type = "growth",  :
  lavaan WARNING: covariance matrix of latent variables is not positive definite;. use inspect(fit,"cov.lv") to investigate.
   fitted(fit.1b) 

             Neuro1 Neuro2 Neuro3 Neuro4 Neuro5 Neuro6 Neuro1  
             29.371                                                              
Neuro2   28.135 29.648                                                       
Neuro3   27.541 28.488 29.608                                                
Neuro4   26.590 27.655 27.900 28.327                                         
Neuro5   25.281 26.148 26.365 25.934 25.853                                  
Neuro6   23.614 23.967 24.003 23.722 23.123 23.206 
 
 
On Tuesday, 27 November 2012 12:33:19 UTC+5:30, Kamal Kishore wrote:

yrosseel

unread,
Nov 30, 2012, 7:52:52 AM11/30/12
to lav...@googlegroups.com
On 11/30/2012 07:15 AM, Kamal Kishore wrote:
> Dear lavaan users,
> Even after incorporating the suggestions
> made by you, I am unable to get VarCov matrix with homogeneous Var and
> Cov. Am I doing something wrong?

Yes:

> Neuro1 ~~ 1*Neuro1
> Neuro2 ~~ 1*Neuro2
> Neuro3 ~~ 1*Neuro3
> Neuro4 ~~ 1*Neuro4
> Neuro5 ~~ 1*Neuro5
> Neuro6 ~~ 1*Neuro6

should be:

Neuro1 ~~ v1*Neuro1
Neuro2 ~~ v1*Neuro2
Neuro3 ~~ v1*Neuro3
Neuro4 ~~ v1*Neuro4
Neuro5 ~~ v1*Neuro5
Neuro6 ~~ v1*Neuro6

where the 'v1' is a label. It could be any string starting with a character.

Yves.

Kamal Kishore

unread,
Nov 30, 2012, 9:15:57 AM11/30/12
to lav...@googlegroups.com
 As per your suggestions I ran the script but  could not get the result, then I applied previous code. I am providing the script and result here: 


 Model.1<- ' 
          # INTERCEPT AND SLOPE EQUATIONS
            i=~ 1*Neuro1+ 1*Neuro2+ 1*Neuro3+ 1*Neuro4+  1*Neuro5+  1*Neuro6
          s1=~ 0*Neuro1+ 1*Neuro2+ 2*Neuro3+ 3*Neuro4+  4*Neuro5+  5*Neuro6
          s2=~ 0*Neuro1+ 1*Neuro2+ 4*Neuro3+ 9*Neuro4+ 16*Neuro5+  25*Neuro6

       # REGRESSSION EQUATION OF FACTORS ON INTERCEPT AND SLOPE
      i~ Sex+ Edu+  Income+  Locality+  Family+ Mstatus+ CD4C+ BDI+ MMSE
      s1~ Sex+ Edu+ Income+ Locality+ Family+ Mstatus+ CD4C+ BDI+ MMSE
      s2~ Sex + Edu+ Income+ Locality+ Family+ Mstatus+ CD4C+ BDI+ MMSE
       
        Neuro1 ~~ v1*Neuro1 
        Neuro2 ~~ v1*Neuro2 
        Neuro3 ~~ v1*Neuro3 
        Neuro4 ~~ v1*Neuro4 
        Neuro5 ~~ v1*Neuro5 
        Neuro6 ~~ v1*Neuro6 
 
        i~~0*s1 
        i~~0*s2 
       s1~~0*s1
       s1~~0*s2 
       s2~~0*s2                ' 
 
  fit.1<- growth(Model.1, data=ExcelW, missing="ml")


             37.912                                                               
Neuro2   25.750 37.912                                                        
Neuro3   25.086 25.888 37.730                                                 
Neuro4   24.127 25.055 25.233 36.456                                          
Neuro5   22.873 23.620 23.777 23.343 34.112                                   
Neuro6   21.325 21.584 21.568 21.274 20.705 31.652      


 I am currently using R version 2.15.0 with lavaan 0.5-11.                      


On Tuesday, 27 November 2012 12:33:19 UTC+5:30, Kamal Kishore wrote:

yrosseel

unread,
Dec 3, 2012, 10:18:11 AM12/3/12
to lav...@googlegroups.com
The regressions destroy the (model-implied) compound symmetry. Remove
the three regressions, and you will get compound symmetry.

Yves.



Kamal Kishore

unread,
Dec 3, 2012, 12:29:16 PM12/3/12
to lav...@googlegroups.com
I am really thankful to your time on this topic. If I am not mistaken you are talking about Unconditional Random Intercept Model, but my major interest is in conditional Random Intercept Model. 

My main question is: Can I able to publish my findings for Conditional Random Intercept on the basis of code you suggested previously? If yes, then what logic I can give to reviewer for VarCov matrix of Random Intercept model. This is my last question on this topic. Once again heartily thanks to bear with me.      

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at http://groups.google.com/group/lavaan?hl=en.


yrosseel

unread,
Dec 13, 2012, 2:50:02 PM12/13/12
to lav...@googlegroups.com
On 12/03/2012 06:29 PM, Kamal Kishore wrote:
> I am really thankful to your time on this topic. If I am not mistaken
> you are talking about Unconditional Random Intercept Model, but my major
> interest is in conditional Random Intercept Model.
>
> My main question is: Can I able to publish my findings for Conditional
> Random Intercept on the basis of code you suggested previously?

Sure. If you understand what you are doing.

> then what logic I can give to reviewer for VarCov matrix of Random
> Intercept model. This is my last question on this topic. Once
> again heartily thanks to bear with me.

Well, in the conditional random intercept model, the variance/covariance
elements take the variances/covariances of the exogenous predictors into
account.

Yves.

Kamal Kishore

unread,
Dec 13, 2012, 11:34:04 PM12/13/12
to lav...@googlegroups.com
Thankyou one and all for your help.



Yves.

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at http://groups.google.com/group/lavaan?hl=en.


Reply all
Reply to author
Forward
0 new messages