User Tools

Site Tools


factor_analysis_examples

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
factor_analysis_examples [2019/11/20 10:28] – removed hkimscilfactor_analysis_examples [2019/12/06 13:45] – created hkimscil
Line 1: Line 1:
 +====== 1 ======
 +{{:r:EFA.csv}}
 +
 +<code>
 +# read the dataset into R variable using the read.csv(file) function
 +data <- read.csv("http://commres.net/wiki/_media/r/efa.csv")
 +head(data)
 +</code>
 +
 +<code>
 +# install the package
 +# install.packages("psych")
 +# install.packages("GPArotation")
 +# load the package
 +library(psych)
 +library(GPArotation)
 +</code>
 +
 +<code>
 +# calculate the correlation matrix
 +corMat <- cor(data)
 +# display the correlation matrix
 +round(corMat,3)
 +</code>
 +
 +<code>
 +# use fa() to conduct an oblique principal-axis exploratory factor analysis
 +# save the solution to an R variable
 +solution <- fa(r = corMat, nfactors = 2, rotate = "oblimin", fm = "pa")
 +solution2 <- fa(data,  nfactors = 2, rotate = "oblimin", fm = "pa")
 +# display the solution output
 +solution 
 +solution2 
 +</code>
 +
 +<code>
 +fa.sort(solution)
 +</code>
 +
  
factor_analysis_examples.txt · Last modified: 2022/05/05 15:02 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki