- Set directory and load data
setwd("~/Google Drive/work/cost benefit UG/new design with Max/analysis/data")
sub_emo = read.csv("EFA_emotion.csv")
head(sub_emo)
## X happy grateful surprised angry annoyed disgust
## 1 1 3 2 4 1 1 1
## 2 2 4 1 1 2 2 2
## 3 3 5 5 5 2 2 2
## 4 4 6 5 6 1 1 1
## 5 5 1 1 6 5 6 4
## 6 6 5 5 4 2 2 2
- PCA to decide the number of factors
fit <- princomp(sub_emo, cor=TRUE)
summary(fit) # print variance accounted for
## Importance of components:
## Comp.1 Comp.2 Comp.3 Comp.4 Comp.5
## Standard deviation 1.9658535 1.0996762 0.9922451 0.71626954 0.4411024
## Proportion of Variance 0.5520829 0.1727554 0.1406500 0.07329172 0.0277959
## Cumulative Proportion 0.5520829 0.7248383 0.8654883 0.93878003 0.9665759
## Comp.6 Comp.7
## Standard deviation 0.3723889 0.30869885
## Proportion of Variance 0.0198105 0.01361357
## Cumulative Proportion 0.9863864 1.00000000
plot(fit) # scree plot

- Find out the factors
fit1 <- factanal(sub_emo, 2, rotation="varimax")
fit1
##
## Call:
## factanal(x = sub_emo, factors = 2, rotation = "varimax")
##
## Uniquenesses:
## X happy grateful surprised angry annoyed disgust
## 0.989 0.154 0.116 0.814 0.243 0.098 0.099
##
## Loadings:
## Factor1 Factor2
## X -0.102
## happy -0.685 0.615
## grateful -0.557 0.758
## surprised 0.425
## angry 0.868
## annoyed 0.942 -0.125
## disgust 0.949
##
## Factor1 Factor2
## SS loadings 3.335 1.152
## Proportion Var 0.476 0.165
## Cumulative Var 0.476 0.641
##
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 30.54 on 8 degrees of freedom.
## The p-value is 0.00017
fit2 <- factanal(sub_emo, 3, rotation="varimax")
fit2
##
## Call:
## factanal(x = sub_emo, factors = 3, rotation = "varimax")
##
## Uniquenesses:
## X happy grateful surprised angry annoyed disgust
## 0.968 0.005 0.151 0.776 0.245 0.104 0.089
##
## Loadings:
## Factor1 Factor2 Factor3
## X 0.168
## happy -0.527 0.594 0.604
## grateful -0.494 0.738 0.245
## surprised 0.464
## angry 0.830 -0.247
## annoyed 0.890 -0.141 -0.290
## disgust 0.925 -0.229
##
## Factor1 Factor2 Factor3
## SS loadings 2.866 1.140 0.656
## Proportion Var 0.409 0.163 0.094
## Cumulative Var 0.409 0.572 0.666
##
## Test of the hypothesis that 3 factors are sufficient.
## The chi square statistic is 3.57 on 3 degrees of freedom.
## The p-value is 0.312