Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. v1 <- c(1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,4,5,6)
  2. v2 <- c(1,2,1,1,1,1,2,1,2,1,3,4,3,3,3,4,6,5)
  3. v3 <- c(3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,5,4,6)
  4. v4 <- c(3,3,4,3,3,1,1,2,1,1,1,1,2,1,1,5,6,4)
  5. v5 <- c(1,1,1,1,1,3,3,3,3,3,1,1,1,1,1,6,4,5)
  6. v6 <- c(1,1,1,2,1,3,3,3,4,3,1,1,1,2,1,6,5,4)
  7. m1 <- cbind(v1,v2,v3,v4,v5,v6)
  8. cor(m1)
  9. factanal(m1, factors = 3) # varimax is the default
  10. factanal(m1, factors = 3, rotation = "promax")
  11. # The following shows the g factor as PC1
  12. prcomp(m1) # signs may depend on platform
  13.  
  14. ## formula interface
  15. factanal(~v1+v2+v3+v4+v5+v6, factors = 3,
  16. scores = "Bartlett")$scores
  17.  
  18. factanal(~v1+v2+v3+v4+v5+v6, factors = 3,
  19. scores = "Bartlett")$scores[,1]
  20.  
  21. factor1scores <- factor1$scores[,1]
  22. data1 <- cbind(data, factor1scores)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement