Hello,
I am running this code to conduct LGCM prior to GMM.
I was wondering if there is a way of implementing FIML instead of ML in my code.
This is because my data has a lot of missingness by design (longitudinal data) and is not normally distributed.
Many thanks!!!
require(OpenMx)
?MxFitFunction
fitFunction <- mxFitFunctionML(rowDiagnostics=TRUE)
mxOption(NULL,"Default optimizer","SLSQP") ### to avoid msg error: https://openmx.ssri.psu.edu/node/4238
linear_growth_model <- mxModel('Linear Growth, Path Specification', fitFunction,
type='RAM', mxData(observed=dfwide_OpenMx, type='raw'),
manifestVars=c('health_2','health_3','health_4','health_5','health_6','health_7','health_8','health_9'),
latentVars=c('eta_1','eta_2'),
# residual variance paths
mxPath(from=c('health_2','health_3','health_4','health_5','health_6','health_7','health_8','health_9'),
arrows=2, free=TRUE, values=1, labels='th'),
# latent variable variances and covariance paths
mxPath(from=c('eta_1','eta_2'), arrows=2, connect='unique.pairs',
free=TRUE, values=c(1,0.5,1), labels=c('psi_11','psi_21','psi_22')),
# factor loadings
mxPath(from='eta_1', to=c('health_2','health_3','health_4','health_5','health_6','health_7','health_8','health_9'),
arrows=1, free=FALSE, values=1),
mxPath(from='eta_2', to=c('health_2','health_3','health_4','health_5','health_6','health_7','health_8','health_9'),
arrows=1, free=FALSE, values=c(0, 1, 2, 3, 4, 5, 6, 7)),
# means and intercepts
mxPath(from='one', to=c('eta_1','eta_2'),
arrows=1, free=TRUE, values=c(1,1), labels=c( 'alpha_1',
'alpha_2'))
) # close model
linear_growth_model = mxModel(linear_growth_model, mxCI(c('psi_11','psi_21','psi_22', "th", "alpha_1", "alpha_2"))) # list the things you want CIs for.
linear_growth_model = mxRun(linear_growth_model, intervals= T)
summary(linear_growth_model, refModels=mxRefModels(linear_growth_model, run = TRUE))
model_linear <- mxTryHard(linear_growth_model) # Run the model, returning the result into model
summary(model_linear)