simulating a latent growth model (with a mean structure)

60 views
Skip to first unread message

Catarina Marques

unread,
Jun 8, 2018, 1:18:55 PM6/8/18
to lavaan
Hello all,

I am trying to simulate data from a latent growth model with linear growth and three time points but I have been lost in how to define the mean structure.

I have defined the intercept mean equal to zero and the slope mean equal to 20. The problem is that the generated data have mean approximately equal to zero at all time points when the function simulateData() is used.
Alternatively when I use the sim() function (with a unique replicate), the estimated mean slope is around 0 and not 20 has it should.

How can I define the arguments of simulateData() and sim() in order to accomodate the mean structure of the model?
Could you help me please?
Thanks in advance.

Best,
Catarina

kma...@aol.com

unread,
Jun 8, 2018, 11:37:10 PM6/8/18
to lav...@googlegroups.com
For some reason I could not get this to post through the Web interface, so I am trying email.

Catarina,
We would probably need to see your script to identify the problem. I was not able to reproduce the result that you described.


simulationModel <- '
intercept =~ 1*x1 + 1*x2 + 1*x3
slope =~ 1*x2 + 2*x3
x1 ~~ 1*x1
x2 ~~ 1*x2
x3 ~~ 1*x3
intercept ~ 0*1
slope ~ 20*1
' # end simulationModel

simulationData <- simulateData(simulationModel, meanstructure=TRUE)

summary(simulationData)

> summary(simulationData)
x1 x2 x3
Min. :-5.6153 Min. :14.29 Min. :32.29
1st Qu.:-1.0870 1st Qu.:18.70 1st Qu.:38.47
Median :-0.1138 Median :19.83 Median :40.03
Mean :-0.1023 Mean :19.89 Mean :39.96
3rd Qu.: 0.8939 3rd Qu.:21.03 3rd Qu.:41.51
Max. : 3.7172 Max. :25.12 Max. :45.79
>

As you can see, my means are 0, 20 and 40.

Keith
------------------------
Keith A. Markus
John Jay College of Criminal Justice, CUNY
http://jjcweb.jjay.cuny.edu/kmarkus
Frontiers of Test Validity Theory: Measurement, Causation and Meaning.
http://www.routledge.com/books/details/9781841692203/



Message has been deleted

Catarina Marques

unread,
Jun 9, 2018, 1:52:07 PM6/9/18
to lav...@googlegroups.com
I've already realized what I did wrong. 1 is missing to define the intercept and slope means. I should have defined it as i~0*1 and s~20*1, respectively, and I didn't it.
Thanks a lot!

best,
Catarina

On 9 June 2018 at 18:14, Catarina Marques <cmvam...@gmail.com> wrote:
Hi keith,
Thanks for your quick reply!

My script is:
1) using SimulateData()


popModel <- '

   i =~ 1*t1 + 1*t2 + 1*t3

   s =~ 0*t1 + 1*t2 + 2*t3

   i ~ 0

   s ~ 20

   i ~~ 1*i

   s ~~ 0.2*s

   i ~~ 0*s

   t1 ~~ 1*t1

   t2 ~~ 1.2*t2

   t3 ~~ 1.8*t3

'

set.seed(53487)

Data <- simulateData(popModel, sample.nobs=500, meanstructure=TRUE)

summary(Data)

      t1                  t2                 t3         

 Min.   :-3.958139   Min.   :-5.60567   Min.   :-5.43702 

 1st Qu.:-0.975398   1st Qu.:-1.07583   1st Qu.:-1.10160 

 Median :-0.008098   Median : 0.07261   Median :-0.01148 

 Mean   : 0.003189   Mean   :-0.02773   Mean   : 0.05765 

 3rd Qu.: 0.966524   3rd Qu.: 1.01091   3rd Qu.: 1.30336 

 Max.   : 4.662340   Max.   : 5.40725   Max.   : 5.68284 

 

2) Using sim()


SModel <-'i =~ 1*t1 + 1*t2 + 1*t3

   s =~ 0*t1 + 1*t2 + 2*t3'

Data1 <- sim(1, SModel, n=500, generate=popModel, lavaanfun="growth", meanstructure=TRUE, seed=53487, estimator="ml")

summary(Data1)


> summary(Data1)

RESULT OBJECT

Model Type

[1] "lavaan"

========= Fit Indices Cutoffs ============

           Alpha

Fit Indices      0.1     0.05     0.01    0.001     Mean SD

      chisq    0.505    0.505    0.505    0.505    0.505 NA

      aic   5472.040 5472.040 5472.040 5472.040 5472.040 NA

      bic   5505.757 5505.757 5505.757 5505.757 5505.757 NA

      rmsea    0.000    0.000    0.000    0.000    0.000 NA

      cfi      1.000    1.000    1.000    1.000    1.000 NA

      tli      1.005    1.005    1.005    1.005    1.005 NA

      srmr     0.008    0.008    0.008    0.008    0.008 NA

========= Parameter Estimates and Standard Errors ============

       Estimate Average Estimate SD Average SE Power (Not equal 0) Std Est Std Est SD Std Ave SE Average Param Average Bias Coverage

t1~~t1            1.123          NA      0.188                   1   0.569         NA      0.088           1.0        0.123        1

t2~~t2            1.245          NA      0.116                   1   0.497         NA      0.034           1.2        0.045        1

t3~~t3            2.176          NA      0.274                   1   0.551         NA      0.060           1.8        0.376        1

i~~i              0.850          NA      0.182                   1   1.000         NA      0.000           1.0       -0.150        1

s~~s              0.052          NA      0.110                   0   1.000         NA      0.000           0.2       -0.148        1

i~~s              0.179          NA      0.117                   0   0.848         NA      1.455           0.0        0.179        1

i~1              -0.011          NA      0.060                   0  -0.011         NA      0.065           0.0       -0.011        1

s~1              -0.020          NA      0.041                   0  -0.087         NA      0.202           0.0       -0.020        1

================== Replications =====================


As you can see, I have a problem here and I'm not understanding what I'm doing wrong.

Could you identify it, please ?


Thanks in advance.


Best,

Catarina




--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+unsubscribe@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.


Reply all
Reply to author
Forward
0 new messages