options(repos = c(CRAN = "https://cloud.r-project.org"))
#Packages to install
install.packages("psych")
## Installing package into 'C:/Users/geral/AppData/Local/R/win-library/4.5'
## (as 'lib' is unspecified)
## package 'psych' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\geral\AppData\Local\Temp\RtmpqgOLzj\downloaded_packages
install.packages("GPArotation")
## Installing package into 'C:/Users/geral/AppData/Local/R/win-library/4.5'
## (as 'lib' is unspecified)
## package 'GPArotation' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\geral\AppData\Local\Temp\RtmpqgOLzj\downloaded_packages
library("psych")
library("GPArotation")
##
## Attaching package: 'GPArotation'
## The following objects are masked from 'package:psych':
##
## equamax, varimin
#Getting the data into R
Data <- read.csv(file.choose(),header=T)
attach(Data)
names(Data)
## [1] "Obs" "Form.of.letter.of.application"
## [3] "Appearance" "Academic.ability"
## [5] "Likeability" "Self.confidence"
## [7] "Lucidity" "Honesty"
## [9] "Salesmanship" "Experience"
## [11] "Drive" "Ambition"
## [13] "Grasp" "Potential"
## [15] "Keeness.to.join" "Suitability"
options(scipen = 999)
#Overall Raw Score – determine top 3
Data$OverallRaw <- Form.of.letter.of.application + Appearance + Academic.ability +
Likeability + Self.confidence + Lucidity + Honesty + Salesmanship + Experience + Drive +
Ambition + Grasp + Potential + Keeness.to.join + Suitability
#Create data frame with assignment 2 variables
DataFrame <- Data[, c("Form.of.letter.of.application", "Appearance", "Academic.ability", "Likeability",
"Self.confidence", "Lucidity", "Honesty", "Salesmanship", "Experience", "Drive", "Ambition", "Grasp", "Potential",
"Keeness.to.join", "Suitability")]
#Scree Plot
ScreePlot <- scree(DataFrame, factors = TRUE, main = "Scree plot", hline = NULL, add = FALSE)

#Eigen Values Total Variance Explained
ev <- eigen(cor(DataFrame))
summary(ev)
## Length Class Mode
## values 15 -none- numeric
## vectors 225 -none- numeric
ev$values
## [1] 7.51379418 2.05630117 1.45581948 1.19789771 0.73915262 0.49457907
## [7] 0.35126183 0.30990202 0.25696154 0.18491037 0.15268036 0.09756308
## [13] 0.08881880 0.06463323 0.03572455
cumsum(ev$values)/16
## [1] 0.4696121 0.5981310 0.6891197 0.7639883 0.8101853 0.8410965 0.8630504
## [8] 0.8824193 0.8984794 0.9100362 0.9195788 0.9256765 0.9312276 0.9352672
## [15] 0.9375000
#Running the Orthogonal EFA
#Running Ortho FA (where the X is you will need to input the number of factors you would like to extract based on the Scree Plot and Eigenvalues– this is up to you to decide!).
ORTHOFA <- factanal(DataFrame, factors = 3, rotation = "varimax", fm="pa")
print(ORTHOFA, digits=3, cutoff=.1, sort=TRUE)
##
## Call:
## factanal(x = DataFrame, factors = 3, rotation = "varimax", fm = "pa")
##
## Uniquenesses:
## Form.of.letter.of.application Appearance
## 0.536 0.699
## Academic.ability Likeability
## 0.944 0.005
## Self.confidence Lucidity
## 0.117 0.198
## Honesty Salesmanship
## 0.442 0.145
## Experience Drive
## 0.356 0.239
## Ambition Grasp
## 0.155 0.198
## Potential Keeness.to.join
## 0.178 0.419
## Suitability
## 0.191
##
## Loadings:
## Factor1 Factor2 Factor3
## Self.confidence 0.925 0.135
## Lucidity 0.833 0.120 0.307
## Salesmanship 0.872 0.270 0.149
## Drive 0.763 0.381 0.187
## Ambition 0.891 0.174 0.144
## Grasp 0.790 0.286 0.311
## Potential 0.720 0.358 0.420
## Form.of.letter.of.application 0.120 0.644 0.189
## Experience 0.799
## Suitability 0.333 0.824 0.137
## Likeability 0.202 0.155 0.964
## Honesty 0.274 -0.242 0.651
## Keeness.to.join 0.440 0.221 0.582
## Appearance 0.441 0.182 0.272
## Academic.ability 0.224
##
## Factor1 Factor2 Factor3
## SS loadings 5.464 2.428 2.286
## Proportion Var 0.364 0.162 0.152
## Cumulative Var 0.364 0.526 0.679
##
## Test of the hypothesis that 3 factors are sufficient.
## The chi square statistic is 128.86 on 63 degrees of freedom.
## The p-value is 0.00000198
#Create Ortho Factor Average Variables – You will create one new variable for each factor that you have kept. You will need to add in the specific variables that are loading on each factor in the parentheses and update number you will divide by to get your average (X is in there as placeholder).
Data$OrthoFA1 <- (Self.confidence + Lucidity + Salesmanship + Drive + Ambition + Grasp + Potential)/7
Data$OrthoFA2 <- (Form.of.letter.of.application + Experience + Suitability)/3
Data$OrthoFA3 <- (Likeability + Honesty + Keeness.to.join)/3
#Create Ortho Factor Data Frames (to be used for reliability analysis)
Ortho1_DataFrame <- Data[, c("Self.confidence","Lucidity","Salesmanship", "Drive","Ambition","Grasp", "Potential")]
Ortho2_DataFrame <- Data[, c("Form.of.letter.of.application", "Experience", "Suitability")]
Ortho3_DataFrame <- Data[, c("Likeability", "Honesty", "Keeness.to.join")]
#Factor Reliability Analysis – only need to interpret the “Raw Alpha” value
alpha(Ortho1_DataFrame)
## Number of categories should be increased in order to count frequencies.
##
## Reliability analysis
## Call: alpha(x = Ortho1_DataFrame)
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.96 0.96 0.97 0.78 25 0.0086 5.9 2.7 0.78
##
## 95% confidence boundaries
## lower alpha upper
## Feldt 0.94 0.96 0.98
## Duhachek 0.94 0.96 0.98
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Self.confidence 0.96 0.96 0.96 0.79 23 0.0096 0.0028 0.78
## Lucidity 0.95 0.95 0.96 0.78 21 0.0102 0.0034 0.78
## Salesmanship 0.95 0.95 0.96 0.77 20 0.0107 0.0040 0.78
## Drive 0.96 0.96 0.97 0.79 23 0.0095 0.0033 0.78
## Ambition 0.95 0.95 0.96 0.77 21 0.0104 0.0040 0.78
## Grasp 0.95 0.95 0.96 0.78 21 0.0104 0.0028 0.78
## Potential 0.95 0.96 0.96 0.78 22 0.0099 0.0032 0.78
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Self.confidence 48 0.87 0.88 0.86 0.83 6.9 2.4
## Lucidity 48 0.91 0.91 0.90 0.87 6.3 3.2
## Salesmanship 48 0.93 0.92 0.91 0.89 4.9 3.4
## Drive 48 0.87 0.87 0.84 0.83 5.3 2.9
## Ambition 48 0.92 0.92 0.91 0.88 6.0 2.9
## Grasp 48 0.92 0.91 0.91 0.88 6.2 3.0
## Potential 48 0.90 0.89 0.88 0.86 5.7 3.2
alpha(Ortho2_DataFrame)
## Number of categories should be increased in order to count frequencies.
##
## Reliability analysis
## Call: alpha(x = Ortho2_DataFrame)
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.82 0.82 0.76 0.61 4.7 0.043 5.4 2.7 0.59
##
## 95% confidence boundaries
## lower alpha upper
## Feldt 0.71 0.82 0.89
## Duhachek 0.74 0.82 0.91
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N
## Form.of.letter.of.application 0.82 0.82 0.69 0.69 4.5
## Experience 0.73 0.74 0.59 0.59 2.8
## Suitability 0.70 0.71 0.55 0.55 2.4
## alpha se var.r med.r
## Form.of.letter.of.application 0.052 NA 0.69
## Experience 0.076 NA 0.59
## Suitability 0.084 NA 0.55
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Form.of.letter.of.application 48 0.80 0.83 0.67 0.62 6.0 2.7
## Experience 48 0.88 0.87 0.78 0.70 4.2 3.3
## Suitability 48 0.89 0.88 0.81 0.73 6.0 3.3
alpha(Ortho3_DataFrame)
## Number of categories should be increased in order to count frequencies.
##
## Reliability analysis
## Call: alpha(x = Ortho3_DataFrame)
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.82 0.81 0.77 0.59 4.4 0.046 6.6 2.3 0.65
##
## 95% confidence boundaries
## lower alpha upper
## Feldt 0.70 0.82 0.89
## Duhachek 0.72 0.82 0.91
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Likeability 0.62 0.62 0.45 0.45 1.6 0.110 NA 0.45
## Honesty 0.81 0.81 0.69 0.69 4.4 0.054 NA 0.69
## Keeness.to.join 0.78 0.78 0.65 0.65 3.6 0.062 NA 0.65
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Likeability 48 0.92 0.91 0.86 0.78 6.1 2.8
## Honesty 48 0.81 0.82 0.67 0.60 8.0 2.5
## Keeness.to.join 48 0.84 0.83 0.71 0.63 5.6 2.7
#Ortho Overall Score
Data$Ortho_Overall <- Data$OrthoFA1 + Data$OrthoFA2 + Data$OrthoFA3 + Appearance + Academic.ability
#Determine the top 3 based on the Ortho Overall Score – there is no code for this, you will filter the “Ortho Overall Score” variable and see who the top 3 candidates are. See assignment #5 walk-through video for more on this
#Running the Oblique EFA
#Running Oblique FA (where the X is you will need to input the number of factors you would like to extract based on the Scree Plot and Eigenvalues– this is up to you to decide!).
OBLIQFA <- factanal(DataFrame, factors = 3, rotation = "oblimin", fm="pa")
print(OBLIQFA, digits=3, cutoff=.1, sort=TRUE)
##
## Call:
## factanal(x = DataFrame, factors = 3, rotation = "oblimin", fm = "pa")
##
## Uniquenesses:
## Form.of.letter.of.application Appearance
## 0.536 0.699
## Academic.ability Likeability
## 0.944 0.005
## Self.confidence Lucidity
## 0.117 0.198
## Honesty Salesmanship
## 0.442 0.145
## Experience Drive
## 0.356 0.239
## Ambition Grasp
## 0.155 0.198
## Potential Keeness.to.join
## 0.178 0.419
## Suitability
## 0.191
##
## Loadings:
## Factor1 Factor2 Factor3
## Self.confidence 1.013 -0.251
## Lucidity 0.831 0.140
## Salesmanship 0.896 0.135
## Drive 0.746 0.265
## Ambition 0.932
## Grasp 0.758 0.153 0.147
## Potential 0.639 0.232 0.279
## Form.of.letter.of.application 0.639 0.149
## Experience 0.822
## Suitability 0.213 0.798
## Likeability 1.008
## Honesty 0.168 -0.341 0.665
## Keeness.to.join 0.303 0.120 0.528
## Appearance 0.393 0.102 0.189
## Academic.ability 0.228
##
## Factor1 Factor2 Factor3
## SS loadings 5.254 2.15 1.933
##
## Factor Correlations:
## Factor1 Factor2 Factor3
## Factor1 1.000 0.316 0.454
## Factor2 0.316 1.000 0.209
## Factor3 0.454 0.209 1.000
##
## Test of the hypothesis that 3 factors are sufficient.
## The chi square statistic is 128.86 on 63 degrees of freedom.
## The p-value is 0.00000198
#Create Oblique Factor Average Variables – You will create one new variable for each factor that you have kept. You will need to add in the specific variables that are loading on each factor in the parentheses and update number you will divide by to get your average (X is in there as placeholder).
Data$ObliqFA1 <- (Self.confidence + Lucidity + Salesmanship + Drive + Ambition + Grasp + Potential + Appearance)/8
Data$ObliqFA2 <- (Form.of.letter.of.application + Experience + Suitability)/3
Data$ObliqFA3 <- (Likeability + Honesty + Keeness.to.join)/3
#Create Ortho Factor Data Frames (to be used for reliability analysis)
Obliq1_DataFrame <- Data[, c("Self.confidence","Lucidity","Salesmanship", "Drive","Ambition","Grasp", "Potential", "Appearance")]
Obliq2_DataFrame <- Data[, c("Form.of.letter.of.application", "Experience", "Suitability")]
Obliq3_DataFrame <- Data[, c("Likeability", "Honesty", "Keeness.to.join")]
#Factor Reliability Analysis – only need to interpret the “Raw Alpha” value
alpha(Obliq1_DataFrame)
## Number of categories should be increased in order to count frequencies.
##
## Reliability analysis
## Call: alpha(x = Obliq1_DataFrame)
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.95 0.95 0.96 0.7 19 0.0095 6.1 2.5 0.76
##
## 95% confidence boundaries
## lower alpha upper
## Feldt 0.93 0.95 0.97
## Duhachek 0.93 0.95 0.97
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Self.confidence 0.94 0.94 0.96 0.70 16 0.0109 0.0270 0.77
## Lucidity 0.94 0.94 0.95 0.69 16 0.0113 0.0239 0.75
## Salesmanship 0.94 0.94 0.95 0.68 15 0.0120 0.0266 0.72
## Drive 0.94 0.94 0.96 0.70 17 0.0107 0.0250 0.77
## Ambition 0.94 0.94 0.95 0.68 15 0.0117 0.0279 0.72
## Grasp 0.94 0.94 0.95 0.68 15 0.0116 0.0267 0.76
## Potential 0.94 0.94 0.95 0.69 15 0.0113 0.0282 0.76
## Appearance 0.96 0.96 0.97 0.78 25 0.0086 0.0034 0.78
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Self.confidence 48 0.87 0.87 0.86 0.83 6.9 2.4
## Lucidity 48 0.90 0.89 0.89 0.86 6.3 3.2
## Salesmanship 48 0.92 0.92 0.91 0.89 4.9 3.4
## Drive 48 0.86 0.85 0.83 0.81 5.3 2.9
## Ambition 48 0.92 0.92 0.92 0.89 6.0 2.9
## Grasp 48 0.92 0.91 0.91 0.89 6.2 3.0
## Potential 48 0.90 0.89 0.89 0.86 5.7 3.2
## Appearance 48 0.58 0.61 0.54 0.51 7.1 2.0
alpha(Obliq2_DataFrame)
## Number of categories should be increased in order to count frequencies.
##
## Reliability analysis
## Call: alpha(x = Obliq2_DataFrame)
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.82 0.82 0.76 0.61 4.7 0.043 5.4 2.7 0.59
##
## 95% confidence boundaries
## lower alpha upper
## Feldt 0.71 0.82 0.89
## Duhachek 0.74 0.82 0.91
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N
## Form.of.letter.of.application 0.82 0.82 0.69 0.69 4.5
## Experience 0.73 0.74 0.59 0.59 2.8
## Suitability 0.70 0.71 0.55 0.55 2.4
## alpha se var.r med.r
## Form.of.letter.of.application 0.052 NA 0.69
## Experience 0.076 NA 0.59
## Suitability 0.084 NA 0.55
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Form.of.letter.of.application 48 0.80 0.83 0.67 0.62 6.0 2.7
## Experience 48 0.88 0.87 0.78 0.70 4.2 3.3
## Suitability 48 0.89 0.88 0.81 0.73 6.0 3.3
alpha(Obliq3_DataFrame)
## Number of categories should be increased in order to count frequencies.
##
## Reliability analysis
## Call: alpha(x = Obliq3_DataFrame)
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.82 0.81 0.77 0.59 4.4 0.046 6.6 2.3 0.65
##
## 95% confidence boundaries
## lower alpha upper
## Feldt 0.70 0.82 0.89
## Duhachek 0.72 0.82 0.91
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Likeability 0.62 0.62 0.45 0.45 1.6 0.110 NA 0.45
## Honesty 0.81 0.81 0.69 0.69 4.4 0.054 NA 0.69
## Keeness.to.join 0.78 0.78 0.65 0.65 3.6 0.062 NA 0.65
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Likeability 48 0.92 0.91 0.86 0.78 6.1 2.8
## Honesty 48 0.81 0.82 0.67 0.60 8.0 2.5
## Keeness.to.join 48 0.84 0.83 0.71 0.63 5.6 2.7
#Oblique Overall Score – After creating your factor averages you will want to create the overall factor score. This will be done by adding all of the Obliq_Factor Variables that you created above. Note, your specific code for doing this will depend on the number of factors you retained and if you decide some variables will not load on a factor. The code below is an example for you to modify.
Data$Obliq_Overall_Score <- Data$ObliqFA1 + Data$ObliqFA2 + Data$ObliqFA3 + Academic.ability
#Determine the top 3 based on the Obliq Overall Score – there is no code for this, you will filter the “Obliq Overall Score” variable and see who the top 3 candidates are. See assignment #5 walk-through video for more on this