Hi all.
I am doing SEM in Lavaan.
I have the following latent factors (all continuous)
IL6
Brain
IQ
My outcome is centered_POMS_total (continuous)
This is my unadjusted model
#Structural model
centered_POMS_Total ~ Brain + IL6
SEM.model <- '
# Measurement model
IL6x =~ IL6
Brainx =~ Brain
IQx =~ IQ
# Regressions
centered_POMS_Total ~ IL6x + Brainx
*I don't want IQ to predict the outcome, therefore, did not include here*
# Residual correlations
Brainx ~~ IL6x
IL6x ~~ IQx
Brainx ~~ IQx
'
fit.SEM.model <- sem(SEM.model, data = FRS_c_data_IL6_IQ_brain_factor_POMS_fatg,
std.lv = TRUE,
missing = "fiml")
summary(fit.SEM.model)
options(
knitr.kable.NA = '')
fitMeasures(fit.SEM.model)
parameterEstimates(fit.SEM.model, standardized = TRUE)
semPaths(fit.SEM.model, "SEM.model", "parameterEstimates")
**This works ok**
Now, I want to adjust for age, BMI, and years of education for both covariances and regression. All are numerical
What I am trying
#Structural model
centered_POMS_Total ~ brain_adjx + IL6_adjx
*brain_adx is a .csv file with 4 columns (1 brain exposure + 3 covariates age, bmi, edu)*
*IL6_adx is a .csv file with 4 columns (1 IL6 exposure + 3 covariates age, bmi, edu)*
SEM.model_FRS_brain_factor_t_adj <- '
# Measurement model
IL6_adjx =~ IL6 + age + bmi + edu
Brain_adjx =~ Brain + age + bmi + edu
IQ_adjx =~ IQ + age + bmi + edu
# Regressions
centered_POMS_Total ~ IL6_adjx + Brain_adjx
# Residual correlations
Brain_adjx ~~ IL6_adjx
IL6_adjx ~~ IQ_adjx
Brain_adjx ~~ IQ_adjx
'
fit.SEM.model_FRS_brain_factor_t_adj <- sem(SEM.model_FRS_brain_factor_t_adj, data = FRS_c_data_IL6_IQ_brain_factor_POMS_t_adj,
std.lv = TRUE,
missing = "fiml")
summary(fit.SEM.model_FRS_brain_factor_t_adj)
**What I am getting**
Warning message:
In lavaan::lavaan(model = SEM.model_FRS_brain_factor_t_adj, data = FRS_c_data_IL6_IQ_brain_factor_POMS_t_adj, :
lavaan WARNING:
the optimizer warns that a solution has NOT been found!
Then in the output, the Std Error or p have NA
I have even tried to add orthogonal=TRUE, see below
fit.SEM.model_FRS_brain_factor_t_adj <- sem(SEM.model_FRS_brain_factor_t_adj, data = FRS_c_data_IL6_IQ_brain_factor_POMS_t_adj,
std.lv = TRUE,
missing = "fiml",
orthogonal=TRUE)
But still not working..
any suggestions?