I would like to compute a confirmatory factor analysis (CFA) with ordinal data in R
using lavaan
. The data is from a questionnaire, containing 16 items structured on a Likert-scale.
I assume a 4-factor-model to be the best fit to my data. To compute the CFA I searched for information and found some useful advise in this paper.
The recommendation is to use DWLS-estimation and polychoric correlation. I've managed to compute the CFA with DWLS in R
using the lavaan
package. I found out that in Mplus the DWLS estimation, or WLSMV which is the same, uses polychoric correlation , unfortunately I never used Mplus and would like to work with R
, so I was wondering if in lavaan
it's the same.
So far I computed the CFA like this:
I specified a model (model.4) with 4 factors (AV, AW, AB, AA), (each factor has 4 items)
model.4='
AV =~ AVf1_+AVf2+AVf3+AVf4
AW =~ AWf1+AW2+AWf3+AWf4
AB =~ ABf1+ABf2+ABf3+ABf4
AA =~ AAf1+AAf2+AAf3+AAf4'
Then I used the "ordered"
function because of my ordered data, which is recommended in the lavaan
package
model.ord = cfa(model.4,data=Data,ordered=c(
"AVf1","AVf2","AVf3","AVf4",
"AWf1","AWf2","AWf3","AWf4",
"ABf1","ABf2","ABf3","ABf4",
"AAf1","AAf2","AAf3","AAf4"))
This worked well. I got an output with all the relevant fit-indices (CFI, RMSEA etc.). Now my question is, if this automatically based upon polychoric correlation like in Mplus? If it's not - how can I add a command to use polychoric correlation? There is some information in the lavaan
package about polychoric correlation, lavCor
, but I don't know if it's useful for my problem and unfortunately I don't know how to use it.
I tried like this:
model.ord1 <- lavCor(cfa(model.4,data=Data,ordered=c(
"AVf1","AVf2","AVf3","AVf4",
"AWf1","AWf2","AWf3","AWf4",
"ABf1","ABf2","ABf3","ABf4",
"AAf1","AAf2","AAf3","AAf4"))
))
But > summary(model.ord1, fit=T)
didn't work. I did not receive any results.
To sum up: Is my CFA automatically based upon polychoric correlation? If not, how can I change my function to implement polychoric correlation?
The following link contains a similar use case I guess: https://www.packtpub.com/books/content/structural-equation-modeling-and-confirmatory-factor-analysis - scroll down to: "The lavaan syntax":
With the argument
ordered = c
, which you have used, you have told lavaan that some variables are ordinal in nature. In response, lavaan estimates polychoric correlations for these variables.But I don't know if its true/correct. Can anybody confirm it?