Categorical variables in lavaan, please clarify

1,318 views
Skip to first unread message

Elias Carvalho

unread,
Mar 15, 2019, 1:54:24 PM3/15/19
to lavaan
As a newbie in lavaan I got confused with categorical data.Somebody would clarify?

If I have:
Exogenous variables
  • 1 binary (Gender: 0 MALE 1 FEMALE)
  • 1 ordinal (BMI: 1 NORMAL, 2 OBESE, 3 OVERWEIGHT)
  • 1 nominal (RACE: 1 WHITE, 2 BLACK, 3 OTHERS)
Question: In this case I recode GENDER and RACE as dummy and tranform it in numeric and for BMI only transform in numeric?

Endogenous variables:
  • 1 Binary variable (HAS DIABETES: 0 NO 1 YES)
  • 1 ORDINAL variable (PAIN LEVEL: 1 - NO PAIN 2 MODERATE 3 SEVERE)
Question: Keep all as categorical, but tranform it as ordered factor and use
pa.model <- SEM(myModel, data = myData,ordered=c("DIA","PAIN"))? 

And nominal variables as endogenous? How to work with them?

Terrence Jorgensen

unread,
Mar 21, 2019, 6:47:38 AM3/21/19
to lavaan
I recode GENDER and RACE as dummy and tranform it in numeric 

Yes
 
and for BMI only transform in numeric?

Only if you can assume the effect is linear (same change between 1 and 2 as between 2 and 3).  I would recommend using the middle category as a reference and make a dummy for the upper/lower categories.  Label their slopes if you want to test linearity (i.e., see if their absolute magnitudes are equal).

Endogenous variables: Keep all as categorical, but tranform it as ordered factor and use
pa.model <- SEM(myModel, data = myData,ordered=c("DIA","PAIN"))? 

Yes

And nominal variables as endogenous? How to work with them?

You don't, not in lavaan.  You could only recode into a dummy to predict being in category 1 vs. any other category, but you would not be able to go beyond binary regression for a nominal outcome.

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