I’m stuck with a Confirmatory Factor Analysis (CFA) issue. My model has 10 factors and 103 ordinal variables, with a sample size of 284. Everything’s fine when I run it without specifying ordinal data, but adding ordered=TRUE
throws an error.
The error says some categories in ‘ASoc6’ are empty, showing frequencies [21 70 113 0]. But when I check my original data, it shows [1 30 101 152]. I can’t even view the frequencies in R - it reports that the object isn’t found.
I’ve tried removing ‘ASoc6’, yet ‘ASoc11’ then leads to the same issue. I am certain that the data was imported correctly from SPSS into RStudio.
Here’s a simplified version of my model:
modelshort <- '
comm =~ Comm3 + Comm5 + Comm6
rc =~ RC2 + RC6 + RC7
as =~ AS6 + AS8 + AS9
vd =~ VD1 + VD2 + VD3
'
fitshortord <- cfa(modelshort, data=mydata, ordered=TRUE)
Any ideas on what might be going wrong and how I can resolve this category issue to successfully run my CFA with ordinal data?
Hey Mia_79Dance, that’s a tricky situation you’ve got there! 
I’m curious - have you tried checking the structure of your data after importing it into R? Sometimes weird things can happen during the import process, especially with ordinal data. Maybe try running str(mydata)
or summary(mydata)
to see if the variables look like they should?
Also, I wonder if there might be some kind of data transformation happening behind the scenes when you run the CFA. Have you looked into whether the lavaan package (I’m assuming that’s what you’re using?) does any automatic recoding or handling of ordinal variables?
One thing you could try is manually recoding your ordinal variables before running the CFA. Something like:
mydata$ASoc6 <- factor(mydata$ASoc6, ordered = TRUE)
for each of your ordinal variables. This way, you can double-check that R is seeing the correct number of levels and frequencies.
What do you think? Have you tried anything like this already? I’m really curious to hear more about your project and what you find out!
I’ve encountered similar issues with CFA on ordinal data before. One possible cause could be how R is interpreting your data types. Have you checked the class of your variables using sapply(mydata, class)
? Sometimes R can misinterpret ordinal data as numeric or character.
Another thing to consider is missing values. Even a few NAs can cause unexpected behavior in CFA models. You might want to examine your data for any missing values and decide how to handle them (e.g., listwise deletion or imputation).
If these don’t resolve the issue, you could try an alternative approach. Instead of using ordered=TRUE
, you might specify the variables as ordinal in the model syntax:
modelshort <- '
comm =~ Comm3 + Comm5 + Comm6
rc =~ RC2 + RC6 + RC7
as =~ AS6 + AS8 + AS9
vd =~ VD1 + VD2 + VD3
Comm3 + Comm5 + Comm6 + RC2 + RC6 + RC7 + AS6 + AS8 + AS9 + VD1 + VD2 + VD3 ~ 1
'
fitshortord <- cfa(modelshort, data=mydata, ordered=c('Comm3', 'Comm5', 'Comm6', 'RC2', 'RC6', 'RC7', 'AS6', 'AS8', 'AS9', 'VD1', 'VD2', 'VD3'))
This approach gives you more control over which variables are treated as ordinal.
hey mia, sounds like a pain! have u tried checking ur data types after importing? sometimes R gets confused w/ ordinal stuff. maybe try table(mydata$ASoc6)
to see the actual freqs? also, double-check for NAs - they can mess things up. if all else fails, u could try manually recoding ur vars as factors before running the CFA. good luck!