library(readr)
palesa <- read_csv("~/SA projects 2019/Palesa/palesa.csv")
## Parsed with column specification:
## cols(
## .default = col_double()
## )
## See spec(...) for full column specifications.
View(palesa)
attach(palesa)
library(factoextra)
## Loading required package: ggplot2
## Welcome! Related Books: `Practical Guide To Cluster Analysis in R` at https://goo.gl/13EFCZ
library(FactoMineR)
library(ggplot2)
Explanatory factor analysis
##screen plot , determining the number of factors or components in form of dimensions to be considered
res.pca <- prcomp(palesa, scale = TRUE)
fviz_eig(res.pca)
fviz_pca_var(res.pca,
col.var = "contrib", # Color by contributions to the PC
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
fviz_pca_ind(res.pca,
col.ind = "cos2", # Color by the quality of representation
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
eig.val <- get_eigenvalue(res.pca)
eig.val
## eigenvalue variance.percent cumulative.variance.percent
## Dim.1 8.3806115 20.9515287 20.95153
## Dim.2 5.1447173 12.8617933 33.81332
## Dim.3 2.3281839 5.8204597 39.63378
## Dim.4 2.2825452 5.7063630 45.34014
## Dim.5 1.9579385 4.8948462 50.23499
## Dim.6 1.6208110 4.0520274 54.28702
## Dim.7 1.4295662 3.5739154 57.86093
## Dim.8 1.2416808 3.1042021 60.96514
## Dim.9 1.1555590 2.8888974 63.85403
## Dim.10 1.0919434 2.7298584 66.58389
## Dim.11 0.9816508 2.4541271 69.03802
## Dim.12 0.9299958 2.3249895 71.36301
## Dim.13 0.9142304 2.2855760 73.64858
## Dim.14 0.8415106 2.1037765 75.75236
## Dim.15 0.7278662 1.8196654 77.57203
## Dim.16 0.6807511 1.7018778 79.27390
## Dim.17 0.6688090 1.6720225 80.94593
## Dim.18 0.6398645 1.5996612 82.54559
## Dim.19 0.6043906 1.5109765 84.05656
## Dim.20 0.5644797 1.4111992 85.46776
## Dim.21 0.5314119 1.3285297 86.79629
## Dim.22 0.4864240 1.2160601 88.01235
## Dim.23 0.4550320 1.1375800 89.14993
## Dim.24 0.4389375 1.0973438 90.24728
## Dim.25 0.4021427 1.0053567 91.25263
## Dim.26 0.3794379 0.9485947 92.20123
## Dim.27 0.3409760 0.8524400 93.05367
## Dim.28 0.3223255 0.8058137 93.85948
## Dim.29 0.2960404 0.7401011 94.59958
## Dim.30 0.2767107 0.6917767 95.29136
## Dim.31 0.2713111 0.6782778 95.96964
## Dim.32 0.2489277 0.6223192 96.59196
## Dim.33 0.2260104 0.5650261 97.15698
## Dim.34 0.2070957 0.5177392 97.67472
## Dim.35 0.1936353 0.4840881 98.15881
## Dim.36 0.1902621 0.4756551 98.63447
## Dim.37 0.1566239 0.3915598 99.02602
## Dim.38 0.1448791 0.3621977 99.38822
## Dim.39 0.1380196 0.3450491 99.73327
## Dim.40 0.1066913 0.2667283 100.00000
library(nFactors)
## Loading required package: MASS
## Loading required package: psych
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
## Loading required package: boot
##
## Attaching package: 'boot'
## The following object is masked from 'package:psych':
##
## logit
## Loading required package: lattice
##
## Attaching package: 'lattice'
## The following object is masked from 'package:boot':
##
## melanoma
##
## Attaching package: 'nFactors'
## The following object is masked from 'package:lattice':
##
## parallel
library(psych)
Non graphical solution to screen test
ev<-eigen(cor(palesa))
ap<-parallel(subject=nrow(palesa),var=ncol(palesa),rep=100,cent=.05)
nS<-nScree(x=ev$values,parallel=ap$eigen$qevpea)
plotnScree(nS)
fac<-factanal(palesa,10,rotation="varimax")
print(fac,digits = 2,cutoff=.3,sort=TRUE)
##
## Call:
## factanal(x = palesa, factors = 10, rotation = "varimax")
##
## Uniquenesses:
## Q10_1 Q10_2 Q10_3 Q10_4 Q11_1 Q11_2 Q11_3 Q11_4 Q11_5 Q11_6
## 0.15 0.34 0.13 0.22 0.55 0.74 0.38 0.38 0.83 0.38
## Q11_7 Q11_8 Q11_9 Q11_10 Q11_11 Q11_12 Q11_13 Q11_14 Q11_15 Q12_1
## 0.34 0.35 0.31 0.68 0.36 0.23 0.28 0.25 0.38 0.25
## Q12_2 Q12_3 Q12_4 Q12_5 Q12_6 Q12_7 Q13_1 Q13_2 Q13_3 Q13_4
## 0.44 0.50 0.57 0.54 0.71 0.70 0.77 0.90 0.36 0.57
## Q13_5 Q14_1 Q14_2 Q14_3 Q14_4 Q14_5 Q14_6 Q14_7 Q14_8 Q14_9
## 0.17 0.72 0.38 0.57 0.62 0.28 0.35 0.38 0.36 0.28
##
## Loadings:
## Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7 Factor8
## Q11_1 0.58
## Q11_3 0.74
## Q11_4 0.71
## Q11_8 0.68
## Q14_2 0.76
## Q14_3 0.61
## Q14_7 0.58
## Q14_8 0.61 0.36
## Q14_9 0.76
## Q12_1 0.79
## Q12_2 0.59
## Q12_3 0.67
## Q12_5 0.52
## Q13_3 0.75
## Q13_4 0.59
## Q13_5 0.88
## Q10_1 0.86
## Q10_2 0.68
## Q10_3 0.87
## Q10_4 0.57
## Q11_11 0.70
## Q11_12 0.72 0.30
## Q11_6 -0.32 0.55
## Q11_7 0.66
## Q11_9 -0.53 0.57
## Q11_13 0.35 0.65
## Q11_14 0.76
## Q11_15 -0.33 0.58
## Q14_5
## Q14_6 0.41
## Q11_2 0.34
## Q11_5 0.32
## Q11_10 0.46
## Q12_4 0.39 -0.43
## Q12_6 0.44
## Q12_7 0.33
## Q13_1 0.41
## Q13_2
## Q14_1 0.31 0.35
## Q14_4 -0.48
## Factor9 Factor10
## Q11_1
## Q11_3
## Q11_4
## Q11_8
## Q14_2
## Q14_3
## Q14_7 0.48
## Q14_8
## Q14_9
## Q12_1
## Q12_2
## Q12_3
## Q12_5
## Q13_3
## Q13_4
## Q13_5
## Q10_1
## Q10_2 0.35
## Q10_3
## Q10_4 0.39 0.47
## Q11_11
## Q11_12
## Q11_6
## Q11_7
## Q11_9
## Q11_13
## Q11_14
## Q11_15
## Q14_5 0.74
## Q14_6 0.62
## Q11_2
## Q11_5
## Q11_10
## Q12_4
## Q12_6
## Q12_7
## Q13_1
## Q13_2
## Q14_1
## Q14_4
##
## Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7
## SS loadings 3.44 3.08 2.75 2.75 2.58 1.83 1.82
## Proportion Var 0.09 0.08 0.07 0.07 0.06 0.05 0.05
## Cumulative Var 0.09 0.16 0.23 0.30 0.37 0.41 0.46
## Factor8 Factor9 Factor10
## SS loadings 1.81 1.63 0.60
## Proportion Var 0.05 0.04 0.01
## Cumulative Var 0.50 0.54 0.56
##
## Test of the hypothesis that 10 factors are sufficient.
## The chi square statistic is 656 on 425 degrees of freedom.
## The p-value is 3.89e-12
Section by Section
Daughter (Gender) Factors
daughter<-palesa[,1:4]
names(daughter)
## [1] "Q10_1" "Q10_2" "Q10_3" "Q10_4"
##screen plot , determining the number of factors or components in form of dimensions to be considered
res.pca <- prcomp(daughter, scale = TRUE)
fviz_eig(res.pca)
fviz_pca_var(res.pca,
col.var = "contrib", # Color by contributions to the PC
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
fviz_pca_ind(res.pca,
col.ind = "cos2", # Color by the quality of representation
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
eig.val <- get_eigenvalue(res.pca)
eig.val
## eigenvalue variance.percent cumulative.variance.percent
## Dim.1 2.7517025 68.792562 68.79256
## Dim.2 0.7539416 18.848539 87.64110
## Dim.3 0.3462810 8.657025 96.29813
## Dim.4 0.1480750 3.701875 100.00000
library(nFactors)
library(psych)
Non graphical solution to screen test
ev<-eigen(cor(daughter))
ap<-parallel(subject=nrow(daughter),var=ncol(daughter),rep=100,cent=.05)
nS<-nScree(x=ev$values,parallel=ap$eigen$qevpea)
plotnScree(nS)
fac<-factanal(daughter,1,rotation="varimax")
print(fac,digits = 2,cutoff=.3,sort=TRUE)
##
## Call:
## factanal(x = daughter, factors = 1, rotation = "varimax")
##
## Uniquenesses:
## Q10_1 Q10_2 Q10_3 Q10_4
## 0.19 0.54 0.12 0.78
##
## Loadings:
## [1] 0.90 0.68 0.94 0.47
##
## Factor1
## SS loadings 2.37
## Proportion Var 0.59
##
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 44.04 on 2 degrees of freedom.
## The p-value is 2.74e-10
Family member relationship
family_member<-palesa[,5:19]
names(family_member)
## [1] "Q11_1" "Q11_2" "Q11_3" "Q11_4" "Q11_5" "Q11_6" "Q11_7"
## [8] "Q11_8" "Q11_9" "Q11_10" "Q11_11" "Q11_12" "Q11_13" "Q11_14"
## [15] "Q11_15"
##screen plot , determining the number of factors or components in form of dimensions to be considered
res.pca <- prcomp(family_member, scale = TRUE)
fviz_eig(res.pca)
fviz_pca_var(res.pca,
col.var = "contrib", # Color by contributions to the PC
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
fviz_pca_ind(res.pca,
col.ind = "cos2", # Color by the quality of representation
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
eig.val <- get_eigenvalue(res.pca)
eig.val
## eigenvalue variance.percent cumulative.variance.percent
## Dim.1 6.0641302 40.427535 40.42753
## Dim.2 1.5217284 10.144856 50.57239
## Dim.3 1.2179730 8.119820 58.69221
## Dim.4 1.0540203 7.026802 65.71901
## Dim.5 0.8235429 5.490286 71.20930
## Dim.6 0.7671298 5.114198 76.32350
## Dim.7 0.6542991 4.361994 80.68549
## Dim.8 0.5268727 3.512484 84.19797
## Dim.9 0.5001833 3.334555 87.53253
## Dim.10 0.4461602 2.974401 90.50693
## Dim.11 0.3832157 2.554772 93.06170
## Dim.12 0.3165613 2.110409 95.17211
## Dim.13 0.2772876 1.848584 97.02070
## Dim.14 0.2534219 1.689479 98.71018
## Dim.15 0.1934737 1.289825 100.00000
library(nFactors)
library(psych)
Non graphical solution to screen test
ev<-eigen(cor(family_member))
ap<-parallel(subject=nrow(family_member),var=ncol(family_member),rep=100,cent=.05)
nS<-nScree(x=ev$values,parallel=ap$eigen$qevpea)
plotnScree(nS)
fac<-factanal(family_member,4,rotation="varimax")
print(fac,digits = 2,cutoff=.3,sort=TRUE)
##
## Call:
## factanal(x = family_member, factors = 4, rotation = "varimax")
##
## Uniquenesses:
## Q11_1 Q11_2 Q11_3 Q11_4 Q11_5 Q11_6 Q11_7 Q11_8 Q11_9 Q11_10
## 0.58 0.79 0.36 0.43 0.89 0.35 0.35 0.43 0.36 0.69
## Q11_11 Q11_12 Q11_13 Q11_14 Q11_15
## 0.50 0.00 0.37 0.13 0.41
##
## Loadings:
## Factor1 Factor2 Factor3 Factor4
## Q11_1 0.55
## Q11_3 0.78
## Q11_4 0.70
## Q11_8 0.68
## Q11_6 -0.30 0.68
## Q11_7 0.75
## Q11_9 -0.51 0.56
## Q11_13 0.59 0.42
## Q11_14 0.90
## Q11_15 -0.31 0.63
## Q11_11 0.59
## Q11_12 0.93
## Q11_2 0.32
## Q11_5
## Q11_10 0.47
##
## Factor1 Factor2 Factor3 Factor4
## SS loadings 2.76 1.93 1.85 1.80
## Proportion Var 0.18 0.13 0.12 0.12
## Cumulative Var 0.18 0.31 0.44 0.56
##
## Test of the hypothesis that 4 factors are sufficient.
## The chi square statistic is 76.71 on 51 degrees of freedom.
## The p-value is 0.0114
Owner- Manager and Daughter relationship
owner<-palesa[,20:26]
names(owner)
## [1] "Q12_1" "Q12_2" "Q12_3" "Q12_4" "Q12_5" "Q12_6" "Q12_7"
##screen plot , determining the number of factors or components in form of dimensions to be considered
res.pca <- prcomp(owner, scale = TRUE)
fviz_eig(res.pca)
fviz_pca_var(res.pca,
col.var = "contrib", # Color by contributions to the PC
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
fviz_pca_ind(res.pca,
col.ind = "cos2", # Color by the quality of representation
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
eig.val <- get_eigenvalue(res.pca)
eig.val
## eigenvalue variance.percent cumulative.variance.percent
## Dim.1 3.0749174 43.927392 43.92739
## Dim.2 0.9897258 14.138941 58.06633
## Dim.3 0.8434506 12.049295 70.11563
## Dim.4 0.7054446 10.077780 80.19341
## Dim.5 0.5746272 8.208960 88.40237
## Dim.6 0.5122142 7.317346 95.71971
## Dim.7 0.2996201 4.280287 100.00000
library(nFactors)
library(psych)
Non graphical solution to screen test
ev<-eigen(cor(owner))
ap<-parallel(subject=nrow(owner),var=ncol(owner),rep=100,cent=.05)
nS<-nScree(x=ev$values,parallel=ap$eigen$qevpea)
plotnScree(nS)
fac<-factanal(owner,3,rotation="varimax")
print(fac,digits = 2,cutoff=.3,sort=TRUE)
##
## Call:
## factanal(x = owner, factors = 3, rotation = "varimax")
##
## Uniquenesses:
## Q12_1 Q12_2 Q12_3 Q12_4 Q12_5 Q12_6 Q12_7
## 0.14 0.37 0.46 0.65 0.54 0.76 0.68
##
## Loadings:
## Factor1 Factor2 Factor3
## Q12_1 0.66 0.65
## Q12_2 0.75
## Q12_3 0.54 0.42
## Q12_4 -0.52
## Q12_5 0.58
## Q12_7 0.54
## Q12_6 0.33
##
## Factor1 Factor2 Factor3
## SS loadings 1.25 1.13 1.03
## Proportion Var 0.18 0.16 0.15
## Cumulative Var 0.18 0.34 0.49
##
## Test of the hypothesis that 3 factors are sufficient.
## The chi square statistic is 1.89 on 3 degrees of freedom.
## The p-value is 0.596
Business context factors
business<-palesa[,27:31]
names(business)
## [1] "Q13_1" "Q13_2" "Q13_3" "Q13_4" "Q13_5"
##screen plot , determining the number of factors or components in form of dimensions to be considered
res.pca <- prcomp(business, scale = TRUE)
fviz_eig(res.pca)
fviz_pca_var(res.pca,
col.var = "contrib", # Color by contributions to the PC
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
fviz_pca_ind(res.pca,
col.ind = "cos2", # Color by the quality of representation
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
eig.val <- get_eigenvalue(res.pca)
eig.val
## eigenvalue variance.percent cumulative.variance.percent
## Dim.1 2.2351800 44.70360 44.70360
## Dim.2 1.0162142 20.32428 65.02788
## Dim.3 0.9474680 18.94936 83.97724
## Dim.4 0.5464129 10.92826 94.90550
## Dim.5 0.2547250 5.09450 100.00000
library(nFactors)
library(psych)
Non graphical solution to screen test
ev<-eigen(cor(business))
ap<-parallel(subject=nrow(business),var=ncol(business),rep=100,cent=.05)
nS<-nScree(x=ev$values,parallel=ap$eigen$qevpea)
plotnScree(nS)
fac<-factanal(business,2,rotation="varimax")
print(fac,digits = 2,cutoff=.3,sort=TRUE)
##
## Call:
## factanal(x = business, factors = 2, rotation = "varimax")
##
## Uniquenesses:
## Q13_1 Q13_2 Q13_3 Q13_4 Q13_5
## 0.99 0.00 0.50 0.59 0.02
##
## Loadings:
## Factor1 Factor2
## Q13_3 0.69
## Q13_4 0.64
## Q13_5 0.99
## Q13_2 1.00
## Q13_1
##
## Factor1 Factor2
## SS loadings 1.87 1.03
## Proportion Var 0.37 0.21
## Cumulative Var 0.37 0.58
##
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 0.37 on 1 degree of freedom.
## The p-value is 0.546
Succession Planning
success<-palesa[,32:40]
names(success)
## [1] "Q14_1" "Q14_2" "Q14_3" "Q14_4" "Q14_5" "Q14_6" "Q14_7" "Q14_8" "Q14_9"
##screen plot , determining the number of factors or components in form of dimensions to be considered
res.pca <- prcomp(success, scale = TRUE)
fviz_eig(res.pca)
fviz_pca_var(res.pca,
col.var = "contrib", # Color by contributions to the PC
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
fviz_pca_ind(res.pca,
col.ind = "cos2", # Color by the quality of representation
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
eig.val <- get_eigenvalue(res.pca)
eig.val
## eigenvalue variance.percent cumulative.variance.percent
## Dim.1 4.0509982 45.011091 45.01109
## Dim.2 1.2636735 14.040817 59.05191
## Dim.3 0.9823733 10.915258 69.96717
## Dim.4 0.7259545 8.066161 78.03333
## Dim.5 0.6954309 7.727010 85.76034
## Dim.6 0.3905132 4.339035 90.09937
## Dim.7 0.3815092 4.238991 94.33836
## Dim.8 0.3037666 3.375184 97.71355
## Dim.9 0.2057808 2.286453 100.00000
library(nFactors)
library(psych)
Non graphical solution to screen test
ev<-eigen(cor(success))
ap<-parallel(subject=nrow(success),var=ncol(success),rep=100,cent=.05)
nS<-nScree(x=ev$values,parallel=ap$eigen$qevpea)
plotnScree(nS)
fac<-factanal(success,4,rotation="varimax")
print(fac,digits = 2,cutoff=.3,sort=TRUE)
##
## Call:
## factanal(x = success, factors = 4, rotation = "varimax")
##
## Uniquenesses:
## Q14_1 Q14_2 Q14_3 Q14_4 Q14_5 Q14_6 Q14_7 Q14_8 Q14_9
## 0.00 0.18 0.61 0.87 0.40 0.21 0.42 0.00 0.31
##
## Loadings:
## Factor1 Factor2 Factor3 Factor4
## Q14_5 0.72
## Q14_6 0.83
## Q14_7 0.56 0.33 0.38
## Q14_2 0.88
## Q14_3 0.57
## Q14_9 0.33 0.57 0.50
## Q14_8 0.30 0.90
## Q14_1 0.96
## Q14_4
##
## Factor1 Factor2 Factor3 Factor4
## SS loadings 1.87 1.75 1.32 1.05
## Proportion Var 0.21 0.19 0.15 0.12
## Cumulative Var 0.21 0.40 0.55 0.66
##
## Test of the hypothesis that 4 factors are sufficient.
## The chi square statistic is 16.4 on 6 degrees of freedom.
## The p-value is 0.0118