CFA with DWLS estimator and complex sampling design, using lavaan.survey package

666 views
Skip to first unread message

Lucie L

unread,
Jun 30, 2014, 9:10:49 AM6/30/14
to lav...@googlegroups.com

I want to fit a CFA with one latent variable and three categorical indicators. This model is just-identified (DF=0). My indicators have 5 categories and are not normally distributed, so I should use DWLS estimator. My sample needs to be weighted, so I use the lavaan.survey package and include weights.

First of all, I tried fitting this model with lavaan command, like was done in the tutorial " package'lavaan.survey' ", but I got an error message, indicating that something might be going wrong.

Second, I tried fitting this model using sem command. Here I had to error message, but the model was estimated using MLM instead of DWLS.

Any suggestions of an alternative code that would work?
Here is my code and output.

> f <- "C:/.../mydata.csv"
> t <- read.csv(f,sep=";")
>
> u<-t[!is.na(t$wreg),]
>
> is.numeric(u$q96_1)
[1] TRUE
> is.numeric(u$q96_2)
[1] TRUE
> is.numeric(u$q96_3)
[1] TRUE
> u <- subset(u, q96_1==1| q96_1==2| q96_1==3| q96_1==4| q96_1==5)
> u <- subset(u, q96_2==1| q96_2==2| q96_2==3| q96_2==4| q96_2==5)
> u <- subset(u, q96_3==1| q96_3==2| q96_3==3| q96_3==4| q96_3==5)
> fl <- subset(u, region==1)
> model <- 'ethic =~ q96_1 + q96_2 + q96_3'

# fit using lavaan # error message #
> fit <- lavaan(model, data=fl,ordered=c("q96_1","q96_2","q96_3"))
Erreur dans t(Delta[[g]]) %*% lavsamplestats@WLS.V[[g]] :
  arguments inadéquats
De plus : Messages d'avis :
1: In WLS.obs - WLS.est :
  la taille d'un objet plus long n'est pas multiple de la taille d'un objet plus court
2: In lavsamp...@WLS.obs[[g]] - WLS.est[[g]] :
  la taille d'un objet plus long n'est pas multiple de la taille d'un objet plus court

> fit <- sem(model, data=fl,ordered=c("q96_1","q96_2","q96_3"))
> des <- svydesign(ids=~1, data=fl, weights=~wreg)
> fit.survey <- lavaan.survey(fit, des,)

# fit not taking into account the sampling design # here I get the right estimator #
> fit
lavaan (0.5-16) converged normally after  12 iterations

  Number of observations                          1036

  Estimator                                       DWLS      Robust
  Minimum Function Test Statistic                0.000       0.000
  Degrees of freedom                                 0           0
  P-value (Chi-square)                           0.000       0.000
  Scaling correction factor                                     NA
  Shift parameter                                    
    for simple second-order correction (Mplus variant)

# fit taking into account the sampling design #  I don't have the right estimator anymore #
> fit.survey
lavaan (0.5-16) converged normally after  24 iterations

  Number of observations                          1036

  Estimator                                         ML      Robust
  Minimum Function Test Statistic                0.000       0.000
  Degrees of freedom                                 0           0
  P-value (Chi-square)                           1.000       1.000
  Scaling correction factor                                     NA
    for the Satorra-Bentler correction

yrosseel

unread,
Jul 1, 2014, 4:18:08 AM7/1/14
to lav...@googlegroups.com
On 06/30/2014 03:10 PM, Lucie L wrote:
>
> I want to fit a CFA with one latent variable and three categorical
> indicators. This model is just-identified (DF=0). My indicators have 5
> categories and are not normally distributed, so I should use DWLS
> estimator. My sample needs to be weighted, so I use the lavaan.survey
> package and include weights.

I am afraid the survey package (and therefore, the lavaan.survey
package) does not handle categorical data...

> First of all, I tried fitting this model with lavaan command

You should first learn how to use the 'lavaan()' function outside
lavaan.survey. Have your read the lavaan paper? You must add all model
parameters to your model syntax yourself (or use auto.* arguments).

> Second, I tried fitting this model using sem command. Here I had to
> error message, but the model was estimated using MLM instead of DWLS.

This is because lavaan.survey does not handle categorical data.

If your 5-category items are not too heavily skewed, I would use
estimator="MLR" (and treat them as continuous).

If you must treat them as categorical, and you need to use the weights,
I am afraid lavaan.survey is not able to help you (for now).

Yves.

Lucie L

unread,
Jul 2, 2014, 1:37:43 PM7/2/14
to lav...@googlegroups.com
Many thanks Yves!


Lucie L

unread,
Jul 7, 2014, 8:43:44 AM7/7/14
to lav...@googlegroups.com
Is the difference between weighted and unweighted results important in CFA?

Yves Rosseel

unread,
Jul 8, 2014, 8:39:44 AM7/8/14
to lav...@googlegroups.com
On 07/07/2014 02:43 PM, Lucie L wrote:
> Is the difference between weighted and unweighted results important in CFA?

It depends. Sometimes, you hardly notice the differences. Sometimes, the
differences are substantial.

Yves.

henriet...@gmail.com

unread,
Jan 21, 2015, 7:52:20 AM1/21/15
to lav...@googlegroups.com
I have a similar problem. I conducted a survey in eight representative country samples (n>1000 in each group) and used a questionnaire with 21-items (4-point-likert-scale). All of the items are heavily skewed to the left. That's why I tried to use lavaan.survey with categorical data and was confronted with the same problem as Lucie. Is there any chance that lavaan.survey will be updated for categorical data soon?

And how should I treat the items in the meantime? Treat them categorically, but leave out the survey weights? Or treat them continuously and ignore the non-normality? And how would I argue?

To argue to leave out the survey weights, I thought about comparing the cfa model fits with and without survey weights within each country. If I don't come across a siginificant difference, I could use categorical data, but leave out the survey weights, couldn't I?

Helpful recommendations are more than welcome :-)

yrosseel

unread,
Jan 25, 2015, 9:14:53 AM1/25/15
to lav...@googlegroups.com
On 01/21/2015 01:52 PM, henriet...@gmail.com wrote:
> Is there any chance
> that lavaan.survey will be updated for categorical data soon?

No. The reason is that lavaan.survey relies on survey, and the latter
does not (and probably never will) support categorical data.

So in order to get support for categorical data in lavaan.survey, we
will have to program everything ourselves. This will happen one day. But
not soon.

> To argue to leave out the survey weights, I thought about comparing the
> cfa model fits with and without survey weights within each country. If I
> don't come across a siginificant difference, I could use categorical
> data, but leave out the survey weights, couldn't I?

That seems to me like a reasonable approach.

Of course, you may want to choose other software. Mplus can do this. And
if you have access to Stata, you can try out gllamm.

Yves.

henriet...@gmail.com

unread,
Jan 26, 2015, 3:28:55 AM1/26/15
to lav...@googlegroups.com
Thanks!
Reply all
Reply to author
Forward
0 new messages