[R] Running SEM

shahram salehi zadeh tr@|ner914 @end|ng |rom y@hoo@com
Sat Jun 20 14:40:41 CEST 2020


I have a problem running SEM using lavaan. I have 44 items on likert scale. I would like to develop a model containing two latent factors. This is the model I have constructed:
library(lavaan)
library(sem)
library(haven)
getwd()
View(Dissertation)
kashk <- c(Dissertation$Q1, Dissertation$Q2, Dissertation$Q3, Dissertation$Q4, Dissertation$Q5,
               Dissertation$Q6, Dissertation$Q7, Dissertation$Q8, Dissertation$Q9, Dissertation$Q10, Dissertation$Q11,
               Dissertation$Q12, Dissertation$Q13, Dissertation$Q14, Dissertation$Q15, Dissertation$Q16, Dissertation$Q17, 
               Dissertation$Q18,
               Dissertation$Q19, Dissertation$Q20, Dissertation$Q21, 
               Dissertation$Q22, Dissertation$Q23, Dissertation$Q24, Dissertation$Q25, Dissertation$Q26,
               Dissertation$Q27, Dissertation$Q28, Dissertation$Q29, Dissertation$Q30, Dissertation$Q31,
               Dissertation$Q32, Dissertation$Q33, Dissertation$Q34, Dissertation$Q35, Dissertation$Q36,
               Dissertation$Q37, Dissertation$Q38, Dissertation$Q39, Dissertation$Q40, 
               Dissertation$Q41, Dissertation$Q42, Dissertation$Q43,Dissertation$Q44)cfa.model<- "F1=~  NA*Dissertation$Q39 + Dissertation$Q23 + Dissertation$Q38 + Dissertation$Q35 + 
Dissertation$Q31 +Dissertation$ Q21 +Dissertation$Q32 +
Dissertation$Q24 +Dissertation$Q4+ Dissertation$Q40 +Dissertation$Q14 +Dissertation$Q12 +Dissertation$Q17 +
Dissertation$Q7 +Dissertation$Q5 +Dissertation$Q30 +Dissertation$Q27 +Dissertation$Q8+ Dissertation$Q33
F2 =~ NA* Dissertation$Q36 +Dissertation$Q41 +Dissertation$Q16 +Dissertation$Q28+ Dissertation$Q19 +
Dissertation$Q25 +Dissertation$Q6+ Dissertation$Q44 +Dissertation$Q10+ Dissertation$Q29 +Dissertation$Q3
F1 ~~ F2
F1 ~~ 1*F1 #fix factor variance to 1
F2 ~~ 1*F2 #fix factor variance to 1"
cfa.fit <- sem(cfa.model, data =Dissertation)
summary(cfa.fit, fit.measures = TRUE)
However, it does not work. This is the following error: 
| Error in if ((!is.matrix(model)) | ncol(model) != 3) stop("model argument must be a 3-column matrix") : 
  argument is of length zero
 |
|  |
| 
| This is the final error:
| Error in summary(cfa.fit, fit.measures = TRUE) : 
  object 'cfa.fit' not found
 |
|  |
| 
| Please help me out of the problem. I hereby appreciate your kind help. |

 |


 |

 |




	[[alternative HTML version deleted]]



More information about the R-help mailing list