factor_analysis_examples
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
factor_analysis_examples [2019/11/20 08:52] – [Personality] hkimscil | factor_analysis_examples [2019/12/06 13:45] – created hkimscil | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | ====== Personality ====== | + | {{: |
< | < | ||
- | d <- read.table(" | + | # read the dataset into R variable using the read.csv(file) function |
+ | data <- read.csv(" | ||
+ | head(data) | ||
</ | </ | ||
- | 살펴보기 (head) | ||
- | 구조및성질 (str) | ||
- | 상관관계 도식화 (corrplot) | ||
- | * require corrplot package | ||
- | < | ||
- | install.packages(" | ||
- | library(corrplot) | ||
- | corrplot(cor(d), | ||
- | </ | ||
- | |||
- | fa 펑션 factor analysis | ||
< | < | ||
+ | # install the package | ||
+ | # install.packages(" | ||
+ | # install.packages(" | ||
+ | # load the package | ||
library(psych) | library(psych) | ||
- | d.fa <- fa(d, rotate=" | + | library(GPArotation) |
- | names(d.fa) # to see what comes with the output d.fa | + | |
</ | </ | ||
- | check out the output. | ||
< | < | ||
- | d.fa | + | # calculate the correlation matrix |
+ | corMat <- cor(data) | ||
+ | # display the correlation matrix | ||
+ | round(corMat, | ||
</ | </ | ||
- | compare the output to d.fa$communality | ||
< | < | ||
- | 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 = " | ||
+ | solution2 <- fa(data, | ||
+ | # display the solution output | ||
+ | solution | ||
+ | solution2 | ||
</ | </ | ||
- | for better output | ||
< | < | ||
- | data.frame(d.fa$communality) | + | fa.sort(solution) |
</ | </ | ||
- | |||
- | d.fa 아웃풋처럼 round 처리 | ||
- | < | ||
- | round(data.frame(d.fa$communality), | ||
- | </ | ||
- | |||
- | check out the uniqueness too | ||
- | <WRAP info 70%> | ||
- | uniqueness check | ||
- | 직접 해 보기 | ||
- | </ | ||
- | |||
factor_analysis_examples.txt · Last modified: 2022/05/05 15:02 by hkimscil