Second order growth model

28 views
Skip to first unread message

EmH

unread,
Sep 14, 2022, 1:17:33 AM9/14/22
to MplusAutomation

Hello, MplusAutomation team,




I am trying to run a second order growth model with the below.

----------

Time points: 9

Sample size: around 300-400

1 latent factor I am interested in the trajectory of (AE: 5 indicators. (ae1-ae5))

2 time varying covariates (AS & TC)

AS: 5 indicators. (as1-as5)

TC: 4 indicators. (tc1-tc4)

5 time invariant covariates (categorical)

Country, school, Stest

*partial invariance maintained for strong invariance.




What I would like to know;

1: fixed and random trajectory of AE.

2: how the two TVC affect AE

3: how TIC affect AE

I have currently successfully ran it in Mplus but it takes too long to run

the whole dataset. So I trimmed it down to a T1-T5 model.

the code is as follows,

-------------------------------------

#Load dataset
G5all <-read.csv("/Users/R2M GCM/data2use/G5GCMComp(MAuto).csv")
head(G5all)
#Mplus data to run from R
GCM5small<- mplusObject(
TITLE = "G5 T1-5 second order growth curve",
VARIABLE = "USEVARIABLES = t1ae1-tc4 t2ae1-tc4 t3ae1-tc4 t4ae1-tc4 t5ae1-tc4;",
usevariables = paste0("x", 1:45),
MODELMISSING = "-99",
ANALYSIS = "general",
Estimator = "MLR",
STARTS = "200",
MODEL =
#Create factor for AE
#1st item set to 1 by default for identification
#Other items labeled (L2-L5) for equality constraints.
"AE1 by t1ae1 * (L1)
t1ae2 t1ae3 t1ae4 t1ae5 (L2-L5);
AE2 by t2ae1 * (L1)
t2ae2 t2ae3 t2ae4 t2ae5 (L2-L5);
AE3 by t3ae1 * (L1)
t3ae2 t3ae3 t3ae4 t3ae5 (L2-L5);
AE4 by t4ae1 * (L1)
t4ae2 t4ae3 t4ae4 t4ae5 (L2-L5);
AE5 by t5ae1 * (L1)
t5ae2 t5ae3 t5ae4 t5ae5 (L2-L5);",

#Create factor for AS (TVC1)
"
AS1 by t1as1 t1as2 t1as3 t1as4 t1as5;
AS2 by t2as1 t2as2 t2as3 t2as4 t2as5;
AS3 by t3as1 t3as2 t3as3 t3as4 t3as5;
AS4 by t4as1 t4as2 t4as3 t4as4 t4as5;
AS5 by t5as1 t5as2 t5as3 t5as4 t5as5;",

# Create factor for AS (TVC2)
"
TC1 by t1tc1 t1tc2 t1tc3 t1tc4;
TC2 by t2tc1 t2tc2 t2tc3 t2tc4;
TC3 by t3tc1 t3tc2 t3tc3 t3tc4;
TC4 by t4tc1 t4tc2 t4tc3 t4tc4;
TC5 by t5tc1 t5tc2 t5tc3 t5tc4;",

#(first order) Item intercepts constrained to be equal (labeled)
"
[t1ae1 t2ae1 t3ae1 t4ae1 t5ae1 ] (I1);
[t1ae2 t2ae2 t3ae2 t4ae2 t5ae2 ] (I2);
[t1ae3 t2ae3 t3ae3 t4ae3 t5ae3 ] (I3);
[t1ae4 t2ae4 t3ae4 t4ae4 t5ae4 ] (I4);
[t1ae5 t2ae5 t3ae5 t4ae5 t5ae5 ] (I5);",

#(fitst order (AE)) residual autolagged covariance across time
"
t1ae1 with t2ae1 t3ae1 t4ae1 t5ae1;
t2ae1 with t3ae1 t4ae1 t5ae1;
t3ae1 with t4ae1 t5ae1;
t4ae1 with t5ae1;

t1ae2 with t2ae2 t3ae2 t4ae2 t5ae2;
t2ae2 with t3ae2 t4ae2 t5ae2;
t3ae2 with t4ae2 t5ae2;
t4ae2 with t5ae2;

t1ae3 with t2ae3 t3ae3 t4ae3 t5ae3;
t2ae3 with t3ae3 t4ae3 t5ae3;
t3ae3 with t4ae3 t5ae3;
t4ae3 with t5ae3;

t1ae4 with t2ae4 t3ae4 t4ae4 t5ae4;
t2ae4 with t3ae4 t4ae4 t5ae4;
t3ae4 with t4ae4 t5ae4;
t4ae4 with t5ae4;

t1ae5 with t2ae5 t3ae5 t4ae5 t5ae5;
t2ae5 with t3ae5 t4ae5 t5ae5;
t3ae5 with t4ae5 t5ae5;
t4ae5 with t5ae5;",

#TVC (AS;TC) residual variances autolagged
"
t1as1 with t2as1 t3as1 t4as1 t5as1;
t2as1 with t3as1 t4as1 t5as1;
t3as1 with t4as1 t5as1;
t4as1 with t5as1;

t1as2 with t2as2 t3as2 t4as2 t5as2;
t2as2 with t3as2 t4as2 t5as2;
t3as2 with t4as2 t5as2;
t4as2 with t5as2;

t1as3 with t2as3 t3as3 t4as3 t5as3;
t2as3 with t3as3 t4as3 t5as3;
t3as3 with t4as3 t5as3;
t4as3 with t5as3;

t1as4 with t2as4 t3as4 t4as4 t5as4;
t2as4 with t3as4 t4as4 t5as4;
t3as4 with t4as4 t5as4;
t4as4 with t5as4;

t1as5 with t2as5 t3as5 t4as5 t5as5;
t2as5 with t3as5 t4as5 t5as5;
t3as5 with t4as5 t5as5;
t4as5 with t5as5;

t1tc1 with t2tc1 t3tc1 t4tc1 t5tc1;
t2tc1 with t3tc1 t4tc1 t5tc1;
t3tc1 with t4tc1 t5tc1;
t4tc1 with t5tc1;

t1tc2 with t2tc2 t3tc2 t4tc2 t5tc2;
t2tc2 with t3tc2 t4tc2 t5tc2;
t3tc2 with t4tc2 t5tc2;
t4tc2 with t5tc2;

t1tc3 with t2tc3 t3tc3 t4tc3 t5tc3;
t2tc3 with t3tc3 t4tc3 t5tc3;
t3tc3 with t4tc3 t5tc3;
t4tc3 with t5tc3;

t1tc4 with t2tc4 t3tc4 t4tc4 t5tc4;
t2tc4 with t3tc4 t4tc4 t5tc4;
t3tc4 with t4tc4 t5tc4;
t4tc4 with t5tc4;",

# 2nd order growth factors
"
i by AE1@1 AE2@1 AE3@1 AE4@1 AE5@1;
s by AE1@0 AE2@1 AE3@2 AE4@3 AE5@4;
",
# Estimate means of the intercept and slope factors
"
[i s];
",
#Set AE intercept to 0.
"
[AE1-AE5@0];",


#intercept and slope with TIC(country ToT CFreq Stest)
"i s ON country school;",
"i s ON AS1-AS5 TC1-TC5;",
#assitional statements for TIC to be modeled for all data to be
#included Grimm et al.;(2016) p.105
" country school;
[country school];
country with school;",
#AE on AS (TVC1)
"
AE1 ON AS1;
AE2 ON AS2;
AE3 ON AS3;
AE4 ON AS4;
AE5 ON AS5;",


#AE on TC (TVC2)
"
AE1 ON TC1;
AE2 ON TC2;
AE3 ON TC3;
AE4 ON TC4;
AE5 ON TC5;",


modelconstraint = "
L1 = 5 - L5 - L4 - L3 - L2;
I1 = 0 - I2 - I3 - I4 - I5;",


output= "standardized;",
"Tech1;",
rdata = G5all
)

result <- mplusModeler(GCM5small,
modelout = "GCM5small.inp",
run = 1L)





When I run my model, MplusAutomation gives me an error saying,

error in `[.data.frame`(object$rdata, , object$usevariables, drop = FALSE) : undefined columns selected


I have tried using the prepareMplusdata

-------------

#prepare Mplus data

prepareMplusData(G5all,

dummyCode = 'Country','school','Stest',

keepCols = c("Country", "school",

"t1ae1", "t1ae2", "t1ae3", "t1ae4", "t1ae5",

"t1as1", "t1as2", "t1as3", "t1as4", "t1as5",

"t1tc1", "t1tc2", "t1tc3", "t1tc4",

"t2ae1", "t2ae2", "t2ae3", "t2ae4", "t2ae5",

"t2as1", "t2as2", "t2as3", "t2as4", "t2as5",

"t2tc1", "t2tc2", "t2tc3", "t2tc4",

"t3ae1", "t3ae2", "t3ae3", "t3ae4", "t3ae5",

"t3as1", "t3as2", "t3as3", "t3as4", "t3as5",

"t3tc1", "t3tc2", "t3tc3", "t3tc4",

"t4ae1", "t4ae2", "t4ae3", "t4ae4", "t4ae5",

"t4as1", "t4as2", "t4as3", "t4as4", "t4as5",

"t4tc1", "t4tc2", "t4tc3", "t4tc4",

"t5ae1", "t5ae2", "t5ae3", "t5ae4", "t5ae5",

"t5as1", "t5as2", "t5as3", "t5as4", "t5as5",

"t5tc1", "t5tc2", "t5tc3", "t5tc4"),



dropCols = "Stest",

"t6ae1", "t6ae2", "t6ae3", "t6ae4", "t6ae5",

"t6as1", "t6as2", "t6as3", "t6as4", "t6as5",

"t6tc1", "t6tc2", "t6tc3", "t6tc4",

"t7ae1", "t7ae2", "t7ae3", "t7ae4", "t7ae5",

"t7as1", "t7as2", "t7as3", "t7as4", "t7as5",

"t7tc1", "t7tc2", "t7tc3", "t7tc4",

"t8ae1", "t8ae2", "t8ae3", "t8ae4", "t8ae5",

"t8as1", "t8as2", "t8as3", "t8as4", "t8as5",

"t8tc1", "t8tc2", "t8tc3", "t8tc4",

"t9ae1", "t9ae2", "t9ae3", "t9ae4", "t9ae5",

"t9as1", "t9as2", "t9as3", "t9as4", "t9as5",

"t9tc1", "t9tc2", "t9tc3", "t9tc4",



)

It would be very helpful if you would show me what is wrong with my syntax.



Reply all
Reply to author
Forward
0 new messages