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 revision
Previous revision
Next revisionBoth sides next revision
factor_analysis_examples [2019/11/20 08:52] – [Personality] hkimscilfactor_analysis_examples [2019/12/06 13:45] – created hkimscil
Line 1: Line 1:
-====== FA e.gs ====== +====== ====== 
-====== Personality ======+{{:r:EFA.csv}} 
 <code> <code>
-<- read.table("http://commres.net/wiki/_media/r/personality0.txt")+# 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>
  
-살펴보기 (head) 
-구조및성질 (str) 
-상관관계 도식화 (corrplot) 
-  * require corrplot package 
-<code> 
-install.packages("corrplot") # if not installed 
-library(corrplot) 
-corrplot(cor(d), order = "hclust", tl.col='black', tl.cex=.75) 
-</code>  
- 
-fa 펑션 factor analysis 
 <code> <code>
 +# install the package
 +# install.packages("psych")
 +# install.packages("GPArotation")
 +# load the package
 library(psych) library(psych)
-d.fa <- fa(d, rotate="none"# fa test with no rotation +library(GPArotation)
-names(d.fa) # to see what comes with the output d.fa+
 </code> </code>
  
-check out the output. 
 <code> <code>
-d.fa+# calculate the correlation matrix 
 +corMat <- cor(data) 
 +# display the correlation matrix 
 +round(corMat,3)
 </code> </code>
  
-compare the output to d.fa$communality 
 <code> <code>
-d.fa$communality+# 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>
  
-for better output 
 <code> <code>
-data.frame(d.fa$communality)+fa.sort(solution)
 </code> </code>
- 
-d.fa 아웃풋처럼 round 처리  
-<code> 
-round(data.frame(d.fa$communality),3) 
-</code> 
- 
-check out the uniqueness too 
-<WRAP info 70%> 
-uniqueness check  
-직접 해 보기 
-</WRAP> 
- 
  
  
factor_analysis_examples.txt · Last modified: 2022/05/05 15:02 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki