#Get rid of duplicated rows in data
#oJoggle1 = oJoggle[!duplicated(oJoggle$HNDid), ]
#save(oJoggle1,file='/Users/meganwilliams/Desktop/HANDLS/Joggle/Joggle PCA/oJoggle1.rdata')
Run PCA for oJoggle with Residual Scores
##Packages Used: “psych”, “GPArotation”, “nFactors”
load(file='/Users/meganwilliams/Desktop/HANDLS/Joggle/Joggle PCA/oJoggle1.rdata')
#install.packages("psych")
library("psych")
#install.packages("GPArotation")
library("GPArotation")
#install.packages("nFactors")
library("nFactors")
Initial Extraction of the Components
JogglePCA<-principal(oJoggle1,nfactors=8,rotate="none")
principal(r=oJoggle1,nfactors=8,rotate="none")
## Principal Components Analysis
## Call: principal(r = oJoggle1, nfactors = 8, rotate = "none")
## Standardized loadings (pattern matrix) based upon correlation matrix
## PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 h2 u2
## residNBack 0.37 0.62 -0.08 0.13 -0.68 -0.01 0.00 -0.01 1 4.4e-16
## residBART 0.05 -0.20 -0.18 0.96 0.03 0.04 0.09 -0.04 1 1.2e-15
## residVOLT 0.67 -0.16 0.41 -0.08 -0.02 0.11 0.45 -0.37 1 1.0e-15
## residDSST -0.10 0.68 0.51 0.21 0.42 0.20 -0.09 0.00 1 -6.7e-16
## residLOT 0.73 -0.01 -0.02 0.04 0.17 -0.37 -0.45 -0.30 1 7.8e-16
## residAM 0.61 -0.26 0.51 0.08 -0.09 -0.10 -0.06 0.52 1 1.2e-15
## oMPTspeed 0.64 -0.08 -0.35 -0.10 0.07 0.63 -0.20 0.05 1 2.2e-16
## oPVTefficiency 0.53 0.33 -0.49 -0.07 0.36 -0.24 0.35 0.22 1 1.9e-15
##
## PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8
## SS loadings 2.20 1.10 1.09 1.00 0.81 0.66 0.59 0.54
## Proportion Var 0.28 0.14 0.14 0.13 0.10 0.08 0.07 0.07
## Cumulative Var 0.28 0.41 0.55 0.67 0.78 0.86 0.93 1.00
## Proportion Explained 0.28 0.14 0.14 0.13 0.10 0.08 0.07 0.07
## Cumulative Proportion 0.28 0.41 0.55 0.67 0.78 0.86 0.93 1.00
##
## Test of the hypothesis that 8 components are sufficient.
##
## The degrees of freedom for the null model are 28 and the objective function was 0.79
## The degrees of freedom for the model are -8 and the objective function was 0
## The total number of observations was 1278 with MLE Chi Square = 0 with prob < NA
##
## Fit based upon off diagonal values = 1
Eigen Values
ev <- eigen(cor(oJoggle1))
ev$values
## [1] 2.2034 1.0999 1.0930 1.0001 0.8085 0.6602 0.5915 0.5433
Scree Plot
ap <- parallel(subject=nrow(oJoggle1),var=ncol(oJoggle1), rep=100,cent=.05)
nS <- nScree(x=ev$values, aparallel=ap$eigen$qevpea)
plotnScree(nS)
Rotation to Final Solution - 3 Factors
JogglePCA.r<-principal(oJoggle1,nfactors=3,rotate="promax",scores=T)
principal(r=oJoggle1,nfactors=3,rotate="promax",scores=T)
## Principal Components Analysis
## Call: principal(r = oJoggle1, nfactors = 3, rotate = "promax", scores = T)
## Standardized loadings (pattern matrix) based upon correlation matrix
## PC1 PC3 PC2 h2 u2
## residNBack -0.07 0.63 0.44 0.525 0.48
## residBART -0.04 0.03 -0.28 0.076 0.92
## residVOLT 0.82 -0.03 0.08 0.643 0.36
## residDSST 0.10 -0.02 0.86 0.731 0.27
## residLOT 0.44 0.42 -0.06 0.539 0.46
## residAM 0.91 -0.19 0.06 0.705 0.29
## oMPTspeed 0.15 0.56 -0.31 0.542 0.46
## oPVTefficiency -0.20 0.85 -0.05 0.636 0.36
##
## PC1 PC3 PC2
## SS loadings 1.69 1.59 1.11
## Proportion Var 0.21 0.20 0.14
## Cumulative Var 0.21 0.41 0.55
## Proportion Explained 0.39 0.36 0.25
## Cumulative Proportion 0.39 0.75 1.00
##
## With component correlations of
## PC1 PC3 PC2
## PC1 1.00 0.41 -0.15
## PC3 0.41 1.00 -0.08
## PC2 -0.15 -0.08 1.00
##
## Test of the hypothesis that 3 components are sufficient.
##
## The degrees of freedom for the null model are 28 and the objective function was 0.79
## The degrees of freedom for the model are 7 and the objective function was 0.79
## The total number of observations was 1278 with MLE Chi Square = 1006 with prob < 6.2e-213
##
## Fit based upon off diagonal values = 0.59