Parallel growth model

106 views
Skip to first unread message

Macsue Jacques

unread,
Jun 22, 2020, 6:24:13 PM6/22/20
to lavaan
Hello, I’m trying to run a parallel growth model, which can be done in Mplus. Would this be the same as a multilevel sem in lavaan? Or is there a special function for it?

Christopher Loan

unread,
Jun 22, 2020, 7:01:59 PM6/22/20
to lavaan
Hello, 

This can be done with the growth() function (which really just calls on the lavaan() function). This is not the same as multilevel sem.

for three time points, intercept and slope only, this would look like: 


model <-
'
Intercept1 =~ 1*x1 + 1*x2 + 1*x3
slope1 =~ 0*x1 + 1*x2 + 2*x3

Intercept2 =~ 1*y1 + 1*y2 + 1*y3
slope2 =~ 0*y1 + 1*y2 + 2*y3

'

fit<- growth(model, data = dat)
summary(fit)

pay attention to your covariances if you have specific specifications (e.g., intercept predicting slope), but this will have all latent vars covary and have estimated variances by default. 

Macsue Jacques

unread,
Jun 22, 2020, 7:19:21 PM6/22/20
to lavaan
Hello,

Thank you so much for this! I don’t believe I have any covariances restrictions what I really want to see is if two growth models are interacting (I.e. changing at the same rate either in the same or opposite directions) so I assume that if I leave the model with this code I will obtain this information with the covariances right?
Message has been deleted

Christopher Loan

unread,
Jun 23, 2020, 12:17:01 PM6/23/20
to lavaan
Yes, latent variables automatically are given a variance and a covariance which you'll see. 

If you want a significance test to see if the rate is significantly different (if that matters to you at all, it might not, but it sounds like this might be what you're doing), you'll have to be creative though. 

In particular you'd want to specify a model which had no constraints on the slope (i.e., what I wrote above), then another model which constrains them to be the same, then you'd do a lavTestLRT(fit1, fit2) call on the two fitted objects. If the test is significant, then you'd prefer the model without the constraint, which would say the slopes are significantly different, otherwise they are not significantly different.

Macsue Jacques

unread,
Jun 25, 2020, 2:17:58 AM6/25/20
to lavaan
Ok so I could do this by writing the following: (please correct me if I am wrong).

model <-
'
Intercept1 =~ 1*x1 + 1*x2 + 1*x3
slope1 =~ 0*x1 + 1*x2 + 2*x3

Intercept2 =~ 1*y1 + 1*y2 + 1*y3
slope2 =~ 0*y1 + 1*y2 + 2*y3

s1~0*1
s1~~0*i

s2~0*1
s2~~0*I
'

Another question I have is how strict should I be on the fit measures (p-value -chisquare, RMSA, CFI, SRMR)? Can I free some timepoints in the slope to make tha model better (i.e. slope2 =~ 0*y1 + 1*y2 + y3+ y4)? How critical it is to get a good model fit?

What is considered a significant variance and covariance?

I am really sorry for so many questions but I am quite new to this and I just want to make sure I get it right.

Thank you so much for your help so far!!!

Christopher Loan

unread,
Jun 25, 2020, 6:57:03 PM6/25/20
to lavaan
You're close, you constrained them to be the same, but also constrained them to be 0, which you don't want if I'm understanding you correctly. That is a good model to compare intercept-only to intercept and slope growth.

If you're specifically looking to test if the two slopes are significantly different from one another (or technically, if the model fits significantly better when they're specified separately or not), you will do the unconstrained PPM like above, then the constrained PPM.

You'll want to set the slopes to be equal with a label (both the same label), like this: 

constrainedMod <-
'
Intercept1 =~ 1*x1 + 1*x2 + 1*x3
slope1 =~ 0*x1 + 1*x2 + 2*x3

Intercept2 =~ 1*y1 + 1*y2 + 1*y3
slope2 =~ 0*y1 + 1*y2 + 2*y3

s1~constraint*1
s2~constraint*1

'
then do an lavTestLRT(unconstrainedMod, constrainedMod). The null hypothesis of this test is essentially that the models fit the same, if so, pick the one with more df because its parsimonious. 

Regarding fit measures, there's an entire literature on this. Hu & Bentler 1999 is often cited, but there are papers about how incremental fit indices are poorer for growth curves. In my own work, I typically have had growth curves fit the Hu & Bentler criteria, though. The importance of fit is related to how important accurate interpretations are. Fit tells you if the model you impose is reflected in the data.

Freed timepoints can be compared to fixed timepoints with lavTestLRT() as well. Models can be more complex that way and you will need some SEM knowlegde to interpret correctly, but if you have more than 3 waves of data it's possible.

Explore this youtube channel for theoretical understanding of some of your questions: https://www.youtube.com/channel/UC7kcXN1Xoj4PzMIKPHJ5m7Q/videos

Christopher Loan

unread,
Jun 25, 2020, 6:58:32 PM6/25/20
to lavaan
s1 and s2 should be slope1 and slope2 in my prior message

Macsue Jacques

unread,
Jul 4, 2020, 11:45:13 PM7/4/20
to lavaan
Hello,

Thank you so much for your help so far. I have now written individual growth models for each of my variables to make sure I get the best fit for all of the variables. 

Then I have tried to combine all variables into one parallel growth model and I get an error like this:

Error in lav_samplestats_icov(COV = cov[[g]], ridge = ridge, x.idx = x.idx[[g]],  : 
  lavaan ERROR: sample covariance matrix is not positive-definite
In addition: Warning messages:
1: In lav_data_full(data = data, group = group, cluster = cluster,  :
  lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate
2: In lav_data_full(data = data, group = group, cluster = cluster,  :
  lavaan WARNING: small number of observations (nobs < nvar)
  nobs = 16 nvar = 36

But if I ran parallel models with less variables they work fine, sometimes with 3 variables at a time sometimes with only 2. I am not sure why that is if every individual model works. I am just running in parallel to be able to check if variables change the same (slopes are significantly different or not). So if I had all covariances between intercepts and slopes I would be able to infer if two slopes are significantly changing at the same direction correct? or should I do this one variable at a time and just compare models one at a time?

Bellow is how I have done the parallel model based on best fit for each variable:

model='
#intercept
iW =~ 1*Wpeak_rel_PRE + 1*Wpeak_rel_4WP + 1*Wpeak_rel_8WP + 1*Wpeak_rel_12WP
#slope
sW=~ 0*Wpeak_rel_PRE + 1*Wpeak_rel_4WP + 2*Wpeak_rel_8WP + 3*Wpeak_rel_12WP
#intercept
iL =~ 1*LT_poly_rel_PRE + 1*LT_poly_rel_4WP + 1*LT_poly_rel_8WP + 1*LT_poly_rel_12WP
#slope
sL=~ 0*LT_poly_rel_PRE + 1*LT_poly_rel_4WP + LT_poly_rel_8WP + LT_poly_rel_12WP
#residual variances
LT_poly_rel_PRE~~r*LT_poly_rel_PRE
LT_poly_rel_4WP~~r*LT_poly_rel_4WP
LT_poly_rel_8WP~~r*LT_poly_rel_8WP
LT_poly_rel_12WP~~r*LT_poly_rel_12WP
#intercept
iV =~ 1*VO2max_rel_PRE + 1*VO2max_rel_4WP + 1*VO2max_rel_8WP + 1*VO2max_rel_12WP
#slope
sV=~ 0*VO2max_rel_PRE + 1*VO2max_rel_4WP + 2*VO2max_rel_8WP + VO2max_rel_12WP
#residual variances
VO2max_rel_PRE~~r*VO2max_rel_PRE
VO2max_rel_4WP~~r*VO2max_rel_4WP
VO2max_rel_8WP~~r*VO2max_rel_8WP
VO2max_rel_12WP~~r*VO2max_rel_12WP
#intercept
iCS =~ 1*CS_PRE + 1*CS_4WP + 1*CS_8WP + 1*CS_12WP
#slope
sCS=~ 0*CS_PRE + 1*CS_4WP + 2*CS_8WP + CS_12WP
CS_PRE~~r*CS_PRE
CS_4WP~~r*CS_4WP
CS_8WP~~r*CS_8WP
CS_12WP~~r*CS_12WP
#intercept
iC =~ 1*COX_PRE + 1*COX_4WP + 1*COX_8WP + 1*COX_12WP
#slope
s1C=~ 0*COX_PRE + 1*COX_4WP + 2*COX_8WP + 3*COX_12WP
s2C=~ 0*COX_PRE + 1*COX_4WP + 4*COX_8WP + 9*COX_12WP
#intercept
imt =~ 1*mtCN_PRE_div + 1*mtCN_4WP_div + 1*mtCN_8WP_div + 1*mtCN_12WP_div
#slope
smt=~ 0*mtCN_PRE_div + mtCN_4WP_div + mtCN_8WP_div + 1*mtCN_12WP_div
#residual variances
mtCN_PRE_div~~r*mtCN_PRE_div
mtCN_4WP_div~~r*mtCN_4WP_div
mtCN_8WP_div~~r*mtCN_8WP_div
mtCN_12WP_div~~r*mtCN_12WP_div
mtCN_PRE_div~Age_PRE
mtCN_4WP_div~Age_4WP
mtCN_8WP_div~Age_8WP
mtCN_12WP_div~Age_12WP
#intercept
iM =~ 1*MHI_PRE + 1*MHI_4WP + 1*MHI_8WP + 1*MHI_12WP
#slope
sM=~ 0*MHI_PRE + MHI_4WP + MHI_8WP + 1*MHI_12WP
#intercept
iS =~ 1*SDH_PRE + 1*SDH_4WP + 1*SDH_8WP + 1*SDH_12WP
#slope
sS=~ 0*SDH_PRE + 1*SDH_4WP + 2*SDH_8WP + 2*SDH_12WP
s2S=~ 0*SDH_PRE + 0*SDH_4WP + 0*SDH_8WP + 1*SDH_12WP
#residual variances
SDH_PRE~~r*SDH_PRE
SDH_4WP~~r*SDH_4WP
SDH_8WP~~r*SDH_8WP
SDH_12WP~~r*SDH_12WP
'

Patrick (Malone Quantitative)

unread,
Jul 5, 2020, 8:52:00 AM7/5/20
to lav...@googlegroups.com
Hi.

First, please include your lavaan() call.

Warning 1: What are the raw-data scales for WP and PRE?

Having observed variables with widely varying metrics can cause
computational problems. Look at descriptive statistics for your
observed variables. If the variances of some of the variables are much
larger (lavaan says >1000x) than the variances of the others. One
possibility to check is if you have some numeric missing value flags
(e.g., 999 on a 1-5 scale).

If the values are correct, the usual practice is to divide the values
of the large one by a constant to bring the variances in line. This
will not affect statistical conclusions from the model, though you may
need to go back and rescale the unstandardized parameter estimates
afterward if the resulting scaling is not intuitive.

Fixing this can sometimes help with the NPD error, so I'd try it first.

As for Warning 2, it is what it says it is. You've got an N of 16,
possibly in just one group (again, you haven't sent the lavaan call).
What missing data method did you specify? If you didn't specify, I
think the default is listwise deletion, so you've lost most of your
sample.

Pat
> --
> 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+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/23d6275b-3d4c-4b9d-9e60-10189572f3c5o%40googlegroups.com.



--
Patrick S. Malone, Ph.D., Malone Quantitative
NEW Service Models: http://malonequantitative.com

He/Him/His

Macsue Jacques

unread,
Jul 5, 2020, 11:24:26 PM7/5/20
to lavaan
Hello Pat,

Thank you for your reply. My lavaan call is as follows:

fit <- growth(model, data=GM1div)
summary(fit, fit.measures=TRUE, standardized=TRUE, rsquare=TRUE)


I have done multiple imputations previously using (MICE) and completed my data set with one of the iterations. So I am sure I don't have missing values. I have a small sample size (n=16) and I know that this is not ideal for growth models but because I would like to compare growth curves between multiple variables I decided to give it a go. If you have any other suggestions if I should use any other model instead that would give me this type of info it would be great. So the warning 2 is correct I have more variables than observations, so I guess this is an issue in lavaan? So perhaps I should compare two growth models at a time and just see their covariances one at a time and if slopes are changing at the same rate by comparing uncontrained vs constrained models one at a time. Is this right?

Also I would like to do this models further on using DNA methylation data, which I have 850,000 CpGs for 16 participants and 4 time points each. Would that be possible? I want to see if growth curves for DNA methylation would be similar between participants as well as if they change at the same rate as some of the other variables I have. 

As for the scales of the variables there are variable scales, I will apply divisions to bring those closer together. Is it ok if one variable is divided by 10 and another by 1000 for example?

Lastly, does the order of variables in the model matters? for example (see code from previous post) does it matter if I place Wpeak first or last in the model? Would that change my results?

Sorry for so many questions I am just trying to get my head around the models and how to get it working in a proper manner. 

I appreciate all your help!
> To unsubscribe from this group and stop receiving emails from it, send an email to lav...@googlegroups.com.

Patrick (Malone Quantitative)

unread,
Jul 6, 2020, 10:31:47 AM7/6/20
to lav...@googlegroups.com
Ok. If the N really is 16, that is your problem, and it's what lavaan
is telling you is the problem.

Your larger model is almost certainly empirically underidentified.
It's not specific to lavaan. That's probably also why you have the NPD
error.

For some of your other questions:

"Is it ok if one variable is divided by 10 and another by 1000 for example?"

Yes. Linear transformations such as addition and division by a
constant do not affect the substantive results, but can make
computations easier.

Order of variables does not matter.

I'm not familiar with genetic data, so can't help much else.

Pat
> To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/37f6a44e-435b-4085-b039-67f93ec4aec3o%40googlegroups.com.

Christopher Loan

unread,
Jul 6, 2020, 1:46:37 PM7/6/20
to lavaan
Everything Pat said is correct. One word of caution is using multiple imputation with 16 people... I would strongly suggest using mice to make 10-20 data sets and then pool your estimates. So the `semTools` package will be needed. You'll call growth.mi() to a mice object (that has not had mice::complete() called to it (i.e., the m = 20 data sets)). 

Anyways, I wanted to offer 3 more avenues to explore (assuming I interpret your message correctly). I am offering this because I sadly think 16 will be too small to answer your desired question. 

As a note: I am a doctoral student in a quantitative research methods PhD, but again, I'm still a student and maybe a long-time expert can suggest something I didn't think of or shoot one of these ideas down.

1) If you have 850,000 data points which are all measured at 4 time points in 16 people, you could explore nested models which treat the 16 people as "groups" with times nested inside that, and then you'd actually have 850,000 data points at 4 times which is way more than you'd need for this. But to be fully honest, I don't know if lavaan can handle 3 levels of nesting... You might have to go to an HLM-type software or Mplus. Admittedly, I did not follow you perfectly when you explained this (because I'm a social scientist) so I'm not sure if this will work for you. 

2) You could try a data reduction method. Maybe consider latent classes of these constructs (within individuals), so that you are looking at growth of fewer constructs. And although you won't have every construct mapped, you'll have a gist of how "groups" of constructs move. 

3) The most fool-proof way--but also a way publications may push against--is to simply plot these in ggplot. You could do this two ways: 
a) get the individual growth curves, ask lavaan for the parameter estimates, and get each construct's intercept and slope for each participant. You'd then take the average slope (& the standard error) across people and plot these. If SEs don't overlap, you have a rough estimate of significance.
b) do the same thing without lavaan (i.e., plot the constructs over time) and fit a linear model to it and see if SEs overlap.  

Method 1 will likely give you a headache with implementing in and interpreting from software.
Method 2 will be very hard to concretely conceptualize and explain to others you did it "right" (conceptually, I mean, not in the software).
Method 3 does not take into account other constructs so you're essentially assuming they're fully independent by using different models, and if it's biology things are rarely fully independent. But people tend to like visuals so maybe it'll be sufficient for your purposes.

As an aside, SEM (and all of frequentist statistics) is not so good with data sets where the number of variables is larger than the number of participants. If you wanted to predict something, machine learning methods like random forests or decision trees can do that, but again those are less valid for inference than prediction (and few people have implemented these in interesting longitudinal ways like you're looking for).

Good luck!


On Monday, June 22, 2020 at 3:24:13 PM UTC-7, Macsue Jacques wrote:

Macsue Jacques

unread,
Jul 6, 2020, 6:53:20 PM7/6/20
to lavaan
Hello Christopher & Pat

Sorry if I wasn’t clear enough but you certainly understood my model. I have two separate cases one is the one I have pasted the code and call on previous posts. And for those because I have more variables than observations I will then have to do model comparison one or two variables at a time.

The second model is the genetic one which I also want to see the growth curves against other variables. I haven’t started this model yet but you have given me great insights and you’re right lavaan can only handle a two-level model. So I will have to play around with it... thank you so much for all your help! Ps I didn’t know you could use mice with lavaan so thanks for pointing it out to me!!
Reply all
Reply to author
Forward
0 new messages