estimator for a model

116 views
Skip to first unread message

tonyto...@gmail.com

unread,
Jun 16, 2016, 5:31:36 AM6/16/16
to lavaan
Hello,

I am testing a cfa model using lavaan. My questionnaire includes 2 factors with 29 items. These items were rated in 3-likert scale ranging from 0 to 2. Are these items categorical? If true which estimator should I use to fit my model?

Thanks you,
Kind regards,
Tony

Cécile Adam

unread,
Jun 16, 2016, 5:43:37 AM6/16/16
to lavaan

On Thursday, 16 June 2016 11:31:36 UTC+2, tonyto...@gmail.com wrote:
Hello,

I am testing a cfa model using lavaan. My questionnaire includes 2 factors with 29 items. These items were rated in 3-likert scale ranging from 0 to 2. Are these items categorical?

Yes
 
If true which estimator should I use to fit my model?


I think that you can use the WLSMV. But I know that there are other estimators. 
So you can write your model, write the name of your variables in a vector (varcat=c("name1","name2","name3",...) and after you can use the cfa function : 

cfa(model, ordered=varcat, estimator="WLSMV",data=data)

tonyto...@gmail.com

unread,
Jun 16, 2016, 8:51:54 AM6/16/16
to lavaan
Thanks Cécile. 
Because I am new to SEM, could you write me a code for 2 factors? Because I have 2 factors in my model in which the first has 14 items and the rest has 15 item.  

Cécile Adam

unread,
Jun 16, 2016, 11:09:04 AM6/16/16
to lavaan
model1<-"factor1 = ~ x1 + x2 + x3 + ...
factor2 = ~ y1 + y2 + y3 + ... 
"

mode2l<-"factor1 = ~ NA*x1 + x2 + x3 + ...
factor2 = ~ NA*y1 + y2 + y3 + ... 
factor1~~1*factor1
factor2~~1*factor2
"
If you write model1, lava an by default assume the first factor loading is fixed to 1 and the variance of the latent variable is freely estimated. If you want you can freely estimate the first factor loading and fix the factor variance to 1 it is "model2"


tonyto...@gmail.com

unread,
Jun 16, 2016, 12:25:58 PM6/16/16
to lavaan
Thanks Cécile :)

tonyto...@gmail.com

unread,
Jul 5, 2016, 6:54:57 PM7/5/16
to lavaan
Hello
Does anyone help me solve these problems as following

> fitAtt<-cfa(modelAtt,order=varcatAtt,data=Att)
There were 50 or more warnings (use warnings() to see the first 50)
> summary(modelAtt,fit.measures=T,standardized=T,rsquare=T)
   Length     Class      Mode 
        1 character character


On Thursday, June 16, 2016 at 5:09:04 PM UTC+2, Cécile Adam wrote:

Edward Rigdon

unread,
Jul 5, 2016, 7:41:26 PM7/5/16
to lav...@googlegroups.com
In your >summary() function statement, the first term inside the parentheses should be the output object fitAtt, not the model modelAtt. You do not provide your Mel syntax, so it is hard to diagnose the first "50 warnings" message. But, given that you have at least one ordinal observed variable, these may all be warnings about empty cells in invariants crosstabs.  As the message says, use >warnings() to see what the warnings are.
--Ed Rigdon
--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

tonyto...@gmail.com

unread,
Aug 4, 2016, 6:32:46 AM8/4/16
to lavaan
Thanks Edward,

I built another model which is:

modelAtt <- 'AL =~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8
AP =~ x9 + x10 + x11 + x12 + x13
SO =~ x14 + x15 + x16
AL~~AP
AL~~SO
AP~~SO'

varcat = c("x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15", "x16" )

fitAtt <- cfa(modelAtt, order = varcat, estimator = "WLSMV", data = myData)

After running cfa it appeared a warning message that is "There were 50 or more warnings (use warnings() to see the first 50)". Then I used >warning() to see what the warnings are but there is only an output that is "Warning message:"

Do you know how to solve this problem?

On Wednesday, July 6, 2016 at 1:41:26 AM UTC+2, Edward Rigdon wrote:
In your >summary() function statement, the first term inside the parentheses should be the output object fitAtt, not the model modelAtt. You do not provide your Mel syntax, so it is hard to diagnose the first "50 warnings" message. But, given that you have at least one ordinal observed variable, these may all be warnings about empty cells in invariants crosstabs.  As the message says, use >warnings() to see what the warnings are.
--Ed Rigdon

On Tuesday, July 5, 2016, <tonyto...@gmail.com> wrote:
Hello
Does anyone help me solve these problems as following

> fitAtt<-cfa(modelAtt,order=varcatAtt,data=Att)
There were 50 or more warnings (use warnings() to see the first 50)
> summary(modelAtt,fit.measures=T,standardized=T,rsquare=T)
   Length     Class      Mode 
        1 character character


On Thursday, June 16, 2016 at 5:09:04 PM UTC+2, Cécile Adam wrote:
model1<-"factor1 = ~ x1 + x2 + x3 + ...
factor2 = ~ y1 + y2 + y3 + ... 
"

mode2l<-"factor1 = ~ NA*x1 + x2 + x3 + ...
factor2 = ~ NA*y1 + y2 + y3 + ... 
factor1~~1*factor1
factor2~~1*factor2
"
If you write model1, lava an by default assume the first factor loading is fixed to 1 and the variance of the latent variable is freely estimated. If you want you can freely estimate the first factor loading and fix the factor variance to 1 it is "model2"


--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+unsubscribe@googlegroups.com.

tonyto...@gmail.com

unread,
Aug 4, 2016, 8:01:19 AM8/4/16
to lavaan
And below is the warning messages

> warnings()

Warning messages:

1: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X2 x X1

2: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X3 x X1

3: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X4 x X1

4: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X5 x X1

5: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X6 x X1

6: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X7 x X1

7: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X8 x X1

8: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X9 x X1

9: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X10 x X1

10: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X11 x X1

11: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X12 x X1

12: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X13 x X1

13: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X14 x X1

14: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X15 x X1

15: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X16 x X1

16: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X3 x X2

17: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X4 x X2

18: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X5 x X2

19: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X6 x X2

20: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X7 x X2

21: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X8 x X2

22: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X9 x X2

23: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X10 x X2

24: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X11 x X2

25: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X12 x X2

26: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X13 x X2

27: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X14 x X2

28: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X15 x X2

29: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X16 x X2

30: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X4 x X3

31: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X5 x X3

32: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X6 x X3

33: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X7 x X3

34: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X8 x X3

35: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X9 x X3

36: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X10 x X3

37: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X11 x X3

38: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X12 x X3

39: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X13 x X3

40: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X14 x X3

41: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X15 x X3

42: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X16 x X3

43: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X5 x X4

44: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X6 x X4

45: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X7 x X4

46: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X8 x X4

47: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X9 x X4

48: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X10 x X4

49: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X11 x X4

50: In pc_cor_TS(fit.y1 = FIT[[i]], fit.y2 = FIT[[j]], method = optim.method,  ... :

  lavaan WARNING: empty cell(s) in bivariate table of X12 x X4


I don't know how to explain this problem. Do you know how to solve it?

Terrence Jorgensen

unread,
Aug 6, 2016, 3:17:31 PM8/6/16
to lavaan
Do you know how to solve this problem?

This is typical when you have several categorical indicators.  You would need an astronomical sample size to observe no zeros in any of the 2-way tables.  lavaan already makes a correction by default so that the model will still run, but the test statistic will no longer be distributed as chi-squared.  That's why you should pay attention to the "robust" column in the summary() output.

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

Torres

unread,
Aug 8, 2016, 5:11:19 AM8/8/16
to lavaan
Thanks Terrence. In that case is it possible to use modification indices to adjust my model? I mean I will use modindices(). If not could you show me other ways to adjust my model since my model is weak fit to my dataset? 

Vào 21:17:31 UTC+2 Thứ Bảy, ngày 06 tháng 8 năm 2016, Terrence Jorgensen đã viết:
Reply all
Reply to author
Forward
0 new messages