Adjust SEM for age, bmi, education

51 views
Skip to first unread message

fabiana zuelli

unread,
Sep 20, 2022, 11:23:45 AM9/20/22
to lavaan
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?

Terrence Jorgensen

unread,
Oct 8, 2022, 2:49:18 AM10/8/22
to lavaan
You can just enter observed variables into lavaan's model syntax as a path analysis, like the model you first indicated you wanted to fit:
 
centered_POMS_Total ~ Brain + IL6

This is not a measurement model:
 
# Measurement model
IL6x =~ IL6
Brainx =~ Brain
IQx =~ IQ

You are just putting observed variables into the latent space.  lavaan does this for you automatically when you use observed variables as predictors.
 
centered_POMS_Total ~ Brain + IL6

If you are treating them as single-indicator factors because they have missing values, you can set missing = "fiml.x"

Now, I want to adjust for age, BMI, and years of education for both covariances and regression.

To estimate the effects of Brain and IL6 adjusted/controlling for those covariates (i.e., partialing the covariates out of Brain and IL6, as well as the outcome), all you have to do is add those covariates:

centered_POMS_Total ~ Brain + IL6 + IQ + age + bmi + edu
 
That's why multiple regression slopes are sometimes called "partial regression slopes". 

IL6_adjx =~ IL6 + age + bmi + edu
Brain_adjx =~ Brain + age + bmi + edu
IQ_adjx =~ IQ + age + bmi + edu

This treats the covariates as outcomes, not predictors.  They must be used as predictors of  Brain, IL6, and IQ to partial out differences due to covariates (i.e., "adjust" them).  But again, you don't have to manually do that.  That is how the math works when you add them as covariates along with focal predictors.

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Reply all
Reply to author
Forward
0 new messages