Advertisement
titounnes

cfa_program

Feb 16th, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. vs = as.numeric(R.version$major)+as.numeric(R.version$minor)
  2. if(vs < 3.5){
  3. cat(paste("Minimun version is 3.5. Your R version is", vs,"\n"))
  4. quit()
  5. }
  6.  
  7. # Menginstall package
  8. for(p in c('lavaan')){
  9. if(!require(p,character.only = TRUE)) install.packages(p)
  10. library(p,character.only = TRUE)
  11. }
  12.  
  13. # Membaca data
  14. myData = read.csv('sample.csv')
  15. myData
  16.  
  17. # Menyusun Model
  18. myModel <- '
  19. f1 =~ x1 + x2 + x3
  20. f2 =~ x4 + x5 + x6
  21. f3 =~ x7 + x8 + x9
  22. '
  23.  
  24. Menjalankan analisis
  25. fit <- cfa(model = myModel, data = myData)
  26. summary(fit, fit.measures = TRUE)
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement