After introducing layoutSplit = TRUE, I get an error:
Error in [<-(*tmp*, object@Pars$sub == g, , value = (subModList[[g]]$ECP + :
(subscript) logical subscript too long
Not sure what's going on, or if I'm using it weirdly somehow (got it with real data and the reproducible example shown below).
#This MODIFIED FROM https://osf.io/ch3rf/
#'Developmental cognitive neuroscience using Latent Change Score models: A tutorial and applications'
#Rogier A. Kievit, Andreas M. Brandmaier, Gabriel Ziegler, Anne-Laura van Harmelen,
#Susanne de Mooij, Michael Moutoussisa, Ian Goodyer, Ed Bullmore, Peter Jones,
#Peter Fonagy, NSPN Consortium, Ulman Lindenberger & Raymond J. Dolan
#Original code was written by Rogier A. Kievit (rogier.kievit@mrc-cbu.cam.ac.uk), 30 January 2017.
#It may be used, (re)shared and modified freely under a CC-BY license
#Fix sample size
samplesize<-500
#Simulate data for a Univariate Latent Change Score model.
MG_ULCS_simulate<-'
##### The following lines specify the core assumptions of the LCS
##### and should not generally be modified
COG_T2 ~ 1*COG_T1 # Fixed regression of COG_T2 on COG_T1
dCOG1 =~ 1*COG_T2 # Fixed regression of dCOG1 on COG_T2
COG_T2 ~ 0*1 # This line constrains the intercept of COG_T2 to 0
COG_T2 ~~ 0*COG_T2 # This fixes the variance of the COG_T2 to 0
###### The following five parameters will be estimated in the model.
###### Values can be modified manually to examine the effect on the model
dCOG1 ~ c(4,8)*1 # This fixes the change score intercept to 4 and 8 for two groups
COG_T1 ~ 50*1 # This fixes the intercept of COG_T1 to 50.
dCOG1 ~~ c(4,2)*dCOG1 # This fixes the change scores variance to 4 & 2
COG_T1 ~~ 8*COG_T1 # This fixes the variance of the COG_T1 to 8
dCOG1~-0.05*COG_T1 # This fixes the self-feedback parameter to -0.05
'
#Simulate data
set.seed(1234)
simdatMG_ULCS<-lavaan::simulateData(MG_ULCS_simulate,sample.nobs = c(.5*samplesize,.5*samplesize),meanstructure = T) #Simulate data
colMeans(simdatMG_ULCS) #sanity check the means
#Update group to factor for further use
simdatMG_ULCS$group<-as.factor(simdatMG_ULCS$group)
levels(simdatMG_ULCS$group)<-c('Group A', 'Group B')
#Fit the Univariate Latent Change Score model to simulated data
MG_ULCS<-'
COG_T2 ~ 1*COG_T1 # Fixed regression of COG_T2 on COG_T1
dCOG1 =~ 1*COG_T2 # Fixed regression of dCOG1 on COG_T2
COG_T2 ~ 0*1 # This line constrains the intercept of COG_T2 to 0
COG_T2 ~~ 0*COG_T2 # This fixes the variance of the COG_T2 to 0
COG_T1 ~ 1 # This estimates the intercept of COG_T1
dCOG1 ~~ dCOG1 # This estimates the variance of the change scores
COG_T1 ~~ COG_T1 # This estimates the variance of the COG_T1
dCOG1~COG_T1 # This estimates the self-feedback parameter
'
fitMG_ULCS <- lavaan::lavaan(MG_ULCS, data=simdatMG_ULCS, estimator='mlr',fixed.x=FALSE,group='group',missing='fiml')
summary(fitMG_ULCS, fit.measures=TRUE, standardized=TRUE, rsquare=TRUE)
semPlot::semPaths(fitMG_ULCS, "std", label.cex = .6, label.scale = FALSE, edge.label.cex = 0.75, layout = "tree",
intercepts = FALSE,
layoutSplit = TRUE,
color = list(lat = viridis::viridis(3, begin = 0.3)[1],
man = viridis::viridis(3, begin = 0.3)[2],
int = viridis::viridis(3, begin = 0.3)[3]))
Hi,
After introducing layoutSplit = TRUE, I get an error:
Not sure what's going on, or if I'm using it weirdly somehow (got it with real data and the reproducible example shown below).