#K-MMSE와 MMSE는 0과 1로 응답한 척도.
#이분형 응답문항을 합점수로 활용하는 자료를 사용하여 EFA를 하는경우 :
#EFA with categoeical indicators of mixed type해야함.
#즉, 문항이 binary 또는 ordinal이 혼합된 mixed type인 경우 모든 문항이 categorical임.
#categorical EFA를 실시해야함.
#R에서는 estimator로 wlsmv를 사용할 수 없기 때문에 Mplus를 활용하는 것이 더 유용함.
#echo = F : R code보이지 않고 결과만 출력.
#echo = T : R code와 결과 모두 출력.
setwd("C:/Users/LG/Desktop/old")
library(haven) #spss
## Warning: package 'haven' was built under R version 3.5.3
library(dplyr) #%>% 연산자
## Warning: package 'dplyr' was built under R version 3.5.3
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2) #그림
## Warning: package 'ggplot2' was built under R version 3.5.3
library(reshape2) #melt함수
## Warning: package 'reshape2' was built under R version 3.5.3
data <- read_spss("SH.sav")
head(data)
## # A tibble: 6 x 49
## pid W07OLDNEW w07wgt_c w07wgt_ac w07C420 w07C550 연령 성별 교육수준
## <dbl> <dbl+lbl> <dbl> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl>
## 1 11 1 [기존패널]~ 1395. 1362. 1 [도움을~ 1 [예] 85 5 2
## 2 21 1 [기존패널]~ 3203. 3201. 1 [도움을~ 1 [예] 63 5 4
## 3 22 1 [기존패널]~ 5361. 5398. 1 [도움을~ 1 [예] 64 1 4
## 4 41 1 [기존패널]~ 1087. 1058. 2 [가끔]~ 1 [예] 82 5 1
## 5 42 1 [기존패널]~ 913. 930. 2 [가끔]~ 1 [예] 83 1 3
## 6 51 1 [기존패널]~ 1942. 1809. 2 [가끔]~ 1 [예] 76 1 1
## # ... with 40 more variables: 가구소득 <dbl>, 주관적건강상태 <dbl>,
## # ADL <dbl>, IADL <dbl>, 우울감 <dbl>, 치매진단 <dbl+lbl>,
## # 우울증진단 <dbl+lbl>, 정신질환진단 <dbl+lbl>, 연구대상자 <dbl+lbl>,
## # KMMSE_총점수 <dbl>, v1 <dbl>, v2 <dbl>, v3 <dbl>, v4 <dbl>, v5 <dbl>,
## # v6 <dbl>, v7 <dbl>, v8 <dbl>, v9 <dbl>, v10 <dbl>, v11 <dbl>,
## # v12 <dbl>, v13 <dbl>, v14 <dbl>, v15 <dbl>, v16 <dbl>, v17 <dbl>,
## # v18 <dbl>, v19 <dbl>, K1 <dbl>, K2 <dbl>, K3 <dbl>, K4 <dbl>,
## # K5 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>, K9 <dbl>, K10 <dbl>, K11 <dbl>
tail(data)
## # A tibble: 6 x 49
## pid W07OLDNEW w07wgt_c w07wgt_ac w07C420 w07C550 연령 성별 교육수준
## <dbl> <dbl+lbl> <dbl> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl>
## 1 68001 2 [신규패널]~ NA 743. 1 [도움을~ 1 [예] 55 5 3
## 2 68011 2 [신규패널]~ NA 840. 1 [도움을~ 1 [예] 56 5 3
## 3 68021 2 [신규패널]~ NA 1213. 1 [도움을~ 1 [예] 56 1 2
## 4 68041 2 [신규패널]~ NA 4772. 1 [도움을~ 1 [예] 55 1 2
## 5 68051 2 [신규패널]~ NA 4911. 1 [도움을~ 1 [예] 56 1 3
## 6 68052 2 [신규패널]~ NA 2835. 1 [도움을~ 1 [예] 55 5 3
## # ... with 40 more variables: 가구소득 <dbl>, 주관적건강상태 <dbl>,
## # ADL <dbl>, IADL <dbl>, 우울감 <dbl>, 치매진단 <dbl+lbl>,
## # 우울증진단 <dbl+lbl>, 정신질환진단 <dbl+lbl>, 연구대상자 <dbl+lbl>,
## # KMMSE_총점수 <dbl>, v1 <dbl>, v2 <dbl>, v3 <dbl>, v4 <dbl>, v5 <dbl>,
## # v6 <dbl>, v7 <dbl>, v8 <dbl>, v9 <dbl>, v10 <dbl>, v11 <dbl>,
## # v12 <dbl>, v13 <dbl>, v14 <dbl>, v15 <dbl>, v16 <dbl>, v17 <dbl>,
## # v18 <dbl>, v19 <dbl>, K1 <dbl>, K2 <dbl>, K3 <dbl>, K4 <dbl>,
## # K5 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>, K9 <dbl>, K10 <dbl>, K11 <dbl>
#연구대상자 선택(치매의심)
dementia <- data %>% filter(연구대상자 == 1)
head(dementia)
## # A tibble: 6 x 49
## pid W07OLDNEW w07wgt_c w07wgt_ac w07C420 w07C550 연령 성별 교육수준
## <dbl> <dbl+lbl> <dbl> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl>
## 1 11 1 [기존패널]~ 1395. 1362. 1 [도움을~ 1 [예] 85 5 2
## 2 21 1 [기존패널]~ 3203. 3201. 1 [도움을~ 1 [예] 63 5 4
## 3 22 1 [기존패널]~ 5361. 5398. 1 [도움을~ 1 [예] 64 1 4
## 4 41 1 [기존패널]~ 1087. 1058. 2 [가끔]~ 1 [예] 82 5 1
## 5 42 1 [기존패널]~ 913. 930. 2 [가끔]~ 1 [예] 83 1 3
## 6 51 1 [기존패널]~ 1942. 1809. 2 [가끔]~ 1 [예] 76 1 1
## # ... with 40 more variables: 가구소득 <dbl>, 주관적건강상태 <dbl>,
## # ADL <dbl>, IADL <dbl>, 우울감 <dbl>, 치매진단 <dbl+lbl>,
## # 우울증진단 <dbl+lbl>, 정신질환진단 <dbl+lbl>, 연구대상자 <dbl+lbl>,
## # KMMSE_총점수 <dbl>, v1 <dbl>, v2 <dbl>, v3 <dbl>, v4 <dbl>, v5 <dbl>,
## # v6 <dbl>, v7 <dbl>, v8 <dbl>, v9 <dbl>, v10 <dbl>, v11 <dbl>,
## # v12 <dbl>, v13 <dbl>, v14 <dbl>, v15 <dbl>, v16 <dbl>, v17 <dbl>,
## # v18 <dbl>, v19 <dbl>, K1 <dbl>, K2 <dbl>, K3 <dbl>, K4 <dbl>,
## # K5 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>, K9 <dbl>, K10 <dbl>, K11 <dbl>
tail(dementia)
## # A tibble: 6 x 49
## pid W07OLDNEW w07wgt_c w07wgt_ac w07C420 w07C550 연령 성별 교육수준
## <dbl> <dbl+lbl> <dbl> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl>
## 1 65712 2 [신규패널]~ NA 45.6 1 [도움을~ 1 [예] 78 5 1
## 2 66433 2 [신규패널]~ NA 30.6 3 [대부분~ 1 [예] 88 5 1
## 3 67191 2 [신규패널]~ NA 751. 1 [도움을~ 1 [예] 56 5 1
## 4 67431 2 [신규패널]~ NA 668. 1 [도움을~ 1 [예] 55 5 1
## 5 67551 2 [신규패널]~ NA 1264. 1 [도움을~ 1 [예] 56 1 4
## 6 67701 2 [신규패널]~ NA 1218. 1 [도움을~ 1 [예] 55 1 3
## # ... with 40 more variables: 가구소득 <dbl>, 주관적건강상태 <dbl>,
## # ADL <dbl>, IADL <dbl>, 우울감 <dbl>, 치매진단 <dbl+lbl>,
## # 우울증진단 <dbl+lbl>, 정신질환진단 <dbl+lbl>, 연구대상자 <dbl+lbl>,
## # KMMSE_총점수 <dbl>, v1 <dbl>, v2 <dbl>, v3 <dbl>, v4 <dbl>, v5 <dbl>,
## # v6 <dbl>, v7 <dbl>, v8 <dbl>, v9 <dbl>, v10 <dbl>, v11 <dbl>,
## # v12 <dbl>, v13 <dbl>, v14 <dbl>, v15 <dbl>, v16 <dbl>, v17 <dbl>,
## # v18 <dbl>, v19 <dbl>, K1 <dbl>, K2 <dbl>, K3 <dbl>, K4 <dbl>,
## # K5 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>, K9 <dbl>, K10 <dbl>, K11 <dbl>
nrow(dementia)
## [1] 1827
#치매의심 대상자(1 ~ 900)가 응답한 19개 문항
demet19 <- dementia %>% .[c(1:900), c(20:38)]
head(demet19)
## # A tibble: 6 x 19
## v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 1 1 1 1 1 1 0 1 1 0 2
## 2 1 1 1 1 3 2 1 1 1 0 0 3
## 3 2 1 1 1 2 3 1 1 0 0 1 2
## 4 2 1 1 1 2 2 1 1 1 1 0 2
## 5 2 1 1 1 3 3 1 1 1 1 0 1
## 6 2 1 1 1 2 2 1 1 0 1 0 2
## # ... with 7 more variables: v13 <dbl>, v14 <dbl>, v15 <dbl>, v16 <dbl>,
## # v17 <dbl>, v18 <dbl>, v19 <dbl>
tail(demet19)
## # A tibble: 6 x 19
## v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 3 1 1 1 4 1 1 1 1 1 1 1
## 2 3 1 1 1 4 2 1 0 1 1 0 1
## 3 1 1 1 1 4 3 1 1 1 0 0 2
## 4 3 1 1 1 4 2 1 0 1 1 1 0
## 5 3 1 1 1 4 1 1 0 1 1 1 0
## 6 3 1 1 1 4 0 0 1 1 1 1 0
## # ... with 7 more variables: v13 <dbl>, v14 <dbl>, v15 <dbl>, v16 <dbl>,
## # v17 <dbl>, v18 <dbl>, v19 <dbl>
nrow(demet19)
## [1] 900
#치매의심 대상자(1 ~ 900)가 응답한 11개 문항
demet11 <- dementia %>% .[c(1:900), c(39:49)]
head(demet11)
## # A tibble: 6 x 11
## K1 K2 K3 K4 K5 K6 K7 K8 K9 K10 K11
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 3 2 1 3 2 2 0 1 1 0 0
## 2 3 4 2 3 3 2 1 2 1 1 1
## 3 4 3 3 3 2 2 1 2 1 1 1
## 4 4 3 2 4 2 2 1 1 1 1 1
## 5 4 4 3 4 1 2 1 2 1 1 0
## 6 4 3 2 3 2 2 1 1 1 0 0
tail(demet11)
## # A tibble: 6 x 11
## K1 K2 K3 K4 K5 K6 K7 K8 K9 K10 K11
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 5 5 1 5 1 2 1 0 0 0 0
## 2 5 5 2 3 1 2 1 1 1 1 0
## 3 3 5 3 3 2 2 1 0 0 0 0
## 4 5 5 2 4 0 2 1 0 0 0 0
## 5 5 5 1 4 0 2 1 1 1 1 0
## 6 5 5 0 4 0 2 1 0 0 0 0
nrow(demet11)
## [1] 900
#19문항 결측치 확인
colSums(is.na(demet19))
## v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 v18
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## v19
## 0
#11문항 결측치 확인
colSums(is.na(demet11))
## K1 K2 K3 K4 K5 K6 K7 K8 K9 K10 K11
## 0 0 0 0 0 0 0 0 0 0 0
#19문항 요약, 평균, 표준편차
as.table(apply(demet19, 2, summary))
## v1 v2 v3 v4 v5 v6
## Min. 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## 1st Qu. 1.0000000 1.0000000 1.0000000 1.0000000 2.0000000 1.0000000
## Median 2.0000000 1.0000000 1.0000000 1.0000000 3.0000000 2.0000000
## Mean 2.0722222 0.8333333 0.9500000 0.9477778 2.8444444 1.7311111
## 3rd Qu. 3.0000000 1.0000000 1.0000000 1.0000000 4.0000000 3.0000000
## Max. 3.0000000 1.0000000 1.0000000 1.0000000 4.0000000 3.0000000
## v7 v8 v9 v10 v11 v12
## Min. 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## 1st Qu. 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## Median 1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000
## Mean 0.6011111 0.2344444 0.3422222 0.2966667 0.2122222 0.9111111
## 3rd Qu. 1.0000000 0.0000000 1.0000000 1.0000000 0.0000000 2.0000000
## Max. 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 3.0000000
## v13 v14 v15 v16 v17 v18
## Min. 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## 1st Qu. 1.0000000 1.0000000 1.0000000 1.0000000 0.0000000 0.0000000
## Median 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## Mean 0.9355556 0.9211111 0.8444444 1.2477778 0.7166667 0.6600000
## 3rd Qu. 1.0000000 1.0000000 1.0000000 2.0000000 1.0000000 1.0000000
## Max. 1.0000000 1.0000000 1.0000000 3.0000000 1.0000000 1.0000000
## v19
## Min. 0.0000000
## 1st Qu. 0.0000000
## Median 0.0000000
## Mean 0.3888889
## 3rd Qu. 1.0000000
## Max. 1.0000000
as.table(apply(demet19, 2, mean))
## v1 v2 v3 v4 v5 v6 v7
## 2.0722222 0.8333333 0.9500000 0.9477778 2.8444444 1.7311111 0.6011111
## v8 v9 v10 v11 v12 v13 v14
## 0.2344444 0.3422222 0.2966667 0.2122222 0.9111111 0.9355556 0.9211111
## v15 v16 v17 v18 v19
## 0.8444444 1.2477778 0.7166667 0.6600000 0.3888889
as.table(apply(demet19, 2, sd))
## v1 v2 v3 v4 v5 v6 v7
## 0.9328426 0.3728852 0.2180661 0.2225986 1.1564118 0.9999604 0.4899421
## v8 v9 v10 v11 v12 v13 v14
## 0.4238866 0.4747174 0.4570423 0.4091087 0.8804444 0.2456795 0.2697151
## v15 v16 v17 v18 v19
## 0.3626350 0.8771893 0.4508674 0.4739722 0.4877691
#11문항 요약, 평균, 표준편차
as.table(apply(demet11, 2, summary))
## K1 K2 K3 K4 K5 K6
## Min. 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## 1st Qu. 3.0000000 3.0000000 1.0000000 0.0000000 0.0000000 2.0000000
## Median 4.0000000 4.0000000 2.0000000 1.0000000 1.0000000 2.0000000
## Mean 3.8555556 3.7922222 1.7311111 1.6866667 0.9111111 1.8566667
## 3rd Qu. 5.0000000 5.0000000 3.0000000 3.0000000 2.0000000 2.0000000
## Max. 5.0000000 5.0000000 3.0000000 5.0000000 3.0000000 2.0000000
## K7 K8 K9 K10 K11
## Min. 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## 1st Qu. 1.0000000 1.0000000 0.0000000 0.0000000 0.0000000
## Median 1.0000000 1.0000000 1.0000000 1.0000000 0.0000000
## Mean 0.8444444 1.2477778 0.7166667 0.6600000 0.3888889
## 3rd Qu. 1.0000000 2.0000000 1.0000000 1.0000000 1.0000000
## Max. 1.0000000 3.0000000 1.0000000 1.0000000 1.0000000
as.table(apply(demet11, 2, mean))
## K1 K2 K3 K4 K5 K6 K7
## 3.8555556 3.7922222 1.7311111 1.6866667 0.9111111 1.8566667 0.8444444
## K8 K9 K10 K11
## 1.2477778 0.7166667 0.6600000 0.3888889
as.table(apply(demet11, 2, sd))
## K1 K2 K3 K4 K5 K6 K7
## 1.2930989 1.2630390 0.9999604 1.5427321 0.8804444 0.4480957 0.3626350
## K8 K9 K10 K11
## 0.8771893 0.4508674 0.4739722 0.4877691
19문항과 11문항 표본 Summary와 평균, 표준편차를 계산함.
명령시행 : V16, V17, V18, V19
시각적 구성 : K11
#19문항 histogram
ggplot(data = melt(demet19), aes(x = value)) +
facet_wrap(~variable) + geom_histogram()
## No id variables; using all as measure variables
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#19문항 box plot
ggplot(data = melt(demet19), aes(x = variable, y = value)) +
geom_boxplot(aes(fill = variable))
## No id variables; using all as measure variables
#11문항 histogram
ggplot(data = melt(demet11), aes(x = value)) +
facet_wrap(~variable) + geom_histogram()
## No id variables; using all as measure variables
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#11문항 box plot
ggplot(data = melt(demet11), aes(x = variable, y = value)) +
geom_boxplot(aes(fill = variable))
## No id variables; using all as measure variables
library(psych)
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
#binary 또는 ordinal 자료는 EFA를 실시하기 위하여 polychoric 또는 tetrachoric 상관행렬을 사용함.
#tetrachoric : 자료가 0, 1로만 구성된 경우, binary
#polychoric : 자료가 여러 범주를 가지는 경우, ordinal
#19문항
p19 <- polychoric(demet19)
## Warning in matpLower(x, nvar, gminx, gmaxx, gminy, gmaxy): 171 cells were
## adjusted for 0 values using the correction for continuity. Examine your
## data carefully.
## Warning in cor.smooth(mat): Matrix was not positive definite, smoothing was
## done
p19$rho
## v1 v2 v3 v4 v5 v6
## v1 1.00000000 0.6039182 0.6882221 0.6954185 0.6336814 0.2854265
## v2 0.60391822 1.0000000 0.7370322 0.7931913 0.2703959 0.4521821
## v3 0.68822213 0.7370322 1.0000000 0.7326822 0.4774871 0.3534925
## v4 0.69541850 0.7931913 0.7326822 1.0000000 0.3803491 0.2264706
## v5 0.63368137 0.2703959 0.4774871 0.3803491 1.0000000 0.2884062
## v6 0.28542652 0.4521821 0.3534925 0.2264706 0.2884062 1.0000000
## v7 0.20745242 0.4452905 0.4372015 0.4539697 0.1000048 0.2400396
## v8 0.01353088 0.2011285 0.1980048 0.2303540 -0.0606116 0.2256946
## v9 0.11058553 0.3718358 0.1341606 0.2911244 0.1013519 0.1482567
## v10 0.06740131 0.2769816 -0.1061539 0.3710004 -0.1625067 0.1701432
## v11 -0.12177048 0.1805009 0.1746120 0.1953689 -0.1009706 -0.1948831
## v12 0.23111774 0.3922362 0.4177711 0.2713644 -0.2058943 0.4390117
## v13 0.65375658 0.5925103 0.3296854 0.4544687 0.4287793 0.5053156
## v14 0.50120917 0.5751371 0.4403966 0.3908904 0.4998579 0.4746916
## v15 0.49523505 0.5116486 0.5581496 0.3600479 0.4373996 0.4826654
## v16 0.47500446 0.4326206 0.4852911 0.2527555 0.2762391 0.4199578
## v17 0.44222346 0.5720527 0.5787075 0.5711774 0.2165804 0.4675201
## v18 0.35990626 0.3570158 0.5185085 0.5184963 0.2147109 0.3353533
## v19 0.36834551 0.2924484 0.3792075 0.3760493 0.1403875 0.4900560
## v7 v8 v9 v10 v11
## v1 0.2074524 0.01353088 0.110585534 0.06740131 -0.121770482
## v2 0.4452905 0.20112848 0.371835777 0.27698158 0.180500892
## v3 0.4372015 0.19800480 0.134160642 -0.10615389 0.174611981
## v4 0.4539697 0.23035397 0.291124393 0.37100039 0.195368863
## v5 0.1000048 -0.06061160 0.101351879 -0.16250672 -0.100970612
## v6 0.2400396 0.22569460 0.148256665 0.17014321 -0.194883084
## v7 1.0000000 0.52672290 0.530227489 0.55818894 0.505832324
## v8 0.5267229 1.00000000 0.438698634 0.49348024 0.476774328
## v9 0.5302275 0.43869863 1.000000000 0.56707874 0.480449425
## v10 0.5581889 0.49348024 0.567078743 1.00000000 0.463208657
## v11 0.5058323 0.47677433 0.480449425 0.46320866 1.000000000
## v12 0.2731572 0.21310658 0.082228131 0.20146686 0.078052981
## v13 0.2619108 0.21166487 0.382252925 0.40793722 -0.059746144
## v14 0.2220275 -0.03564240 -0.081232455 -0.05336140 -0.357137392
## v15 0.4664628 0.25384042 0.114135655 0.25797533 0.186775472
## v16 0.1754028 -0.02857775 -0.008190598 -0.02493423 0.172797174
## v17 0.3695579 0.10777947 -0.094104539 0.17487781 0.003648404
## v18 0.4315348 0.05806107 0.223543418 0.25227600 0.094207251
## v19 0.3729768 0.12305177 0.151304677 0.21706190 -0.050672408
## v12 v13 v14 v15 v16
## v1 0.23111774 0.65375658 0.50120917 0.4952350 0.475004460
## v2 0.39223620 0.59251026 0.57513705 0.5116486 0.432620621
## v3 0.41777111 0.32968541 0.44039655 0.5581496 0.485291112
## v4 0.27136440 0.45446870 0.39089036 0.3600479 0.252755545
## v5 -0.20589430 0.42877932 0.49985793 0.4373996 0.276239140
## v6 0.43901167 0.50531557 0.47469160 0.4826654 0.419957820
## v7 0.27315716 0.26191077 0.22202748 0.4664628 0.175402817
## v8 0.21310658 0.21166487 -0.03564240 0.2538404 -0.028577748
## v9 0.08222813 0.38225292 -0.08123246 0.1141357 -0.008190598
## v10 0.20146686 0.40793722 -0.05336140 0.2579753 -0.024934225
## v11 0.07805298 -0.05974614 -0.35713739 0.1867755 0.172797174
## v12 1.00000000 0.40324462 0.09733796 0.2514379 0.420103780
## v13 0.40324462 1.00000000 0.65358483 0.5876218 0.556231342
## v14 0.09733796 0.65358483 1.00000000 0.6453377 0.448449970
## v15 0.25143787 0.58762178 0.64533773 1.0000000 0.554440967
## v16 0.42010378 0.55623134 0.44844997 0.5544410 1.000000000
## v17 0.52122646 0.57248287 0.67195926 0.6043701 0.722343464
## v18 0.21495069 0.20567558 0.26610479 0.5309324 0.325301674
## v19 0.42502280 0.46663546 0.44113438 0.4812411 0.520458331
## v17 v18 v19
## v1 0.442223457 0.35990626 0.36834551
## v2 0.572052709 0.35701584 0.29244839
## v3 0.578707457 0.51850845 0.37920745
## v4 0.571177427 0.51849635 0.37604931
## v5 0.216580382 0.21471092 0.14038746
## v6 0.467520091 0.33535325 0.49005597
## v7 0.369557919 0.43153481 0.37297681
## v8 0.107779468 0.05806107 0.12305177
## v9 -0.094104539 0.22354342 0.15130468
## v10 0.174877811 0.25227600 0.21706190
## v11 0.003648404 0.09420725 -0.05067241
## v12 0.521226455 0.21495069 0.42502280
## v13 0.572482874 0.20567558 0.46663546
## v14 0.671959264 0.26610479 0.44113438
## v15 0.604370081 0.53093244 0.48124114
## v16 0.722343464 0.32530167 0.52045833
## v17 1.000000000 0.48411655 0.61721090
## v18 0.484116545 1.00000000 0.74553434
## v19 0.617210904 0.74553434 1.00000000
#11문항
p11 <- polychoric(demet11)
## Warning in matpLower(x, nvar, gminx, gmaxx, gminy, gmaxy): 55 cells were
## adjusted for 0 values using the correction for continuity. Examine your
## data carefully.
## Warning in matpLower(x, nvar, gminx, gmaxx, gminy, gmaxy): Matrix was not
## positive definite, smoothing was done
p11$rho
## K1 K2 K3 K4 K5 K6
## K1 1.0000000 0.661234734 0.52616347 0.12855311 0.295400118 0.7011990
## K2 0.6612347 1.000000000 0.23561930 0.03046618 0.003820853 0.5011412
## K3 0.5261635 0.235619302 1.00000000 0.07727208 0.459534796 0.4103778
## K4 0.1285531 0.030466184 0.07727208 1.00000000 0.212683172 0.3291149
## K5 0.2954001 0.003820853 0.45953480 0.21268317 1.000000000 0.5499598
## K6 0.7011990 0.501141171 0.41037784 0.32911491 0.549959804 1.0000000
## K7 0.4936593 0.332735487 0.51374167 0.16726344 0.234842795 0.5010411
## K8 0.3749261 0.190129233 0.45844146 0.04061171 0.415013023 0.7806703
## K9 0.5072686 0.235758982 0.47472214 0.18838628 0.536825126 0.7073257
## K10 0.2299382 0.286699015 0.32276940 0.05534892 0.235299033 0.2374713
## K11 0.2581946 0.236341930 0.51377336 0.22742488 0.437590326 0.5116895
## K7 K8 K9 K10 K11
## K1 0.4936593 0.37492611 0.5072686 0.22993815 0.2581946
## K2 0.3327355 0.19012923 0.2357590 0.28669901 0.2363419
## K3 0.5137417 0.45844146 0.4747221 0.32276940 0.5137734
## K4 0.1672634 0.04061171 0.1883863 0.05534892 0.2274249
## K5 0.2348428 0.41501302 0.5368251 0.23529903 0.4375903
## K6 0.5010411 0.78067032 0.7073257 0.23747132 0.5116895
## K7 1.0000000 0.54907107 0.6436976 0.57128465 0.4964499
## K8 0.5490711 1.00000000 0.7803043 0.36526024 0.5285443
## K9 0.6436976 0.78030431 1.0000000 0.48748472 0.6307647
## K10 0.5712846 0.36526024 0.4874847 1.00000000 0.7688931
## K11 0.4964499 0.52854431 0.6307647 0.76889313 1.0000000
library(psych)
#parallel plot
fa.parallel(p19$rho)
## Warning in fa.parallel(p19$rho): It seems as if you are using a correlation
## matrix, but have not specified the number of cases. The number of subjects
## is arbitrarily set to be 100
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs
## = np.obs, : The estimated weights for the factor scores are probably
## incorrect. Try a different factor extraction method.
## Parallel analysis suggests that the number of factors = 5 and the number of components = 3
#scree plot
scree(p19$rho)
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs
## = np.obs, : The estimated weights for the factor scores are probably
## incorrect. Try a different factor extraction method.
#EFA factor 1 ~ 2
#1
f1 <- fa(p19$rho, 1, n.obs = 900, fm = "ml")
#ml = maximum likelihood, 자료가 범주형에 해당하는경우에는 추정방법을 wlsmv를 활용해야함.
#하지만, fa에는 wlsmv가 없음.
#결과적으로 mplus를 활용하여 EFA를 해야함.
print(f1)
## Factor Analysis using method = ml
## Call: fa(r = p19$rho, nfactors = 1, n.obs = 900, fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 h2 u2 com
## v1 0.73 0.532 0.47 1
## v2 0.80 0.643 0.36 1
## v3 0.78 0.605 0.40 1
## v4 0.75 0.558 0.44 1
## v5 0.47 0.218 0.78 1
## v6 0.57 0.319 0.68 1
## v7 0.51 0.263 0.74 1
## v8 0.23 0.054 0.95 1
## v9 0.25 0.062 0.94 1
## v10 0.27 0.073 0.93 1
## v11 0.10 0.010 0.99 1
## v12 0.47 0.217 0.78 1
## v13 0.73 0.528 0.47 1
## v14 0.69 0.474 0.53 1
## v15 0.74 0.550 0.45 1
## v16 0.65 0.420 0.58 1
## v17 0.79 0.625 0.37 1
## v18 0.58 0.341 0.66 1
## v19 0.62 0.386 0.61 1
##
## ML1
## SS loadings 6.88
## Proportion Var 0.36
##
## Mean item complexity = 1
## Test of the hypothesis that 1 factor is sufficient.
##
## The degrees of freedom for the null model are 171 and the objective function was 99.74 with Chi Square of 88952.17
## The degrees of freedom for the model are 152 and the objective function was 92.91
##
## The root mean square of the residuals (RMSR) is 0.17
## The df corrected root mean square of the residuals is 0.18
##
## The harmonic number of observations is 900 with the empirical chi square 8574.77 with prob < 0
## The total number of observations was 900 with Likelihood Chi Square = 82799.95 with prob < 0
##
## Tucker Lewis Index of factoring reliability = -0.048
## RMSEA index = 0.781 and the 90 % confidence intervals are 0.773 0.782
## BIC = 81765.98
## Fit based upon off diagonal values = 0.82
## Measures of factor score adequacy
## ML1
## Correlation of (regression) scores with factors 0.97
## Multiple R square of scores with factors 0.93
## Minimum correlation of possible factor scores 0.87
#h2 = communality = 요인부하량의 제곱 = 요인이 각 문항의 분산을 설명하는 정도
#v1문항 분산의 약 43%는 ML1 요인으로 설명됨.
#u2 = uniqueness = 각 문항의 분산에서 요인으로 설명되지 않는 정도
print(f1$loadings, cutoff = 0.4)
##
## Loadings:
## ML1
## v1 0.729
## v2 0.802
## v3 0.778
## v4 0.747
## v5 0.466
## v6 0.565
## v7 0.513
## v8
## v9
## v10
## v11
## v12 0.466
## v13 0.727
## v14 0.689
## v15 0.741
## v16 0.648
## v17 0.791
## v18 0.584
## v19 0.622
##
## ML1
## SS loadings 6.880
## Proportion Var 0.362
#cutoff = 0.4는 요인부하량 가운데 부하량이 0.4이상인 것만 표시함.
fa.diagram(f1, cut = 0, simple = T)
#2
f2 <- fa(p19$rho, 2, n.obs = 900, fm = "ml", rotate = "oblimin")
## Loading required namespace: GPArotation
print(f2)
## Factor Analysis using method = ml
## Call: fa(r = p19$rho, nfactors = 2, n.obs = 900, rotate = "oblimin",
## fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 ML2 h2 u2 com
## v1 0.75 -0.08 0.55 0.45 1.0
## v2 0.73 0.24 0.65 0.35 1.2
## v3 0.74 0.09 0.58 0.42 1.0
## v4 0.64 0.29 0.58 0.42 1.4
## v5 0.55 -0.20 0.29 0.71 1.3
## v6 0.58 -0.01 0.33 0.67 1.0
## v7 0.31 0.67 0.63 0.37 1.4
## v8 0.02 0.64 0.42 0.58 1.0
## v9 0.02 0.71 0.51 0.49 1.0
## v10 0.04 0.73 0.54 0.46 1.0
## v11 -0.17 0.76 0.55 0.45 1.1
## v12 0.39 0.17 0.21 0.79 1.4
## v13 0.72 0.08 0.55 0.45 1.0
## v14 0.83 -0.31 0.69 0.31 1.3
## v15 0.72 0.12 0.57 0.43 1.1
## v16 0.68 -0.09 0.44 0.56 1.0
## v17 0.82 -0.04 0.66 0.34 1.0
## v18 0.51 0.20 0.34 0.66 1.3
## v19 0.61 0.07 0.39 0.61 1.0
##
## ML1 ML2
## SS loadings 6.54 2.94
## Proportion Var 0.34 0.15
## Cumulative Var 0.34 0.50
## Proportion Explained 0.69 0.31
## Cumulative Proportion 0.69 1.00
##
## With factor correlations of
## ML1 ML2
## ML1 1.0 0.2
## ML2 0.2 1.0
##
## Mean item complexity = 1.1
## Test of the hypothesis that 2 factors are sufficient.
##
## The degrees of freedom for the null model are 171 and the objective function was 99.74 with Chi Square of 88952.17
## The degrees of freedom for the model are 134 and the objective function was 90.69
##
## The root mean square of the residuals (RMSR) is 0.11
## The df corrected root mean square of the residuals is 0.12
##
## The harmonic number of observations is 900 with the empirical chi square 3580.16 with prob < 0
## The total number of observations was 900 with Likelihood Chi Square = 80761.97 with prob < 0
##
## Tucker Lewis Index of factoring reliability = -0.161
## RMSEA index = 0.822 and the 90 % confidence intervals are 0.813 0.823
## BIC = 79850.45
## Fit based upon off diagonal values = 0.93
## Measures of factor score adequacy
## ML1 ML2
## Correlation of (regression) scores with factors 0.97 0.93
## Multiple R square of scores with factors 0.94 0.86
## Minimum correlation of possible factor scores 0.87 0.73
print(f2$loadings, cutoff = 0.4)
##
## Loadings:
## ML1 ML2
## v1 0.754
## v2 0.727
## v3 0.736
## v4 0.644
## v5 0.545
## v6 0.581
## v7 0.671
## v8 0.641
## v9 0.708
## v10 0.729
## v11 0.757
## v12
## v13 0.722
## v14 0.833
## v15 0.722
## v16 0.678
## v17 0.818
## v18 0.512
## v19 0.606
##
## ML1 ML2
## SS loadings 6.462 2.864
## Proportion Var 0.340 0.151
## Cumulative Var 0.340 0.491
fa.diagram(f2, cut = 0, simple = T)
#parallel plot
fa.parallel(p11$rho)
## Warning in fa.parallel(p11$rho): It seems as if you are using a correlation
## matrix, but have not specified the number of cases. The number of subjects
## is arbitrarily set to be 100
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs
## = np.obs, : The estimated weights for the factor scores are probably
## incorrect. Try a different factor extraction method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate =
## rotate, : A loading greater than abs(1) was detected. Examine the loadings
## carefully.
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs
## = np.obs, : The estimated weights for the factor scores are probably
## incorrect. Try a different factor extraction method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate =
## rotate, : An ultra-Heywood case was detected. Examine the results carefully
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs
## = np.obs, : The estimated weights for the factor scores are probably
## incorrect. Try a different factor extraction method.
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs
## = np.obs, : The estimated weights for the factor scores are probably
## incorrect. Try a different factor extraction method.
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs
## = np.obs, : The estimated weights for the factor scores are probably
## incorrect. Try a different factor extraction method.
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs
## = np.obs, : The estimated weights for the factor scores are probably
## incorrect. Try a different factor extraction method.
## Parallel analysis suggests that the number of factors = 3 and the number of components = 1
#scree plot
scree(p11$rho)
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs
## = np.obs, : The estimated weights for the factor scores are probably
## incorrect. Try a different factor extraction method.
#EFA factor 1 ~ 2
#1
ff1 <- fa(p11$rho, 1, n.obs = 900, fm = "ml")
print(ff1)
## Factor Analysis using method = ml
## Call: fa(r = p11$rho, nfactors = 1, n.obs = 900, fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 h2 u2 com
## K1 0.63 0.393 0.61 1
## K2 0.40 0.156 0.84 1
## K3 0.59 0.352 0.65 1
## K4 0.23 0.052 0.95 1
## K5 0.57 0.320 0.68 1
## K6 0.84 0.706 0.29 1
## K7 0.70 0.488 0.51 1
## K8 0.82 0.679 0.32 1
## K9 0.88 0.778 0.22 1
## K10 0.53 0.280 0.72 1
## K11 0.70 0.484 0.52 1
##
## ML1
## SS loadings 4.69
## Proportion Var 0.43
##
## Mean item complexity = 1
## Test of the hypothesis that 1 factor is sufficient.
##
## The degrees of freedom for the null model are 55 and the objective function was 27.88 with Chi Square of 24939.26
## The degrees of freedom for the model are 44 and the objective function was 23.39
##
## The root mean square of the residuals (RMSR) is 0.12
## The df corrected root mean square of the residuals is 0.14
##
## The harmonic number of observations is 900 with the empirical chi square 1520.35 with prob < 4.6e-290
## The total number of observations was 900 with Likelihood Chi Square = 20910.96 with prob < 0
##
## Tucker Lewis Index of factoring reliability = -0.049
## RMSEA index = 0.728 and the 90 % confidence intervals are 0.718 0.735
## BIC = 20611.65
## Fit based upon off diagonal values = 0.92
## Measures of factor score adequacy
## ML1
## Correlation of (regression) scores with factors 0.96
## Multiple R square of scores with factors 0.92
## Minimum correlation of possible factor scores 0.85
print(ff1$loadings, cutoff = 0.4)
##
## Loadings:
## ML1
## K1 0.627
## K2
## K3 0.594
## K4
## K5 0.565
## K6 0.840
## K7 0.699
## K8 0.824
## K9 0.882
## K10 0.529
## K11 0.695
##
## ML1
## SS loadings 4.687
## Proportion Var 0.426
fa.diagram(ff1, cut = 0, simple = T)
#2
ff2 <- fa(p11$rho, 2, n.obs = 900, fm = "ml", rotate = "oblimin")
print(ff2)
## Factor Analysis using method = ml
## Call: fa(r = p11$rho, nfactors = 2, n.obs = 900, rotate = "oblimin",
## fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML2 ML1 h2 u2 com
## K1 0.02 0.99 0.995 0.005 1.0
## K2 -0.05 0.69 0.443 0.557 1.0
## K3 0.40 0.33 0.389 0.611 1.9
## K4 0.20 0.03 0.047 0.953 1.0
## K5 0.57 0.01 0.329 0.671 1.0
## K6 0.60 0.40 0.756 0.244 1.7
## K7 0.57 0.20 0.485 0.515 1.3
## K8 0.89 -0.08 0.737 0.263 1.0
## K9 0.86 0.07 0.807 0.193 1.0
## K10 0.58 -0.06 0.302 0.698 1.0
## K11 0.80 -0.14 0.542 0.458 1.1
##
## ML2 ML1
## SS loadings 3.88 1.95
## Proportion Var 0.35 0.18
## Cumulative Var 0.35 0.53
## Proportion Explained 0.67 0.33
## Cumulative Proportion 0.67 1.00
##
## With factor correlations of
## ML2 ML1
## ML2 1.00 0.49
## ML1 0.49 1.00
##
## Mean item complexity = 1.2
## Test of the hypothesis that 2 factors are sufficient.
##
## The degrees of freedom for the null model are 55 and the objective function was 27.88 with Chi Square of 24939.26
## The degrees of freedom for the model are 34 and the objective function was 22.43
##
## The root mean square of the residuals (RMSR) is 0.1
## The df corrected root mean square of the residuals is 0.12
##
## The harmonic number of observations is 900 with the empirical chi square 935.27 with prob < 2.1e-174
## The total number of observations was 900 with Likelihood Chi Square = 20037.62 with prob < 0
##
## Tucker Lewis Index of factoring reliability = -0.302
## RMSEA index = 0.812 and the 90 % confidence intervals are 0.8 0.818
## BIC = 19806.34
## Fit based upon off diagonal values = 0.95
## Measures of factor score adequacy
## ML2 ML1
## Correlation of (regression) scores with factors 0.96 1.00
## Multiple R square of scores with factors 0.92 0.99
## Minimum correlation of possible factor scores 0.85 0.99
print(ff2$loadings, cutoff = 0.4)
##
## Loadings:
## ML2 ML1
## K1 0.988
## K2 0.690
## K3
## K4
## K5 0.569
## K6 0.602
## K7 0.572
## K8 0.893
## K9 0.861
## K10 0.577
## K11 0.796
##
## ML2 ML1
## SS loadings 3.720 1.794
## Proportion Var 0.338 0.163
## Cumulative Var 0.338 0.501
fa.diagram(ff2, cut = 0, simple = T)
Mplus code
Mplus result : Factor1
Mplus result : Factor2
Mplus result : Factor3
Mplus code
Mplus result : Factor1
Mplus result : Factor2
Mplus result : Factor3
#echo = F : R code보이지 않고 결과만 출력.
#echo = T : R code와 결과 모두 출력.
setwd("C:/Users/LG/Desktop/old")
library(haven)
library(dplyr)
library(ggplot2)
library(reshape2)
data <- read_spss("SH.sav")
head(data)
## # A tibble: 6 x 49
## pid W07OLDNEW w07wgt_c w07wgt_ac w07C420 w07C550 연령 성별 교육수준
## <dbl> <dbl+lbl> <dbl> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl>
## 1 11 1 [기존패널]~ 1395. 1362. 1 [도움을~ 1 [예] 85 5 2
## 2 21 1 [기존패널]~ 3203. 3201. 1 [도움을~ 1 [예] 63 5 4
## 3 22 1 [기존패널]~ 5361. 5398. 1 [도움을~ 1 [예] 64 1 4
## 4 41 1 [기존패널]~ 1087. 1058. 2 [가끔]~ 1 [예] 82 5 1
## 5 42 1 [기존패널]~ 913. 930. 2 [가끔]~ 1 [예] 83 1 3
## 6 51 1 [기존패널]~ 1942. 1809. 2 [가끔]~ 1 [예] 76 1 1
## # ... with 40 more variables: 가구소득 <dbl>, 주관적건강상태 <dbl>,
## # ADL <dbl>, IADL <dbl>, 우울감 <dbl>, 치매진단 <dbl+lbl>,
## # 우울증진단 <dbl+lbl>, 정신질환진단 <dbl+lbl>, 연구대상자 <dbl+lbl>,
## # KMMSE_총점수 <dbl>, v1 <dbl>, v2 <dbl>, v3 <dbl>, v4 <dbl>, v5 <dbl>,
## # v6 <dbl>, v7 <dbl>, v8 <dbl>, v9 <dbl>, v10 <dbl>, v11 <dbl>,
## # v12 <dbl>, v13 <dbl>, v14 <dbl>, v15 <dbl>, v16 <dbl>, v17 <dbl>,
## # v18 <dbl>, v19 <dbl>, K1 <dbl>, K2 <dbl>, K3 <dbl>, K4 <dbl>,
## # K5 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>, K9 <dbl>, K10 <dbl>, K11 <dbl>
tail(data)
## # A tibble: 6 x 49
## pid W07OLDNEW w07wgt_c w07wgt_ac w07C420 w07C550 연령 성별 교육수준
## <dbl> <dbl+lbl> <dbl> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl>
## 1 68001 2 [신규패널]~ NA 743. 1 [도움을~ 1 [예] 55 5 3
## 2 68011 2 [신규패널]~ NA 840. 1 [도움을~ 1 [예] 56 5 3
## 3 68021 2 [신규패널]~ NA 1213. 1 [도움을~ 1 [예] 56 1 2
## 4 68041 2 [신규패널]~ NA 4772. 1 [도움을~ 1 [예] 55 1 2
## 5 68051 2 [신규패널]~ NA 4911. 1 [도움을~ 1 [예] 56 1 3
## 6 68052 2 [신규패널]~ NA 2835. 1 [도움을~ 1 [예] 55 5 3
## # ... with 40 more variables: 가구소득 <dbl>, 주관적건강상태 <dbl>,
## # ADL <dbl>, IADL <dbl>, 우울감 <dbl>, 치매진단 <dbl+lbl>,
## # 우울증진단 <dbl+lbl>, 정신질환진단 <dbl+lbl>, 연구대상자 <dbl+lbl>,
## # KMMSE_총점수 <dbl>, v1 <dbl>, v2 <dbl>, v3 <dbl>, v4 <dbl>, v5 <dbl>,
## # v6 <dbl>, v7 <dbl>, v8 <dbl>, v9 <dbl>, v10 <dbl>, v11 <dbl>,
## # v12 <dbl>, v13 <dbl>, v14 <dbl>, v15 <dbl>, v16 <dbl>, v17 <dbl>,
## # v18 <dbl>, v19 <dbl>, K1 <dbl>, K2 <dbl>, K3 <dbl>, K4 <dbl>,
## # K5 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>, K9 <dbl>, K10 <dbl>, K11 <dbl>
#연구대상자 선택(치매의심)
dementia <- data %>% filter(연구대상자 == 1)
head(dementia)
## # A tibble: 6 x 49
## pid W07OLDNEW w07wgt_c w07wgt_ac w07C420 w07C550 연령 성별 교육수준
## <dbl> <dbl+lbl> <dbl> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl>
## 1 11 1 [기존패널]~ 1395. 1362. 1 [도움을~ 1 [예] 85 5 2
## 2 21 1 [기존패널]~ 3203. 3201. 1 [도움을~ 1 [예] 63 5 4
## 3 22 1 [기존패널]~ 5361. 5398. 1 [도움을~ 1 [예] 64 1 4
## 4 41 1 [기존패널]~ 1087. 1058. 2 [가끔]~ 1 [예] 82 5 1
## 5 42 1 [기존패널]~ 913. 930. 2 [가끔]~ 1 [예] 83 1 3
## 6 51 1 [기존패널]~ 1942. 1809. 2 [가끔]~ 1 [예] 76 1 1
## # ... with 40 more variables: 가구소득 <dbl>, 주관적건강상태 <dbl>,
## # ADL <dbl>, IADL <dbl>, 우울감 <dbl>, 치매진단 <dbl+lbl>,
## # 우울증진단 <dbl+lbl>, 정신질환진단 <dbl+lbl>, 연구대상자 <dbl+lbl>,
## # KMMSE_총점수 <dbl>, v1 <dbl>, v2 <dbl>, v3 <dbl>, v4 <dbl>, v5 <dbl>,
## # v6 <dbl>, v7 <dbl>, v8 <dbl>, v9 <dbl>, v10 <dbl>, v11 <dbl>,
## # v12 <dbl>, v13 <dbl>, v14 <dbl>, v15 <dbl>, v16 <dbl>, v17 <dbl>,
## # v18 <dbl>, v19 <dbl>, K1 <dbl>, K2 <dbl>, K3 <dbl>, K4 <dbl>,
## # K5 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>, K9 <dbl>, K10 <dbl>, K11 <dbl>
tail(dementia)
## # A tibble: 6 x 49
## pid W07OLDNEW w07wgt_c w07wgt_ac w07C420 w07C550 연령 성별 교육수준
## <dbl> <dbl+lbl> <dbl> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl>
## 1 65712 2 [신규패널]~ NA 45.6 1 [도움을~ 1 [예] 78 5 1
## 2 66433 2 [신규패널]~ NA 30.6 3 [대부분~ 1 [예] 88 5 1
## 3 67191 2 [신규패널]~ NA 751. 1 [도움을~ 1 [예] 56 5 1
## 4 67431 2 [신규패널]~ NA 668. 1 [도움을~ 1 [예] 55 5 1
## 5 67551 2 [신규패널]~ NA 1264. 1 [도움을~ 1 [예] 56 1 4
## 6 67701 2 [신규패널]~ NA 1218. 1 [도움을~ 1 [예] 55 1 3
## # ... with 40 more variables: 가구소득 <dbl>, 주관적건강상태 <dbl>,
## # ADL <dbl>, IADL <dbl>, 우울감 <dbl>, 치매진단 <dbl+lbl>,
## # 우울증진단 <dbl+lbl>, 정신질환진단 <dbl+lbl>, 연구대상자 <dbl+lbl>,
## # KMMSE_총점수 <dbl>, v1 <dbl>, v2 <dbl>, v3 <dbl>, v4 <dbl>, v5 <dbl>,
## # v6 <dbl>, v7 <dbl>, v8 <dbl>, v9 <dbl>, v10 <dbl>, v11 <dbl>,
## # v12 <dbl>, v13 <dbl>, v14 <dbl>, v15 <dbl>, v16 <dbl>, v17 <dbl>,
## # v18 <dbl>, v19 <dbl>, K1 <dbl>, K2 <dbl>, K3 <dbl>, K4 <dbl>,
## # K5 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>, K9 <dbl>, K10 <dbl>, K11 <dbl>
nrow(dementia)
## [1] 1827
#치매의심 대상자(1 ~ 900)가 응답한 19개 문항
demet19 <- dementia %>% .[c(1:900), c(20:38)]
head(demet19)
## # A tibble: 6 x 19
## v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 1 1 1 1 1 1 0 1 1 0 2
## 2 1 1 1 1 3 2 1 1 1 0 0 3
## 3 2 1 1 1 2 3 1 1 0 0 1 2
## 4 2 1 1 1 2 2 1 1 1 1 0 2
## 5 2 1 1 1 3 3 1 1 1 1 0 1
## 6 2 1 1 1 2 2 1 1 0 1 0 2
## # ... with 7 more variables: v13 <dbl>, v14 <dbl>, v15 <dbl>, v16 <dbl>,
## # v17 <dbl>, v18 <dbl>, v19 <dbl>
tail(demet19)
## # A tibble: 6 x 19
## v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 3 1 1 1 4 1 1 1 1 1 1 1
## 2 3 1 1 1 4 2 1 0 1 1 0 1
## 3 1 1 1 1 4 3 1 1 1 0 0 2
## 4 3 1 1 1 4 2 1 0 1 1 1 0
## 5 3 1 1 1 4 1 1 0 1 1 1 0
## 6 3 1 1 1 4 0 0 1 1 1 1 0
## # ... with 7 more variables: v13 <dbl>, v14 <dbl>, v15 <dbl>, v16 <dbl>,
## # v17 <dbl>, v18 <dbl>, v19 <dbl>
nrow(demet19)
## [1] 900
#치매의심 대상자(1 ~ 900)가 응답한 11개 문항
demet11 <- dementia %>% .[c(1:900), c(39:49)]
head(demet11)
## # A tibble: 6 x 11
## K1 K2 K3 K4 K5 K6 K7 K8 K9 K10 K11
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 3 2 1 3 2 2 0 1 1 0 0
## 2 3 4 2 3 3 2 1 2 1 1 1
## 3 4 3 3 3 2 2 1 2 1 1 1
## 4 4 3 2 4 2 2 1 1 1 1 1
## 5 4 4 3 4 1 2 1 2 1 1 0
## 6 4 3 2 3 2 2 1 1 1 0 0
tail(demet11)
## # A tibble: 6 x 11
## K1 K2 K3 K4 K5 K6 K7 K8 K9 K10 K11
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 5 5 1 5 1 2 1 0 0 0 0
## 2 5 5 2 3 1 2 1 1 1 1 0
## 3 3 5 3 3 2 2 1 0 0 0 0
## 4 5 5 2 4 0 2 1 0 0 0 0
## 5 5 5 1 4 0 2 1 1 1 1 0
## 6 5 5 0 4 0 2 1 0 0 0 0
nrow(demet11)
## [1] 900
#19문항 결측치 확인
colSums(is.na(demet19))
## v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 v18
## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## v19
## 0
#11문항 결측치 확인
colSums(is.na(demet11))
## K1 K2 K3 K4 K5 K6 K7 K8 K9 K10 K11
## 0 0 0 0 0 0 0 0 0 0 0
#19문항 요약, 평균, 표준편차
as.table(apply(demet19, 2, summary))
## v1 v2 v3 v4 v5 v6
## Min. 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## 1st Qu. 1.0000000 1.0000000 1.0000000 1.0000000 2.0000000 1.0000000
## Median 2.0000000 1.0000000 1.0000000 1.0000000 3.0000000 2.0000000
## Mean 2.0722222 0.8333333 0.9500000 0.9477778 2.8444444 1.7311111
## 3rd Qu. 3.0000000 1.0000000 1.0000000 1.0000000 4.0000000 3.0000000
## Max. 3.0000000 1.0000000 1.0000000 1.0000000 4.0000000 3.0000000
## v7 v8 v9 v10 v11 v12
## Min. 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## 1st Qu. 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## Median 1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000
## Mean 0.6011111 0.2344444 0.3422222 0.2966667 0.2122222 0.9111111
## 3rd Qu. 1.0000000 0.0000000 1.0000000 1.0000000 0.0000000 2.0000000
## Max. 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 3.0000000
## v13 v14 v15 v16 v17 v18
## Min. 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## 1st Qu. 1.0000000 1.0000000 1.0000000 1.0000000 0.0000000 0.0000000
## Median 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
## Mean 0.9355556 0.9211111 0.8444444 1.2477778 0.7166667 0.6600000
## 3rd Qu. 1.0000000 1.0000000 1.0000000 2.0000000 1.0000000 1.0000000
## Max. 1.0000000 1.0000000 1.0000000 3.0000000 1.0000000 1.0000000
## v19
## Min. 0.0000000
## 1st Qu. 0.0000000
## Median 0.0000000
## Mean 0.3888889
## 3rd Qu. 1.0000000
## Max. 1.0000000
as.table(apply(demet19, 2, mean))
## v1 v2 v3 v4 v5 v6 v7
## 2.0722222 0.8333333 0.9500000 0.9477778 2.8444444 1.7311111 0.6011111
## v8 v9 v10 v11 v12 v13 v14
## 0.2344444 0.3422222 0.2966667 0.2122222 0.9111111 0.9355556 0.9211111
## v15 v16 v17 v18 v19
## 0.8444444 1.2477778 0.7166667 0.6600000 0.3888889
as.table(apply(demet19, 2, sd))
## v1 v2 v3 v4 v5 v6 v7
## 0.9328426 0.3728852 0.2180661 0.2225986 1.1564118 0.9999604 0.4899421
## v8 v9 v10 v11 v12 v13 v14
## 0.4238866 0.4747174 0.4570423 0.4091087 0.8804444 0.2456795 0.2697151
## v15 v16 v17 v18 v19
## 0.3626350 0.8771893 0.4508674 0.4739722 0.4877691
#11문항 요약, 평균, 표준편차
as.table(apply(demet11, 2, summary))
## K1 K2 K3 K4 K5 K6
## Min. 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## 1st Qu. 3.0000000 3.0000000 1.0000000 0.0000000 0.0000000 2.0000000
## Median 4.0000000 4.0000000 2.0000000 1.0000000 1.0000000 2.0000000
## Mean 3.8555556 3.7922222 1.7311111 1.6866667 0.9111111 1.8566667
## 3rd Qu. 5.0000000 5.0000000 3.0000000 3.0000000 2.0000000 2.0000000
## Max. 5.0000000 5.0000000 3.0000000 5.0000000 3.0000000 2.0000000
## K7 K8 K9 K10 K11
## Min. 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## 1st Qu. 1.0000000 1.0000000 0.0000000 0.0000000 0.0000000
## Median 1.0000000 1.0000000 1.0000000 1.0000000 0.0000000
## Mean 0.8444444 1.2477778 0.7166667 0.6600000 0.3888889
## 3rd Qu. 1.0000000 2.0000000 1.0000000 1.0000000 1.0000000
## Max. 1.0000000 3.0000000 1.0000000 1.0000000 1.0000000
as.table(apply(demet11, 2, mean))
## K1 K2 K3 K4 K5 K6 K7
## 3.8555556 3.7922222 1.7311111 1.6866667 0.9111111 1.8566667 0.8444444
## K8 K9 K10 K11
## 1.2477778 0.7166667 0.6600000 0.3888889
as.table(apply(demet11, 2, sd))
## K1 K2 K3 K4 K5 K6 K7
## 1.2930989 1.2630390 0.9999604 1.5427321 0.8804444 0.4480957 0.3626350
## K8 K9 K10 K11
## 0.8771893 0.4508674 0.4739722 0.4877691
#19문항 histogram
ggplot(data = melt(demet19), aes(x = value)) +
facet_wrap(~variable) + geom_histogram()
## No id variables; using all as measure variables
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#19문항 box plot
ggplot(data = melt(demet19), aes(x = variable, y = value)) +
geom_boxplot(aes(fill = variable))
## No id variables; using all as measure variables
#11문항 histogram
ggplot(data = melt(demet11), aes(x = value)) +
facet_wrap(~variable) + geom_histogram()
## No id variables; using all as measure variables
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#11문항 box plot
ggplot(data = melt(demet11), aes(x = variable, y = value)) +
geom_boxplot(aes(fill = variable))
## No id variables; using all as measure variables
library(psych)
#parallel plot
fa.parallel(demet19)
## Parallel analysis suggests that the number of factors = 6 and the number of components = 3
#scree plot
scree(demet19)
#EFA factor 1 ~ 6
#1
cf1 <- fa(demet19, 1, fm = "ml")
print(cf1)
## Factor Analysis using method = ml
## Call: fa(r = demet19, nfactors = 1, fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 h2 u2 com
## v1 0.65 0.4283 0.57 1
## v2 0.65 0.4225 0.58 1
## v3 0.67 0.4453 0.55 1
## v4 0.71 0.4981 0.50 1
## v5 0.54 0.2864 0.71 1
## v6 0.51 0.2625 0.74 1
## v7 0.37 0.1345 0.87 1
## v8 0.13 0.0172 0.98 1
## v9 0.18 0.0320 0.97 1
## v10 0.20 0.0412 0.96 1
## v11 0.09 0.0075 0.99 1
## v12 0.38 0.1460 0.85 1
## v13 0.61 0.3734 0.63 1
## v14 0.62 0.3792 0.62 1
## v15 0.59 0.3511 0.65 1
## v16 0.50 0.2516 0.75 1
## v17 0.57 0.3195 0.68 1
## v18 0.44 0.1910 0.81 1
## v19 0.35 0.1245 0.88 1
##
## ML1
## SS loadings 4.71
## Proportion Var 0.25
##
## Mean item complexity = 1
## Test of the hypothesis that 1 factor is sufficient.
##
## The degrees of freedom for the null model are 171 and the objective function was 6.21 with Chi Square of 5534.67
## The degrees of freedom for the model are 152 and the objective function was 2.51
##
## The root mean square of the residuals (RMSR) is 0.11
## The df corrected root mean square of the residuals is 0.11
##
## The harmonic number of observations is 900 with the empirical chi square 3614.63 with prob < 0
## The total number of observations was 900 with Likelihood Chi Square = 2233.7 with prob < 0
##
## Tucker Lewis Index of factoring reliability = 0.563
## RMSEA index = 0.124 and the 90 % confidence intervals are 0.119 0.128
## BIC = 1199.74
## Fit based upon off diagonal values = 0.84
## Measures of factor score adequacy
## ML1
## Correlation of (regression) scores with factors 0.94
## Multiple R square of scores with factors 0.88
## Minimum correlation of possible factor scores 0.76
#h2 = communality = 요인부하량의 제곱 = 요인이 각 문항의 분산을 설명하는 정도
#v1문항 분산의 약 43%는 ML1 요인으로 설명됨.
#u2 = uniqueness = 각 문항의 분산에서 요인으로 설명되지 않는 정도
print(cf1$loadings, cutoff = 0.4)
##
## Loadings:
## ML1
## v1 0.654
## v2 0.650
## v3 0.667
## v4 0.706
## v5 0.535
## v6 0.512
## v7
## v8
## v9
## v10
## v11
## v12
## v13 0.611
## v14 0.616
## v15 0.593
## v16 0.502
## v17 0.565
## v18 0.437
## v19
##
## ML1
## SS loadings 4.712
## Proportion Var 0.248
#cutoff = 0.4는 요인부하량 가운데 부하량이 0.4이상인 것만 표시함.
fa.diagram(cf1, cut = 0, simple = T)
#2
cf2 <- fa(demet19, 2, fm = "ml", rotate = "oblimin")
print(cf2)
## Factor Analysis using method = ml
## Call: fa(r = demet19, nfactors = 2, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 ML2 h2 u2 com
## v1 0.68 -0.04 0.45 0.55 1.0
## v2 0.64 0.03 0.43 0.57 1.0
## v3 0.68 -0.02 0.45 0.55 1.0
## v4 0.71 0.00 0.50 0.50 1.0
## v5 0.59 -0.12 0.33 0.67 1.1
## v6 0.53 -0.03 0.27 0.73 1.0
## v7 0.17 0.60 0.44 0.56 1.2
## v8 -0.05 0.51 0.25 0.75 1.0
## v9 -0.04 0.62 0.38 0.62 1.0
## v10 -0.02 0.64 0.40 0.60 1.0
## v11 -0.09 0.51 0.24 0.76 1.1
## v12 0.33 0.14 0.15 0.85 1.3
## v13 0.60 0.04 0.37 0.63 1.0
## v14 0.61 0.01 0.38 0.62 1.0
## v15 0.55 0.13 0.35 0.65 1.1
## v16 0.53 -0.08 0.27 0.73 1.0
## v17 0.54 0.06 0.32 0.68 1.0
## v18 0.38 0.18 0.21 0.79 1.4
## v19 0.29 0.18 0.14 0.86 1.6
##
## ML1 ML2
## SS loadings 4.49 1.84
## Proportion Var 0.24 0.10
## Cumulative Var 0.24 0.33
## Proportion Explained 0.71 0.29
## Cumulative Proportion 0.71 1.00
##
## With factor correlations of
## ML1 ML2
## ML1 1.00 0.25
## ML2 0.25 1.00
##
## Mean item complexity = 1.1
## Test of the hypothesis that 2 factors are sufficient.
##
## The degrees of freedom for the null model are 171 and the objective function was 6.21 with Chi Square of 5534.67
## The degrees of freedom for the model are 134 and the objective function was 1.69
##
## The root mean square of the residuals (RMSR) is 0.07
## The df corrected root mean square of the residuals is 0.08
##
## The harmonic number of observations is 900 with the empirical chi square 1700.49 with prob < 2.5e-269
## The total number of observations was 900 with Likelihood Chi Square = 1505 with prob < 2.2e-230
##
## Tucker Lewis Index of factoring reliability = 0.673
## RMSEA index = 0.107 and the 90 % confidence intervals are 0.102 0.112
## BIC = 593.48
## Fit based upon off diagonal values = 0.92
## Measures of factor score adequacy
## ML1 ML2
## Correlation of (regression) scores with factors 0.94 0.86
## Multiple R square of scores with factors 0.88 0.74
## Minimum correlation of possible factor scores 0.76 0.49
print(cf2$loadings, cutoff = 0.4)
##
## Loadings:
## ML1 ML2
## v1 0.678
## v2 0.643
## v3 0.678
## v4 0.711
## v5 0.589
## v6 0.528
## v7 0.603
## v8 0.505
## v9 0.624
## v10 0.640
## v11 0.507
## v12
## v13 0.599
## v14 0.613
## v15 0.547
## v16 0.533
## v17 0.545
## v18
## v19
##
## ML1 ML2
## SS loadings 4.456 1.807
## Proportion Var 0.235 0.095
## Cumulative Var 0.235 0.330
fa.diagram(cf2, cut = 0, simple = T)
#3
cf3 <- fa(demet19, 3, fm = "ml", rotate = "oblimin")
print(cf3)
## Factor Analysis using method = ml
## Call: fa(r = demet19, nfactors = 3, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 ML2 ML3 h2 u2 com
## v1 0.35 0.40 -0.02 0.40 0.60 2.0
## v2 0.48 0.24 0.05 0.41 0.59 1.5
## v3 0.84 -0.05 0.00 0.67 0.33 1.0
## v4 0.90 -0.06 0.01 0.77 0.23 1.0
## v5 0.44 0.18 -0.09 0.29 0.71 1.4
## v6 0.12 0.52 -0.05 0.34 0.66 1.1
## v7 0.00 0.23 0.59 0.45 0.55 1.3
## v8 -0.02 -0.03 0.50 0.24 0.76 1.0
## v9 0.00 -0.04 0.63 0.39 0.61 1.0
## v10 0.04 -0.05 0.65 0.42 0.58 1.0
## v11 0.03 -0.13 0.51 0.26 0.74 1.1
## v12 -0.05 0.50 0.11 0.26 0.74 1.1
## v13 0.51 0.16 0.06 0.38 0.62 1.2
## v14 0.50 0.20 0.02 0.38 0.62 1.3
## v15 0.24 0.41 0.13 0.36 0.64 1.9
## v16 0.00 0.71 -0.13 0.49 0.51 1.1
## v17 0.02 0.71 0.02 0.52 0.48 1.0
## v18 0.01 0.48 0.17 0.30 0.70 1.2
## v19 -0.10 0.51 0.15 0.27 0.73 1.3
##
## ML1 ML2 ML3
## SS loadings 2.91 2.85 1.84
## Proportion Var 0.15 0.15 0.10
## Cumulative Var 0.15 0.30 0.40
## Proportion Explained 0.38 0.38 0.24
## Cumulative Proportion 0.38 0.76 1.00
##
## With factor correlations of
## ML1 ML2 ML3
## ML1 1.00 0.45 0.20
## ML2 0.45 1.00 0.18
## ML3 0.20 0.18 1.00
##
## Mean item complexity = 1.2
## Test of the hypothesis that 3 factors are sufficient.
##
## The degrees of freedom for the null model are 171 and the objective function was 6.21 with Chi Square of 5534.67
## The degrees of freedom for the model are 117 and the objective function was 0.83
##
## The root mean square of the residuals (RMSR) is 0.05
## The df corrected root mean square of the residuals is 0.05
##
## The harmonic number of observations is 900 with the empirical chi square 629.58 with prob < 3.3e-71
## The total number of observations was 900 with Likelihood Chi Square = 742.61 with prob < 1.2e-91
##
## Tucker Lewis Index of factoring reliability = 0.829
## RMSEA index = 0.078 and the 90 % confidence intervals are 0.072 0.082
## BIC = -53.27
## Fit based upon off diagonal values = 0.97
## Measures of factor score adequacy
## ML1 ML2 ML3
## Correlation of (regression) scores with factors 0.94 0.91 0.86
## Multiple R square of scores with factors 0.89 0.82 0.75
## Minimum correlation of possible factor scores 0.77 0.65 0.49
print(cf3$loadings, cutoff = 0.4)
##
## Loadings:
## ML1 ML2 ML3
## v1
## v2 0.477
## v3 0.844
## v4 0.900
## v5 0.441
## v6 0.521
## v7 0.593
## v8 0.500
## v9 0.631
## v10 0.647
## v11 0.511
## v12 0.503
## v13 0.508
## v14 0.495
## v15 0.408
## v16 0.710
## v17 0.709
## v18 0.483
## v19 0.512
##
## ML1 ML2 ML3
## SS loadings 2.659 2.592 1.795
## Proportion Var 0.140 0.136 0.094
## Cumulative Var 0.140 0.276 0.371
fa.diagram(cf3, cut = 0, simple = T)
#4
cf4 <- fa(demet19, 4, fm = "ml", rotate = "oblimin")
print(cf4)
## Factor Analysis using method = ml
## Call: fa(r = demet19, nfactors = 4, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML2 ML1 ML3 ML4 h2 u2 com
## v1 0.04 -0.04 0.03 0.88 0.77 0.23 1.0
## v2 0.10 0.29 0.08 0.38 0.45 0.55 2.1
## v3 -0.02 0.79 0.00 0.05 0.66 0.34 1.0
## v4 -0.01 0.94 0.00 -0.03 0.84 0.16 1.0
## v5 -0.10 0.16 -0.05 0.64 0.47 0.53 1.2
## v6 0.40 0.04 -0.03 0.24 0.33 0.67 1.7
## v7 0.19 0.00 0.59 0.05 0.45 0.55 1.2
## v8 0.01 0.01 0.49 -0.07 0.24 0.76 1.0
## v9 -0.08 -0.03 0.64 0.05 0.40 0.60 1.0
## v10 -0.04 0.03 0.65 0.00 0.42 0.58 1.0
## v11 -0.09 0.05 0.50 -0.08 0.25 0.75 1.1
## v12 0.55 0.01 0.09 -0.08 0.29 0.71 1.1
## v13 0.14 0.45 0.06 0.11 0.37 0.63 1.4
## v14 0.22 0.48 0.01 0.03 0.38 0.62 1.4
## v15 0.34 0.18 0.13 0.16 0.35 0.65 2.4
## v16 0.67 -0.01 -0.14 0.10 0.49 0.51 1.1
## v17 0.75 0.07 0.00 -0.04 0.58 0.42 1.0
## v18 0.44 0.01 0.16 0.07 0.29 0.71 1.3
## v19 0.50 -0.07 0.14 0.01 0.27 0.73 1.2
##
## ML2 ML1 ML3 ML4
## SS loadings 2.41 2.35 1.84 1.72
## Proportion Var 0.13 0.12 0.10 0.09
## Cumulative Var 0.13 0.25 0.35 0.44
## Proportion Explained 0.29 0.28 0.22 0.21
## Cumulative Proportion 0.29 0.57 0.79 1.00
##
## With factor correlations of
## ML2 ML1 ML3 ML4
## ML2 1.00 0.37 0.19 0.47
## ML1 0.37 1.00 0.20 0.54
## ML3 0.19 0.20 1.00 0.13
## ML4 0.47 0.54 0.13 1.00
##
## Mean item complexity = 1.3
## Test of the hypothesis that 4 factors are sufficient.
##
## The degrees of freedom for the null model are 171 and the objective function was 6.21 with Chi Square of 5534.67
## The degrees of freedom for the model are 101 and the objective function was 0.5
##
## The root mean square of the residuals (RMSR) is 0.04
## The df corrected root mean square of the residuals is 0.05
##
## The harmonic number of observations is 900 with the empirical chi square 378.02 with prob < 1.3e-33
## The total number of observations was 900 with Likelihood Chi Square = 442.56 with prob < 2.8e-44
##
## Tucker Lewis Index of factoring reliability = 0.892
## RMSEA index = 0.062 and the 90 % confidence intervals are 0.056 0.067
## BIC = -244.48
## Fit based upon off diagonal values = 0.98
## Measures of factor score adequacy
## ML2 ML1 ML3 ML4
## Correlation of (regression) scores with factors 0.90 0.95 0.86 0.92
## Multiple R square of scores with factors 0.81 0.90 0.75 0.84
## Minimum correlation of possible factor scores 0.62 0.80 0.49 0.68
print(cf4$loadings, cutoff = 0.4)
##
## Loadings:
## ML2 ML1 ML3 ML4
## v1 0.878
## v2
## v3 0.789
## v4 0.939
## v5 0.638
## v6 0.404
## v7 0.594
## v8 0.494
## v9 0.644
## v10 0.647
## v11 0.504
## v12 0.546
## v13 0.448
## v14 0.477
## v15
## v16 0.667
## v17 0.754
## v18 0.443
## v19 0.501
##
## ML2 ML1 ML3 ML4
## SS loadings 2.184 2.090 1.789 1.463
## Proportion Var 0.115 0.110 0.094 0.077
## Cumulative Var 0.115 0.225 0.319 0.396
fa.diagram(cf4, cut = 0, simple = T)
#5
cf5 <- fa(demet19, 5, fm = "ml", rotate = "oblimin")
print(cf5)
## Factor Analysis using method = ml
## Call: fa(r = demet19, nfactors = 5, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML2 ML4 ML5 ML3 ML1 h2 u2 com
## v1 -0.05 0.04 0.07 0.85 0.00 0.75 0.254 1.0
## v2 0.28 0.11 0.15 0.39 -0.08 0.46 0.543 2.4
## v3 0.78 -0.01 -0.03 0.05 0.04 0.66 0.343 1.0
## v4 0.94 0.00 -0.02 -0.03 0.02 0.85 0.153 1.0
## v5 0.14 -0.07 -0.15 0.65 0.09 0.50 0.495 1.3
## v6 0.03 -0.02 0.40 0.26 0.03 0.34 0.664 1.7
## v7 -0.01 0.58 0.13 0.06 0.08 0.44 0.562 1.2
## v8 0.00 0.52 0.06 -0.06 -0.09 0.27 0.733 1.1
## v9 -0.03 0.63 -0.10 0.06 0.03 0.40 0.600 1.1
## v10 0.02 0.64 -0.07 0.00 0.04 0.42 0.582 1.0
## v11 0.05 0.52 -0.06 -0.08 -0.05 0.26 0.738 1.1
## v12 0.01 0.12 0.56 -0.08 0.01 0.32 0.676 1.1
## v13 0.44 0.09 0.20 0.12 -0.08 0.38 0.618 1.7
## v14 0.47 0.05 0.30 0.05 -0.12 0.42 0.582 1.9
## v15 0.17 0.14 0.30 0.17 0.09 0.35 0.645 3.1
## v16 -0.01 -0.11 0.67 0.12 0.01 0.52 0.479 1.1
## v17 0.08 0.00 0.64 -0.01 0.19 0.56 0.440 1.2
## v18 0.02 0.01 0.02 0.01 0.96 0.94 0.056 1.0
## v19 -0.05 0.09 0.30 0.00 0.37 0.32 0.683 2.1
##
## ML2 ML4 ML5 ML3 ML1
## SS loadings 2.32 1.83 2.02 1.74 1.25
## Proportion Var 0.12 0.10 0.11 0.09 0.07
## Cumulative Var 0.12 0.22 0.32 0.42 0.48
## Proportion Explained 0.25 0.20 0.22 0.19 0.14
## Cumulative Proportion 0.25 0.45 0.67 0.86 1.00
##
## With factor correlations of
## ML2 ML4 ML5 ML3 ML1
## ML2 1.00 0.21 0.33 0.54 0.22
## ML4 0.21 1.00 0.15 0.12 0.22
## ML5 0.33 0.15 1.00 0.42 0.36
## ML3 0.54 0.12 0.42 1.00 0.29
## ML1 0.22 0.22 0.36 0.29 1.00
##
## Mean item complexity = 1.4
## Test of the hypothesis that 5 factors are sufficient.
##
## The degrees of freedom for the null model are 171 and the objective function was 6.21 with Chi Square of 5534.67
## The degrees of freedom for the model are 86 and the objective function was 0.28
##
## The root mean square of the residuals (RMSR) is 0.02
## The df corrected root mean square of the residuals is 0.03
##
## The harmonic number of observations is 900 with the empirical chi square 184.46 with prob < 3.8e-09
## The total number of observations was 900 with Likelihood Chi Square = 250.66 with prob < 5.2e-18
##
## Tucker Lewis Index of factoring reliability = 0.939
## RMSEA index = 0.047 and the 90 % confidence intervals are 0.04 0.053
## BIC = -334.35
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy
## ML2 ML4 ML5 ML3 ML1
## Correlation of (regression) scores with factors 0.95 0.86 0.88 0.91 0.97
## Multiple R square of scores with factors 0.90 0.75 0.78 0.83 0.94
## Minimum correlation of possible factor scores 0.80 0.49 0.56 0.66 0.89
print(cf5$loadings, cutoff = 0.4)
##
## Loadings:
## ML2 ML4 ML5 ML3 ML1
## v1 0.851
## v2
## v3 0.783
## v4 0.938
## v5 0.655
## v6
## v7 0.584
## v8 0.524
## v9 0.634
## v10 0.639
## v11 0.517
## v12 0.559
## v13 0.438
## v14 0.470
## v15
## v16 0.674
## v17 0.636
## v18 0.955
## v19
##
## ML2 ML4 ML5 ML3 ML1
## SS loadings 2.049 1.776 1.730 1.462 1.150
## Proportion Var 0.108 0.093 0.091 0.077 0.061
## Cumulative Var 0.108 0.201 0.292 0.369 0.430
fa.diagram(cf5, cut = 0, simple = T)
#6
cf6 <- fa(demet19, 6, fm = "ml", rotate = "oblimin")
print(cf6)
## Factor Analysis using method = ml
## Call: fa(r = demet19, nfactors = 6, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML3 ML1 ML4 ML5 ML2 ML6 h2 u2 com
## v1 0.05 0.00 0.11 0.79 0.00 0.01 0.71 0.29 1.0
## v2 0.12 0.38 0.23 0.36 -0.11 -0.09 0.50 0.50 3.2
## v3 -0.01 0.89 0.00 0.00 0.02 -0.05 0.75 0.25 1.0
## v4 0.00 0.78 -0.04 -0.01 0.03 0.17 0.78 0.22 1.1
## v5 -0.07 0.05 -0.19 0.68 0.11 0.11 0.55 0.45 1.3
## v6 -0.01 0.08 0.42 0.25 0.02 -0.02 0.36 0.64 1.7
## v7 0.59 0.04 0.16 0.06 0.08 -0.07 0.46 0.54 1.2
## v8 0.52 0.01 0.07 -0.08 -0.09 0.01 0.27 0.73 1.1
## v9 0.64 -0.05 -0.10 0.06 0.03 0.00 0.40 0.60 1.1
## v10 0.63 0.00 -0.08 -0.02 0.05 0.05 0.42 0.58 1.1
## v11 0.51 -0.02 -0.09 -0.09 -0.04 0.11 0.27 0.73 1.2
## v12 0.12 0.04 0.56 -0.10 0.01 0.04 0.35 0.65 1.2
## v13 0.08 0.20 0.06 0.13 -0.03 0.43 0.45 0.55 1.7
## v14 0.03 0.11 0.10 0.05 -0.05 0.66 0.61 0.39 1.1
## v15 0.13 0.00 0.17 0.18 0.15 0.33 0.39 0.61 3.0
## v16 -0.12 -0.03 0.61 0.12 0.05 0.13 0.51 0.49 1.3
## v17 -0.01 0.03 0.55 -0.01 0.24 0.16 0.55 0.45 1.6
## v18 0.02 0.03 0.01 0.02 0.91 -0.03 0.85 0.15 1.0
## v19 0.08 -0.04 0.27 -0.02 0.41 0.02 0.33 0.67 1.8
##
## ML3 ML1 ML4 ML5 ML2 ML6
## SS loadings 1.81 1.90 1.73 1.66 1.27 1.13
## Proportion Var 0.10 0.10 0.09 0.09 0.07 0.06
## Cumulative Var 0.10 0.20 0.29 0.37 0.44 0.50
## Proportion Explained 0.19 0.20 0.18 0.17 0.13 0.12
## Cumulative Proportion 0.19 0.39 0.57 0.75 0.88 1.00
##
## With factor correlations of
## ML3 ML1 ML4 ML5 ML2 ML6
## ML3 1.00 0.20 0.14 0.10 0.22 0.15
## ML1 0.20 1.00 0.25 0.52 0.24 0.55
## ML4 0.14 0.25 1.00 0.35 0.36 0.32
## ML5 0.10 0.52 0.35 1.00 0.29 0.37
## ML2 0.22 0.24 0.36 0.29 1.00 0.17
## ML6 0.15 0.55 0.32 0.37 0.17 1.00
##
## Mean item complexity = 1.5
## Test of the hypothesis that 6 factors are sufficient.
##
## The degrees of freedom for the null model are 171 and the objective function was 6.21 with Chi Square of 5534.67
## The degrees of freedom for the model are 72 and the objective function was 0.16
##
## The root mean square of the residuals (RMSR) is 0.02
## The df corrected root mean square of the residuals is 0.03
##
## The harmonic number of observations is 900 with the empirical chi square 97.42 with prob < 0.025
## The total number of observations was 900 with Likelihood Chi Square = 144.04 with prob < 1e-06
##
## Tucker Lewis Index of factoring reliability = 0.968
## RMSEA index = 0.034 and the 90 % confidence intervals are 0.025 0.041
## BIC = -345.73
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy
## ML3 ML1 ML4 ML5 ML2
## Correlation of (regression) scores with factors 0.86 0.94 0.86 0.90 0.93
## Multiple R square of scores with factors 0.75 0.88 0.75 0.81 0.86
## Minimum correlation of possible factor scores 0.49 0.75 0.50 0.61 0.72
## ML6
## Correlation of (regression) scores with factors 0.84
## Multiple R square of scores with factors 0.71
## Minimum correlation of possible factor scores 0.41
print(cf6$loadings, cutoff = 0.4)
##
## Loadings:
## ML3 ML1 ML4 ML5 ML2 ML6
## v1 0.790
## v2
## v3 0.889
## v4 0.784
## v5 0.683
## v6 0.421
## v7 0.591
## v8 0.520
## v9 0.636
## v10 0.632
## v11 0.511
## v12 0.560
## v13 0.431
## v14 0.656
## v15
## v16 0.609
## v17 0.552
## v18 0.906
## v19 0.411
##
## ML3 ML1 ML4 ML5 ML2 ML6
## SS loadings 1.762 1.624 1.437 1.384 1.120 0.840
## Proportion Var 0.093 0.085 0.076 0.073 0.059 0.044
## Cumulative Var 0.093 0.178 0.254 0.327 0.386 0.430
fa.diagram(cf6, cut = 0, simple = T)
#parallel plot
fa.parallel(demet11)
## Parallel analysis suggests that the number of factors = 5 and the number of components = 2
#scree plot
scree(demet11)
#EFA factor 1 ~ 6
#1
cff1 <- fa(demet11, 1, fm = "ml")
print(cff1)
## Factor Analysis using method = ml
## Call: fa(r = demet11, nfactors = 1, fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 h2 u2 com
## K1 0.71 0.499 0.50 1
## K2 0.55 0.301 0.70 1
## K3 0.57 0.323 0.68 1
## K4 0.23 0.053 0.95 1
## K5 0.45 0.201 0.80 1
## K6 0.61 0.370 0.63 1
## K7 0.62 0.379 0.62 1
## K8 0.61 0.368 0.63 1
## K9 0.66 0.434 0.57 1
## K10 0.51 0.256 0.74 1
## K11 0.44 0.190 0.81 1
##
## ML1
## SS loadings 3.38
## Proportion Var 0.31
##
## Mean item complexity = 1
## Test of the hypothesis that 1 factor is sufficient.
##
## The degrees of freedom for the null model are 55 and the objective function was 3.17 with Chi Square of 2836.43
## The degrees of freedom for the model are 44 and the objective function was 0.82
##
## The root mean square of the residuals (RMSR) is 0.09
## The df corrected root mean square of the residuals is 0.1
##
## The harmonic number of observations is 900 with the empirical chi square 760.81 with prob < 2e-131
## The total number of observations was 900 with Likelihood Chi Square = 736.58 with prob < 1.8e-126
##
## Tucker Lewis Index of factoring reliability = 0.689
## RMSEA index = 0.133 and the 90 % confidence intervals are 0.124 0.141
## BIC = 437.27
## Fit based upon off diagonal values = 0.92
## Measures of factor score adequacy
## ML1
## Correlation of (regression) scores with factors 0.92
## Multiple R square of scores with factors 0.84
## Minimum correlation of possible factor scores 0.68
print(cff1$loadings, cutoff = 0.4)
##
## Loadings:
## ML1
## K1 0.706
## K2 0.549
## K3 0.568
## K4
## K5 0.449
## K6 0.609
## K7 0.616
## K8 0.607
## K9 0.659
## K10 0.506
## K11 0.436
##
## ML1
## SS loadings 3.376
## Proportion Var 0.307
fa.diagram(cff1, cut = 0, simple = T)
#2
cff2 <- fa(demet11, 2, fm = "ml", rotate = "oblimin")
print(cff2)
## Factor Analysis using method = ml
## Call: fa(r = demet11, nfactors = 2, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML2 ML1 h2 u2 com
## K1 0.19 0.71 0.662 0.34 1.1
## K2 -0.11 0.87 0.674 0.33 1.0
## K3 0.41 0.24 0.315 0.68 1.6
## K4 0.21 0.04 0.052 0.95 1.1
## K5 0.60 -0.12 0.305 0.70 1.1
## K6 0.27 0.45 0.383 0.62 1.6
## K7 0.40 0.30 0.354 0.65 1.9
## K8 0.61 0.07 0.422 0.58 1.0
## K9 0.75 0.00 0.565 0.44 1.0
## K10 0.49 0.08 0.290 0.71 1.1
## K11 0.55 -0.07 0.274 0.73 1.0
##
## ML2 ML1
## SS loadings 2.50 1.80
## Proportion Var 0.23 0.16
## Cumulative Var 0.23 0.39
## Proportion Explained 0.58 0.42
## Cumulative Proportion 0.58 1.00
##
## With factor correlations of
## ML2 ML1
## ML2 1.00 0.47
## ML1 0.47 1.00
##
## Mean item complexity = 1.2
## Test of the hypothesis that 2 factors are sufficient.
##
## The degrees of freedom for the null model are 55 and the objective function was 3.17 with Chi Square of 2836.43
## The degrees of freedom for the model are 34 and the objective function was 0.36
##
## The root mean square of the residuals (RMSR) is 0.06
## The df corrected root mean square of the residuals is 0.07
##
## The harmonic number of observations is 900 with the empirical chi square 300.98 with prob < 1.6e-44
## The total number of observations was 900 with Likelihood Chi Square = 321.36 with prob < 1.7e-48
##
## Tucker Lewis Index of factoring reliability = 0.833
## RMSEA index = 0.097 and the 90 % confidence intervals are 0.087 0.107
## BIC = 90.08
## Fit based upon off diagonal values = 0.97
## Measures of factor score adequacy
## ML2 ML1
## Correlation of (regression) scores with factors 0.90 0.91
## Multiple R square of scores with factors 0.81 0.82
## Minimum correlation of possible factor scores 0.62 0.65
print(cff2$loadings, cutoff = 0.4)
##
## Loadings:
## ML2 ML1
## K1 0.707
## K2 0.867
## K3 0.408
## K4
## K5 0.597
## K6 0.448
## K7
## K8 0.612
## K9 0.753
## K10 0.495
## K11 0.555
##
## ML2 ML1
## SS loadings 2.335 1.629
## Proportion Var 0.212 0.148
## Cumulative Var 0.212 0.360
fa.diagram(cff2, cut = 0, simple = T)
#3
cff3 <- fa(demet11, 3, fm = "ml", rotate = "oblimin")
print(cff3)
## Factor Analysis using method = ml
## Call: fa(r = demet11, nfactors = 3, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML3 ML2 ML1 h2 u2 com
## K1 0.26 0.67 0.00 0.648 0.352 1.3
## K2 -0.11 0.88 0.06 0.727 0.273 1.0
## K3 0.45 0.22 0.01 0.332 0.668 1.4
## K4 0.13 0.03 0.14 0.057 0.943 2.1
## K5 0.61 -0.13 0.01 0.332 0.668 1.1
## K6 0.38 0.43 -0.11 0.415 0.585 2.1
## K7 0.38 0.28 0.09 0.353 0.647 2.0
## K8 0.66 0.06 -0.02 0.459 0.541 1.0
## K9 0.66 0.00 0.17 0.545 0.455 1.1
## K10 0.00 0.02 0.99 0.995 0.005 1.0
## K11 0.33 -0.08 0.37 0.308 0.692 2.1
##
## ML3 ML2 ML1
## SS loadings 2.18 1.70 1.29
## Proportion Var 0.20 0.15 0.12
## Cumulative Var 0.20 0.35 0.47
## Proportion Explained 0.42 0.33 0.25
## Cumulative Proportion 0.42 0.75 1.00
##
## With factor correlations of
## ML3 ML2 ML1
## ML3 1.00 0.41 0.40
## ML2 0.41 1.00 0.27
## ML1 0.40 0.27 1.00
##
## Mean item complexity = 1.5
## Test of the hypothesis that 3 factors are sufficient.
##
## The degrees of freedom for the null model are 55 and the objective function was 3.17 with Chi Square of 2836.43
## The degrees of freedom for the model are 25 and the objective function was 0.17
##
## The root mean square of the residuals (RMSR) is 0.04
## The df corrected root mean square of the residuals is 0.06
##
## The harmonic number of observations is 900 with the empirical chi square 141.16 with prob < 3.5e-18
## The total number of observations was 900 with Likelihood Chi Square = 154.15 with prob < 1.4e-20
##
## Tucker Lewis Index of factoring reliability = 0.898
## RMSEA index = 0.076 and the 90 % confidence intervals are 0.065 0.088
## BIC = -15.91
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy
## ML3 ML2 ML1
## Correlation of (regression) scores with factors 0.89 0.91 1.00
## Multiple R square of scores with factors 0.79 0.83 0.99
## Minimum correlation of possible factor scores 0.58 0.66 0.99
print(cff3$loadings, cutoff = 0.4)
##
## Loadings:
## ML3 ML2 ML1
## K1 0.665
## K2 0.876
## K3 0.448
## K4
## K5 0.613
## K6 0.429
## K7
## K8 0.657
## K9 0.657
## K10 0.990
## K11
##
## ML3 ML2 ML1
## SS loadings 1.928 1.544 1.187
## Proportion Var 0.175 0.140 0.108
## Cumulative Var 0.175 0.316 0.424
fa.diagram(cff3, cut = 0, simple = T)
#4
cff4 <- fa(demet11, 4, fm = "ml", rotate = "oblimin")
print(cff4)
## Factor Analysis using method = ml
## Call: fa(r = demet11, nfactors = 4, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML3 ML2 ML1 ML4 h2 u2 com
## K1 0.21 0.58 0.01 0.20 0.61 0.39 1.5
## K2 -0.05 0.92 0.05 -0.04 0.83 0.17 1.0
## K3 0.41 0.19 0.03 0.09 0.33 0.67 1.5
## K4 -0.20 -0.05 0.15 0.52 0.25 0.75 1.5
## K5 0.42 -0.16 0.04 0.27 0.32 0.68 2.1
## K6 0.19 0.35 -0.11 0.42 0.48 0.52 2.6
## K7 0.18 0.20 0.10 0.38 0.41 0.59 2.2
## K8 0.80 0.04 0.00 -0.09 0.61 0.39 1.0
## K9 0.58 -0.03 0.21 0.13 0.54 0.46 1.4
## K10 0.00 0.04 0.94 -0.01 0.90 0.10 1.0
## K11 0.23 -0.09 0.41 0.11 0.32 0.68 1.8
##
## ML3 ML2 ML1 ML4
## SS loadings 1.79 1.57 1.27 0.97
## Proportion Var 0.16 0.14 0.12 0.09
## Cumulative Var 0.16 0.31 0.42 0.51
## Proportion Explained 0.32 0.28 0.23 0.17
## Cumulative Proportion 0.32 0.60 0.83 1.00
##
## With factor correlations of
## ML3 ML2 ML1 ML4
## ML3 1.00 0.36 0.37 0.43
## ML2 0.36 1.00 0.26 0.31
## ML1 0.37 0.26 1.00 0.30
## ML4 0.43 0.31 0.30 1.00
##
## Mean item complexity = 1.6
## Test of the hypothesis that 4 factors are sufficient.
##
## The degrees of freedom for the null model are 55 and the objective function was 3.17 with Chi Square of 2836.43
## The degrees of freedom for the model are 17 and the objective function was 0.07
##
## The root mean square of the residuals (RMSR) is 0.02
## The df corrected root mean square of the residuals is 0.04
##
## The harmonic number of observations is 900 with the empirical chi square 49.5 with prob < 5.1e-05
## The total number of observations was 900 with Likelihood Chi Square = 64.28 with prob < 2e-07
##
## Tucker Lewis Index of factoring reliability = 0.945
## RMSEA index = 0.056 and the 90 % confidence intervals are 0.042 0.07
## BIC = -51.36
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy
## ML3 ML2 ML1 ML4
## Correlation of (regression) scores with factors 0.89 0.93 0.95 0.78
## Multiple R square of scores with factors 0.79 0.86 0.90 0.60
## Minimum correlation of possible factor scores 0.57 0.73 0.81 0.21
print(cff4$loadings, cutoff = 0.4)
##
## Loadings:
## ML3 ML2 ML1 ML4
## K1 0.582
## K2 0.924
## K3 0.415
## K4 0.515
## K5 0.420
## K6 0.415
## K7
## K8 0.803
## K9 0.577
## K10 0.941
## K11 0.410
##
## ML3 ML2 ML1 ML4
## SS loadings 1.531 1.426 1.148 0.740
## Proportion Var 0.139 0.130 0.104 0.067
## Cumulative Var 0.139 0.269 0.373 0.440
fa.diagram(cff4, cut = 0, simple = T)
#5
cff5 <- fa(demet11, 5, fm = "ml", rotate = "oblimin")
print(cff5)
## Factor Analysis using method = ml
## Call: fa(r = demet11, nfactors = 5, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML2 ML1 ML4 ML3 ML5 h2 u2 com
## K1 0.62 0.01 0.09 0.14 0.14 0.63 0.37 1.3
## K2 0.88 0.05 -0.04 -0.05 0.00 0.76 0.24 1.0
## K3 0.30 0.01 0.18 0.37 -0.07 0.38 0.62 2.5
## K4 -0.08 0.16 -0.27 0.16 0.40 0.22 0.78 2.6
## K5 -0.03 0.00 0.00 0.75 0.00 0.56 0.44 1.0
## K6 0.25 -0.11 0.12 0.03 0.53 0.53 0.47 1.7
## K7 0.11 0.11 0.15 0.01 0.46 0.43 0.57 1.5
## K8 0.02 0.00 0.78 0.04 -0.01 0.65 0.35 1.0
## K9 -0.08 0.23 0.51 0.06 0.21 0.55 0.45 1.9
## K10 0.04 0.93 0.00 -0.01 -0.02 0.87 0.13 1.0
## K11 -0.07 0.42 0.12 0.16 0.05 0.33 0.67 1.6
##
## ML2 ML1 ML4 ML3 ML5
## SS loadings 1.50 1.26 1.24 0.95 0.94
## Proportion Var 0.14 0.11 0.11 0.09 0.09
## Cumulative Var 0.14 0.25 0.36 0.45 0.54
## Proportion Explained 0.25 0.21 0.21 0.16 0.16
## Cumulative Proportion 0.25 0.47 0.68 0.84 1.00
##
## With factor correlations of
## ML2 ML1 ML4 ML3 ML5
## ML2 1.00 0.28 0.38 0.16 0.47
## ML1 0.28 1.00 0.35 0.33 0.31
## ML4 0.38 0.35 1.00 0.55 0.39
## ML3 0.16 0.33 0.55 1.00 0.44
## ML5 0.47 0.31 0.39 0.44 1.00
##
## Mean item complexity = 1.5
## Test of the hypothesis that 5 factors are sufficient.
##
## The degrees of freedom for the null model are 55 and the objective function was 3.17 with Chi Square of 2836.43
## The degrees of freedom for the model are 10 and the objective function was 0.03
##
## The root mean square of the residuals (RMSR) is 0.01
## The df corrected root mean square of the residuals is 0.03
##
## The harmonic number of observations is 900 with the empirical chi square 14.62 with prob < 0.15
## The total number of observations was 900 with Likelihood Chi Square = 22.99 with prob < 0.011
##
## Tucker Lewis Index of factoring reliability = 0.974
## RMSEA index = 0.038 and the 90 % confidence intervals are 0.017 0.059
## BIC = -45.03
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy
## ML2 ML1 ML4 ML3 ML5
## Correlation of (regression) scores with factors 0.91 0.94 0.87 0.83 0.80
## Multiple R square of scores with factors 0.83 0.88 0.76 0.69 0.65
## Minimum correlation of possible factor scores 0.67 0.76 0.52 0.38 0.29
print(cff5$loadings, cutoff = 0.4)
##
## Loadings:
## ML2 ML1 ML4 ML3 ML5
## K1 0.620
## K2 0.880
## K3
## K4
## K5 0.751
## K6 0.525
## K7 0.460
## K8 0.780
## K9 0.505
## K10 0.930
## K11 0.422
##
## ML2 ML1 ML4 ML3 ML5
## SS loadings 1.344 1.148 1.033 0.782 0.717
## Proportion Var 0.122 0.104 0.094 0.071 0.065
## Cumulative Var 0.122 0.226 0.320 0.392 0.457
fa.diagram(cff5, cut = 0, simple = T)
#6
cff6 <- fa(demet11, 6, fm = "ml", rotate = "oblimin")
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate =
## rotate, : A loading greater than abs(1) was detected. Examine the loadings
## carefully.
print(cff6)
## Factor Analysis using method = ml
## Call: fa(r = demet11, nfactors = 6, rotate = "oblimin", fm = "ml")
##
## Warning: A Heywood case was detected.
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML3 ML2 ML1 ML4 ML5 ML6 h2 u2 com
## K1 0.59 -0.03 0.09 0.12 0.13 0.15 0.62 0.385 1.4
## K2 0.92 0.03 0.00 -0.03 -0.01 -0.04 0.83 0.174 1.0
## K3 0.00 0.01 1.00 -0.01 0.00 -0.01 1.00 0.005 1.0
## K4 -0.02 0.10 -0.01 -0.27 0.28 0.36 0.27 0.731 3.0
## K5 -0.08 -0.03 0.20 0.24 0.03 0.38 0.37 0.631 2.4
## K6 0.21 -0.09 0.01 0.11 0.53 0.04 0.52 0.484 1.5
## K7 0.02 0.13 0.08 0.09 0.54 -0.02 0.45 0.548 1.2
## K8 0.05 -0.02 0.05 0.74 0.02 0.00 0.60 0.395 1.0
## K9 -0.05 0.19 0.01 0.53 0.19 0.07 0.56 0.440 1.6
## K10 0.02 0.97 0.01 0.00 0.01 -0.01 0.97 0.034 1.0
## K11 0.06 0.31 -0.04 0.21 -0.11 0.34 0.37 0.635 3.0
##
## ML3 ML2 ML1 ML4 ML5 ML6
## SS loadings 1.38 1.23 1.15 1.25 0.96 0.58
## Proportion Var 0.13 0.11 0.10 0.11 0.09 0.05
## Cumulative Var 0.13 0.24 0.34 0.45 0.54 0.59
## Proportion Explained 0.21 0.19 0.18 0.19 0.15 0.09
## Cumulative Proportion 0.21 0.40 0.57 0.76 0.91 1.00
##
## With factor correlations of
## ML3 ML2 ML1 ML4 ML5 ML6
## ML3 1.00 0.28 0.37 0.31 0.53 0.03
## ML2 0.28 1.00 0.24 0.34 0.26 0.37
## ML1 0.37 0.24 1.00 0.46 0.33 0.25
## ML4 0.31 0.34 0.46 1.00 0.42 0.35
## ML5 0.53 0.26 0.33 0.42 1.00 0.43
## ML6 0.03 0.37 0.25 0.35 0.43 1.00
##
## Mean item complexity = 1.6
## Test of the hypothesis that 6 factors are sufficient.
##
## The degrees of freedom for the null model are 55 and the objective function was 3.17 with Chi Square of 2836.43
## The degrees of freedom for the model are 4 and the objective function was 0.01
##
## The root mean square of the residuals (RMSR) is 0.01
## The df corrected root mean square of the residuals is 0.02
##
## The harmonic number of observations is 900 with the empirical chi square 2.81 with prob < 0.59
## The total number of observations was 900 with Likelihood Chi Square = 4.96 with prob < 0.29
##
## Tucker Lewis Index of factoring reliability = 0.995
## RMSEA index = 0.017 and the 90 % confidence intervals are 0 0.055
## BIC = -22.25
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy
## ML3 ML2 ML1 ML4 ML5
## Correlation of (regression) scores with factors 0.93 0.98 1.00 0.86 0.82
## Multiple R square of scores with factors 0.86 0.97 0.99 0.74 0.68
## Minimum correlation of possible factor scores 0.73 0.93 0.99 0.48 0.36
## ML6
## Correlation of (regression) scores with factors 0.73
## Multiple R square of scores with factors 0.53
## Minimum correlation of possible factor scores 0.06
print(cff6$loadings, cutoff = 0.4)
##
## Loadings:
## ML3 ML2 ML1 ML4 ML5 ML6
## K1 0.586
## K2 0.916
## K3 1.001
## K4
## K5
## K6 0.531
## K7 0.540
## K8 0.737
## K9 0.535
## K10 0.975
## K11
##
## ML3 ML2 ML1 ML4 ML5 ML6
## SS loadings 1.242 1.120 1.059 1.036 0.720 0.423
## Proportion Var 0.113 0.102 0.096 0.094 0.065 0.038
## Cumulative Var 0.113 0.215 0.311 0.405 0.471 0.509
fa.diagram(cff6, cut = 0, simple = T)
#echo = F : R code보이지 않고 결과만 출력.
#echo = T : R code와 결과 모두 출력.
setwd("C:/Users/LG/Desktop/old")
library(haven)
library(dplyr)
library(ggplot2)
library(reshape2)
mdata <- read_spss("MSH.sav")
head(mdata)
## # A tibble: 6 x 65
## ID ID_A1 ID_A2 ID_A3 ID_A4 ID_A4_1 ID_A5 ID_B1 ID_B2 ID_B2_1
## <dbl> <dbl+> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl+l> <dbl> <dbl+l>
## 1 1 1 [남] 70 4 [이혼(~ 5 [고등학~ 12 1456 3 [그저 ~ 4 2 [아니오~
## 2 2 1 [남] 71 2 [유배우~ 7 [대학교~ 18 4580 2 [건강한~ 2 2 [아니오~
## 3 3 2 [여] 71 2 [유배우~ 5 [고등학~ 12 4580 2 [건강한~ 3 2 [아니오~
## 4 4 1 [남] 82 2 [유배우~ 7 [대학교~ 18 3200 4 [건강이~ 7 1 [예]
## 5 5 1 [남] 68 2 [유배우~ 3 [초등학~ 6 4946 2 [건강한~ 0 2 [아니오~
## 6 6 2 [여] 66 2 [유배우~ 3 [초등학~ 6 4946 2 [건강한~ 0 2 [아니오~
## # ... with 55 more variables: ID_B2_2 <dbl+lbl>, ID_B3 <dbl>, ID_B4 <dbl>,
## # ID_B5 <dbl>, M_total <dbl>, M_target <dbl+lbl>, card_V <dbl>,
## # v1_1 <dbl+lbl>, v1_2 <dbl+lbl>, v1_3 <dbl+lbl>, v1_4 <dbl+lbl>,
## # v1_5 <dbl+lbl>, v2_1 <dbl+lbl>, v2_2 <dbl+lbl>, v2_3 <dbl+lbl>,
## # v2_4 <dbl+lbl>, v2_5 <dbl+lbl>, v3_1 <dbl+lbl>, v3_2 <dbl+lbl>,
## # v3_3 <dbl+lbl>, v4_1 <dbl+lbl>, v4_2 <dbl+lbl>, v4_3 <dbl+lbl>,
## # v4_4 <dbl+lbl>, v4_5 <dbl+lbl>, v5_1 <dbl+lbl>, v5_2 <dbl+lbl>,
## # v5_3 <dbl+lbl>, v6_1 <dbl+lbl>, v6_2 <dbl+lbl>, v7 <dbl+lbl>,
## # v8_1 <dbl+lbl>, v8_2 <dbl+lbl>, v8_3 <dbl+lbl>, v9 <dbl+lbl>,
## # v10_1 <dbl+lbl>, v10_2 <dbl+lbl>, card_M <dbl>, M1 <dbl>, M3 <dbl>,
## # M2 <dbl>, M4 <dbl>, M5 <dbl>, M6 <dbl>, card_K <dbl>, K1 <dbl>,
## # K2 <dbl>, K3 <dbl>, K5 <dbl>, K4 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>,
## # K9 <dbl>, K10 <dbl>
tail(mdata)
## # A tibble: 6 x 65
## ID ID_A1 ID_A2 ID_A3 ID_A4 ID_A4_1 ID_A5 ID_B1 ID_B2 ID_B2_1
## <dbl> <dbl+> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl+l> <dbl> <dbl+l>
## 1 10295 2 [여] 73 2 [유배우~ 3 [초등학~ 6 1116 5 [건강이~ 11 1 [예]
## 2 10296 2 [여] 84 3 [사별(~ 2 [무학(~ 5 681 4 [건강이~ 7 1 [예]
## 3 10297 2 [여] 71 2 [유배우~ 2 [무학(~ 4 1147 4 [건강이~ 6 2 [아니오~
## 4 10298 2 [여] 68 3 [사별(~ 2 [무학(~ 0 684 4 [건강이~ 3 2 [아니오~
## 5 10299 2 [여] 84 3 [사별(~ 2 [무학(~ 0 1420 2 [건강한~ 3 2 [아니오~
## 6 10300 1 [남] 66 4 [이혼(~ 5 [고등학~ 12 1179 3 [그저 ~ 3 2 [아니오~
## # ... with 55 more variables: ID_B2_2 <dbl+lbl>, ID_B3 <dbl>, ID_B4 <dbl>,
## # ID_B5 <dbl>, M_total <dbl>, M_target <dbl+lbl>, card_V <dbl>,
## # v1_1 <dbl+lbl>, v1_2 <dbl+lbl>, v1_3 <dbl+lbl>, v1_4 <dbl+lbl>,
## # v1_5 <dbl+lbl>, v2_1 <dbl+lbl>, v2_2 <dbl+lbl>, v2_3 <dbl+lbl>,
## # v2_4 <dbl+lbl>, v2_5 <dbl+lbl>, v3_1 <dbl+lbl>, v3_2 <dbl+lbl>,
## # v3_3 <dbl+lbl>, v4_1 <dbl+lbl>, v4_2 <dbl+lbl>, v4_3 <dbl+lbl>,
## # v4_4 <dbl+lbl>, v4_5 <dbl+lbl>, v5_1 <dbl+lbl>, v5_2 <dbl+lbl>,
## # v5_3 <dbl+lbl>, v6_1 <dbl+lbl>, v6_2 <dbl+lbl>, v7 <dbl+lbl>,
## # v8_1 <dbl+lbl>, v8_2 <dbl+lbl>, v8_3 <dbl+lbl>, v9 <dbl+lbl>,
## # v10_1 <dbl+lbl>, v10_2 <dbl+lbl>, card_M <dbl>, M1 <dbl>, M3 <dbl>,
## # M2 <dbl>, M4 <dbl>, M5 <dbl>, M6 <dbl>, card_K <dbl>, K1 <dbl>,
## # K2 <dbl>, K3 <dbl>, K5 <dbl>, K4 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>,
## # K9 <dbl>, K10 <dbl>
#인지기능 저하집단
newdata <- mdata %>% filter(M_target == 1)
head(newdata)
## # A tibble: 6 x 65
## ID ID_A1 ID_A2 ID_A3 ID_A4 ID_A4_1 ID_A5 ID_B1 ID_B2 ID_B2_1
## <dbl> <dbl+> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl+l> <dbl> <dbl+l>
## 1 4 1 [남] 82 2 [유배우~ 7 [대학교~ 18 3200 4 [건강이~ 7 1 [예]
## 2 7 1 [남] 75 2 [유배우~ 5 [고등학~ 12 1819 2 [건강한~ 1 2 [아니오~
## 3 8 2 [여] 71 2 [유배우~ 4 [중학교~ 9 1819 4 [건강이~ 4 2 [아니오~
## 4 14 2 [여] 68 2 [유배우~ 5 [고등학~ 12 2212 2 [건강한~ 1 2 [아니오~
## 5 30 2 [여] 65 2 [유배우~ 3 [초등학~ 6 3117 4 [건강이~ 2 2 [아니오~
## 6 35 2 [여] 68 3 [사별(~ 4 [중학교~ 9 1116 4 [건강이~ 3 2 [아니오~
## # ... with 55 more variables: ID_B2_2 <dbl+lbl>, ID_B3 <dbl>, ID_B4 <dbl>,
## # ID_B5 <dbl>, M_total <dbl>, M_target <dbl+lbl>, card_V <dbl>,
## # v1_1 <dbl+lbl>, v1_2 <dbl+lbl>, v1_3 <dbl+lbl>, v1_4 <dbl+lbl>,
## # v1_5 <dbl+lbl>, v2_1 <dbl+lbl>, v2_2 <dbl+lbl>, v2_3 <dbl+lbl>,
## # v2_4 <dbl+lbl>, v2_5 <dbl+lbl>, v3_1 <dbl+lbl>, v3_2 <dbl+lbl>,
## # v3_3 <dbl+lbl>, v4_1 <dbl+lbl>, v4_2 <dbl+lbl>, v4_3 <dbl+lbl>,
## # v4_4 <dbl+lbl>, v4_5 <dbl+lbl>, v5_1 <dbl+lbl>, v5_2 <dbl+lbl>,
## # v5_3 <dbl+lbl>, v6_1 <dbl+lbl>, v6_2 <dbl+lbl>, v7 <dbl+lbl>,
## # v8_1 <dbl+lbl>, v8_2 <dbl+lbl>, v8_3 <dbl+lbl>, v9 <dbl+lbl>,
## # v10_1 <dbl+lbl>, v10_2 <dbl+lbl>, card_M <dbl>, M1 <dbl>, M3 <dbl>,
## # M2 <dbl>, M4 <dbl>, M5 <dbl>, M6 <dbl>, card_K <dbl>, K1 <dbl>,
## # K2 <dbl>, K3 <dbl>, K5 <dbl>, K4 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>,
## # K9 <dbl>, K10 <dbl>
tail(newdata)
## # A tibble: 6 x 65
## ID ID_A1 ID_A2 ID_A3 ID_A4 ID_A4_1 ID_A5 ID_B1 ID_B2 ID_B2_1
## <dbl> <dbl+> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl+l> <dbl> <dbl+l>
## 1 10252 1 [남] 71 2 [유배우~ 5 [고등학~ 12 2276 4 [건강이~ 2 2 [아니오~
## 2 10257 2 [여] 70 2 [유배우~ 4 [중학교~ 9 4151 2 [건강한~ 3 2 [아니오~
## 3 10287 1 [남] 94 2 [유배우~ 7 [대학교~ 16 1431 5 [건강이~ 4 2 [아니오~
## 4 10288 2 [여] 90 2 [유배우~ 5 [고등학~ 12 1431 5 [건강이~ 2 2 [아니오~
## 5 10290 2 [여] 69 3 [사별(~ 4 [중학교~ 9 723 5 [건강이~ 3 2 [아니오~
## 6 10291 1 [남] 85 2 [유배우~ 3 [초등학~ 8 1801 2 [건강한~ 3 2 [아니오~
## # ... with 55 more variables: ID_B2_2 <dbl+lbl>, ID_B3 <dbl>, ID_B4 <dbl>,
## # ID_B5 <dbl>, M_total <dbl>, M_target <dbl+lbl>, card_V <dbl>,
## # v1_1 <dbl+lbl>, v1_2 <dbl+lbl>, v1_3 <dbl+lbl>, v1_4 <dbl+lbl>,
## # v1_5 <dbl+lbl>, v2_1 <dbl+lbl>, v2_2 <dbl+lbl>, v2_3 <dbl+lbl>,
## # v2_4 <dbl+lbl>, v2_5 <dbl+lbl>, v3_1 <dbl+lbl>, v3_2 <dbl+lbl>,
## # v3_3 <dbl+lbl>, v4_1 <dbl+lbl>, v4_2 <dbl+lbl>, v4_3 <dbl+lbl>,
## # v4_4 <dbl+lbl>, v4_5 <dbl+lbl>, v5_1 <dbl+lbl>, v5_2 <dbl+lbl>,
## # v5_3 <dbl+lbl>, v6_1 <dbl+lbl>, v6_2 <dbl+lbl>, v7 <dbl+lbl>,
## # v8_1 <dbl+lbl>, v8_2 <dbl+lbl>, v8_3 <dbl+lbl>, v9 <dbl+lbl>,
## # v10_1 <dbl+lbl>, v10_2 <dbl+lbl>, card_M <dbl>, M1 <dbl>, M3 <dbl>,
## # M2 <dbl>, M4 <dbl>, M5 <dbl>, M6 <dbl>, card_K <dbl>, K1 <dbl>,
## # K2 <dbl>, K3 <dbl>, K5 <dbl>, K4 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>,
## # K9 <dbl>, K10 <dbl>
nrow(newdata)
## [1] 1998
#문항 6
data6 <- newdata %>% .[c(1:999), c(49:54)]
data6 <- data6[c(1,3,2,4,5,6)]
head(data6)
## # A tibble: 6 x 6
## M1 M2 M3 M4 M5 M6
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 8 3 4 5 1 2
## 2 8 3 5 6 1 2
## 3 7 1 4 6 1 2
## 4 9 3 5 5 1 2
## 5 9 1 3 6 0 2
## 6 10 2 5 5 1 1
tail(data6)
## # A tibble: 6 x 6
## M1 M2 M3 M4 M5 M6
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 5 1 3 5 0 2
## 2 9 0 4 6 0 1
## 3 4 0 6 5 0 1
## 4 10 1 3 3 1 2
## 5 8 2 4 6 1 2
## 6 7 0 3 4 0 2
nrow(data6)
## [1] 999
#문항 10
data10 <- newdata %>% .[c(1:999), c(56:65)]
data10 <- data10[c(1,2,3,5,4,6,7,8,9,10)]
head(data10)
## # A tibble: 6 x 10
## K1 K2 K3 K4 K5 K6 K7 K8 K9 K10
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 4 4 3 3 1 2 0 3 1 2
## 2 4 4 3 3 2 2 1 3 1 2
## 3 3 4 2 1 2 2 1 3 1 2
## 4 4 5 3 3 2 2 1 2 1 2
## 5 4 5 3 1 0 2 1 3 0 2
## 6 5 5 3 2 2 2 1 2 1 1
tail(data10)
## # A tibble: 6 x 10
## K1 K2 K3 K4 K5 K6 K7 K8 K9 K10
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 4 3 1 0 2 0 3 0 2
## 2 5 4 3 0 1 2 1 3 0 1
## 3 1 3 3 0 3 2 1 2 0 1
## 4 5 5 3 1 0 2 0 1 1 2
## 5 4 4 3 2 1 2 1 3 1 2
## 6 3 4 2 0 1 2 0 2 0 2
nrow(data10)
## [1] 999
#문항 6 결측치 확인
colSums(is.na(data6))
## M1 M2 M3 M4 M5 M6
## 0 0 0 1 0 0
cdata6 <- data6 %>% filter(!is.na(M4))
colSums(is.na(cdata6))
## M1 M2 M3 M4 M5 M6
## 0 0 0 0 0 0
#문항 10 결측치 확인
colSums(is.na(data10))
## K1 K2 K3 K4 K5 K6 K7 K8 K9 K10
## 0 0 0 0 0 0 0 1 0 0
cdata10 <- data10 %>% filter(!is.na(K8))
#K8이외에 결측치가 있는 문항은 &로 연결함.
#filter(!is.na(v8_1) & !is.na(v8_2) & !is.na(v8_3) & !is.na(v9))
colSums(is.na(cdata10))
## K1 K2 K3 K4 K5 K6 K7 K8 K9 K10
## 0 0 0 0 0 0 0 0 0 0
#문항 6 요약, 평균, 표준편차
as.table(apply(cdata6, 2, summary))
## M1 M2 M3 M4 M5 M6
## Min. 0.0000000 0.0000000 0.0000000 2.0000000 0.0000000 0.0000000
## 1st Qu. 7.0000000 0.0000000 3.0000000 5.0000000 0.0000000 1.0000000
## Median 8.0000000 1.0000000 4.0000000 6.0000000 0.0000000 2.0000000
## Mean 8.0040080 1.3597194 3.7795591 5.2284569 0.3777555 1.6442886
## 3rd Qu. 10.0000000 2.0000000 5.0000000 6.0000000 1.0000000 2.0000000
## Max. 10.0000000 5.0000000 6.0000000 6.0000000 1.0000000 2.0000000
as.table(apply(cdata6, 2, mean))
## M1 M2 M3 M4 M5 M6
## 8.0040080 1.3597194 3.7795591 5.2284569 0.3777555 1.6442886
as.table(apply(cdata6, 2, sd))
## M1 M2 M3 M4 M5 M6
## 1.9455950 1.3473332 1.1495510 1.0173578 0.4850691 0.5054591
#문항 10 요약, 평균, 표준편차
as.table(apply(cdata10, 2, summary))
## K1 K2 K3 K4 K5 K6
## Min. 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## 1st Qu. 3.0000000 4.0000000 3.0000000 0.0000000 0.0000000 2.0000000
## Median 4.0000000 5.0000000 3.0000000 1.0000000 1.0000000 2.0000000
## Mean 3.6082164 4.3957916 2.8376754 1.3597194 0.9418838 1.9839679
## 3rd Qu. 5.0000000 5.0000000 3.0000000 2.0000000 2.0000000 2.0000000
## Max. 5.0000000 5.0000000 3.0000000 5.0000000 3.0000000 2.0000000
## K7 K8 K9 K10
## Min. 0.0000000 0.0000000 0.0000000 0.0000000
## 1st Qu. 0.0000000 2.0000000 0.0000000 1.0000000
## Median 1.0000000 3.0000000 0.0000000 2.0000000
## Mean 0.7144289 2.5300601 0.3777555 1.6442886
## 3rd Qu. 1.0000000 3.0000000 1.0000000 2.0000000
## Max. 1.0000000 3.0000000 1.0000000 2.0000000
as.table(apply(cdata10, 2, mean))
## K1 K2 K3 K4 K5 K6 K7
## 3.6082164 4.3957916 2.8376754 1.3597194 0.9418838 1.9839679 0.7144289
## K8 K9 K10
## 2.5300601 0.3777555 1.6442886
as.table(apply(cdata10, 2, sd))
## K1 K2 K3 K4 K5 K6 K7
## 1.3955843 0.9494032 0.5064315 1.3473332 0.9733816 0.1476784 0.4519125
## K8 K9 K10
## 0.8164545 0.4850691 0.5054591
#6문항 histogram
ggplot(data = melt(cdata6), aes(x = value)) +
facet_wrap(~variable) + geom_histogram()
## No id variables; using all as measure variables
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#6문항 box plot
ggplot(data = melt(cdata6), aes(x = variable, y = value)) +
geom_boxplot(aes(fill = variable))
## No id variables; using all as measure variables
#10문항 histogram
ggplot(data = melt(cdata10), aes(x = value)) +
facet_wrap(~variable) + geom_histogram()
## No id variables; using all as measure variables
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#10문항 box plot
ggplot(data = melt(cdata10), aes(x = variable, y = value)) +
geom_boxplot(aes(fill = variable))
## No id variables; using all as measure variables
library(psych)
#6문항
#p6 <- polychoric(cdata6)
#p6$rho
#cdata6에서 polychoric correlation을 구할 수 없음.
#Error 발생 = You have more than 8 categories for your items, polychoric is probably not needed
p10 <- polychoric(cdata10)
## Warning in matpLower(x, nvar, gminx, gmaxx, gminy, gmaxy): 45 cells were
## adjusted for 0 values using the correction for continuity. Examine your
## data carefully.
p10$rho
## K1 K2 K3 K4 K5 K6
## K1 1.00000000 0.4070532 0.2360273 0.36560926 0.21087448 -0.08365093
## K2 0.40705321 1.0000000 0.4445935 0.23702879 0.23598353 0.42514641
## K3 0.23602728 0.4445935 1.0000000 0.14233279 0.23645929 0.22851278
## K4 0.36560926 0.2370288 0.1423328 1.00000000 0.07146097 0.44271910
## K5 0.21087448 0.2359835 0.2364593 0.07146097 1.00000000 -0.23606798
## K6 -0.08365093 0.4251464 0.2285128 0.44271910 -0.23606798 1.00000000
## K7 0.15704103 0.2297819 0.2952894 0.16465521 -0.21709064 0.33325554
## K8 0.09559189 0.1971690 0.2360680 0.23606798 0.22704774 -0.00352604
## K9 0.29205102 0.2354520 0.4552750 0.32289849 0.15301957 0.24227922
## K10 0.14362246 0.2345615 0.1524099 0.25219857 0.18575507 0.23610867
## K7 K8 K9 K10
## K1 0.1570410 0.09559189 0.2920510 0.1436225
## K2 0.2297819 0.19716903 0.2354520 0.2345615
## K3 0.2952894 0.23606798 0.4552750 0.1524099
## K4 0.1646552 0.23606798 0.3228985 0.2521986
## K5 -0.2170906 0.22704774 0.1530196 0.1857551
## K6 0.3332555 -0.00352604 0.2422792 0.2361087
## K7 1.0000000 0.22078539 0.1555788 -0.2353172
## K8 0.2207854 1.00000000 0.2374248 0.1568408
## K9 0.1555788 0.23742480 1.0000000 0.2360680
## K10 -0.2353172 0.15684080 0.2360680 1.0000000
library(psych)
#parallel plot
#fa.parallel(p6$rho)
#scree plot
#scree(p6$rho)
#EFA factor 1 ~ 2
#1
#fff1 <- fa(p6$rho, 1, n.obs = 998, fm = "ml")
#print(fff1)
#print(fff1$loadings, cutoff = 0.4)
#fa.diagram(fff1, cut = 0, simple = T)
#2
#fff2 <- fa(p6$rho, 2, n.obs = 998, fm = "ml", rotate = "oblimin")
#print(fff2)
#print(fff2$loadings, cutoff = 0.4)
#fa.diagram(fff2, cut = 0, simple = T)
#parallel plot
fa.parallel(p10$rho)
## Warning in fa.parallel(p10$rho): It seems as if you are using a correlation
## matrix, but have not specified the number of cases. The number of subjects
## is arbitrarily set to be 100
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs
## = np.obs, : The estimated weights for the factor scores are probably
## incorrect. Try a different factor extraction method.
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs
## = np.obs, : The estimated weights for the factor scores are probably
## incorrect. Try a different factor extraction method.
## Parallel analysis suggests that the number of factors = 3 and the number of components = 2
#scree plot
scree(p10$rho)
#EFA factor 1 ~ 2
#1
ffff1 <- fa(p10$rho, 1, n.obs = 998, fm = "ml")
print(ffff1)
## Factor Analysis using method = ml
## Call: fa(r = p10$rho, nfactors = 1, n.obs = 998, fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 h2 u2 com
## K1 0.47 0.217 0.78 1
## K2 0.66 0.437 0.56 1
## K3 0.62 0.382 0.62 1
## K4 0.50 0.250 0.75 1
## K5 0.24 0.059 0.94 1
## K6 0.45 0.204 0.80 1
## K7 0.34 0.113 0.89 1
## K8 0.35 0.125 0.87 1
## K9 0.57 0.321 0.68 1
## K10 0.34 0.114 0.89 1
##
## ML1
## SS loadings 2.22
## Proportion Var 0.22
##
## Mean item complexity = 1
## Test of the hypothesis that 1 factor is sufficient.
##
## The degrees of freedom for the null model are 45 and the objective function was 2.77 with Chi Square of 2751.73
## The degrees of freedom for the model are 35 and the objective function was 1.57
##
## The root mean square of the residuals (RMSR) is 0.13
## The df corrected root mean square of the residuals is 0.15
##
## The harmonic number of observations is 998 with the empirical chi square 1498.28 with prob < 1.4e-292
## The total number of observations was 998 with Likelihood Chi Square = 1554.1 with prob < 2e-304
##
## Tucker Lewis Index of factoring reliability = 0.278
## RMSEA index = 0.209 and the 90 % confidence intervals are 0.2 0.218
## BIC = 1312.4
## Fit based upon off diagonal values = 0.74
## Measures of factor score adequacy
## ML1
## Correlation of (regression) scores with factors 0.87
## Multiple R square of scores with factors 0.76
## Minimum correlation of possible factor scores 0.52
print(ffff1$loadings, cutoff = 0.4)
##
## Loadings:
## ML1
## K1 0.466
## K2 0.661
## K3 0.618
## K4 0.500
## K5
## K6 0.452
## K7
## K8
## K9 0.566
## K10
##
## ML1
## SS loadings 2.223
## Proportion Var 0.222
fa.diagram(ffff1, cut = 0, simple = T)
#2
ffff2 <- fa(p10$rho, 2, n.obs = 998, fm = "ml", rotate = "oblimin")
print(ffff2)
## Factor Analysis using method = ml
## Call: fa(r = p10$rho, nfactors = 2, n.obs = 998, rotate = "oblimin",
## fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML2 ML1 h2 u2 com
## K1 0.64 -0.21 0.40 0.605 1.2
## K2 0.56 0.31 0.48 0.515 1.6
## K3 0.56 0.12 0.36 0.643 1.1
## K4 0.36 0.37 0.32 0.682 2.0
## K5 0.48 -0.33 0.28 0.719 1.8
## K6 0.00 1.00 1.00 0.005 1.0
## K7 0.16 0.30 0.14 0.864 1.5
## K8 0.40 -0.08 0.15 0.847 1.1
## K9 0.51 0.14 0.30 0.696 1.2
## K10 0.29 0.18 0.13 0.866 1.7
##
## ML2 ML1
## SS loadings 1.97 1.59
## Proportion Var 0.20 0.16
## Cumulative Var 0.20 0.36
## Proportion Explained 0.55 0.45
## Cumulative Proportion 0.55 1.00
##
## With factor correlations of
## ML2 ML1
## ML2 1.0 0.2
## ML1 0.2 1.0
##
## Mean item complexity = 1.4
## Test of the hypothesis that 2 factors are sufficient.
##
## The degrees of freedom for the null model are 45 and the objective function was 2.77 with Chi Square of 2751.73
## The degrees of freedom for the model are 26 and the objective function was 0.98
##
## The root mean square of the residuals (RMSR) is 0.1
## The df corrected root mean square of the residuals is 0.13
##
## The harmonic number of observations is 998 with the empirical chi square 872.26 with prob < 4e-167
## The total number of observations was 998 with Likelihood Chi Square = 973.4 with prob < 1.6e-188
##
## Tucker Lewis Index of factoring reliability = 0.393
## RMSEA index = 0.192 and the 90 % confidence intervals are 0.181 0.202
## BIC = 793.85
## Fit based upon off diagonal values = 0.85
## Measures of factor score adequacy
## ML2 ML1
## Correlation of (regression) scores with factors 0.87 1.00
## Multiple R square of scores with factors 0.75 1.00
## Minimum correlation of possible factor scores 0.50 0.99
print(ffff2$loadings, cutoff = 0.4)
##
## Loadings:
## ML2 ML1
## K1 0.636
## K2 0.562
## K3 0.563
## K4
## K5 0.484
## K6 0.997
## K7
## K8
## K9 0.505
## K10
##
## ML2 ML1
## SS loadings 1.921 1.550
## Proportion Var 0.192 0.155
## Cumulative Var 0.192 0.347
fa.diagram(ffff2, cut = 0, simple = T)
Mplus code
Mplus result : Factor1
Mplus code
Mplus result : Factor1
Mplus result : Factor2
Mplus result : Factor3
#echo = F : R code보이지 않고 결과만 출력.
#echo = T : R code와 결과 모두 출력.
setwd("C:/Users/LG/Desktop/old")
library(haven)
library(dplyr)
library(ggplot2)
library(reshape2)
mdata <- read_spss("MSH.sav")
head(mdata)
## # A tibble: 6 x 65
## ID ID_A1 ID_A2 ID_A3 ID_A4 ID_A4_1 ID_A5 ID_B1 ID_B2 ID_B2_1
## <dbl> <dbl+> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl+l> <dbl> <dbl+l>
## 1 1 1 [남] 70 4 [이혼(~ 5 [고등학~ 12 1456 3 [그저 ~ 4 2 [아니오~
## 2 2 1 [남] 71 2 [유배우~ 7 [대학교~ 18 4580 2 [건강한~ 2 2 [아니오~
## 3 3 2 [여] 71 2 [유배우~ 5 [고등학~ 12 4580 2 [건강한~ 3 2 [아니오~
## 4 4 1 [남] 82 2 [유배우~ 7 [대학교~ 18 3200 4 [건강이~ 7 1 [예]
## 5 5 1 [남] 68 2 [유배우~ 3 [초등학~ 6 4946 2 [건강한~ 0 2 [아니오~
## 6 6 2 [여] 66 2 [유배우~ 3 [초등학~ 6 4946 2 [건강한~ 0 2 [아니오~
## # ... with 55 more variables: ID_B2_2 <dbl+lbl>, ID_B3 <dbl>, ID_B4 <dbl>,
## # ID_B5 <dbl>, M_total <dbl>, M_target <dbl+lbl>, card_V <dbl>,
## # v1_1 <dbl+lbl>, v1_2 <dbl+lbl>, v1_3 <dbl+lbl>, v1_4 <dbl+lbl>,
## # v1_5 <dbl+lbl>, v2_1 <dbl+lbl>, v2_2 <dbl+lbl>, v2_3 <dbl+lbl>,
## # v2_4 <dbl+lbl>, v2_5 <dbl+lbl>, v3_1 <dbl+lbl>, v3_2 <dbl+lbl>,
## # v3_3 <dbl+lbl>, v4_1 <dbl+lbl>, v4_2 <dbl+lbl>, v4_3 <dbl+lbl>,
## # v4_4 <dbl+lbl>, v4_5 <dbl+lbl>, v5_1 <dbl+lbl>, v5_2 <dbl+lbl>,
## # v5_3 <dbl+lbl>, v6_1 <dbl+lbl>, v6_2 <dbl+lbl>, v7 <dbl+lbl>,
## # v8_1 <dbl+lbl>, v8_2 <dbl+lbl>, v8_3 <dbl+lbl>, v9 <dbl+lbl>,
## # v10_1 <dbl+lbl>, v10_2 <dbl+lbl>, card_M <dbl>, M1 <dbl>, M3 <dbl>,
## # M2 <dbl>, M4 <dbl>, M5 <dbl>, M6 <dbl>, card_K <dbl>, K1 <dbl>,
## # K2 <dbl>, K3 <dbl>, K5 <dbl>, K4 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>,
## # K9 <dbl>, K10 <dbl>
tail(mdata)
## # A tibble: 6 x 65
## ID ID_A1 ID_A2 ID_A3 ID_A4 ID_A4_1 ID_A5 ID_B1 ID_B2 ID_B2_1
## <dbl> <dbl+> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl+l> <dbl> <dbl+l>
## 1 10295 2 [여] 73 2 [유배우~ 3 [초등학~ 6 1116 5 [건강이~ 11 1 [예]
## 2 10296 2 [여] 84 3 [사별(~ 2 [무학(~ 5 681 4 [건강이~ 7 1 [예]
## 3 10297 2 [여] 71 2 [유배우~ 2 [무학(~ 4 1147 4 [건강이~ 6 2 [아니오~
## 4 10298 2 [여] 68 3 [사별(~ 2 [무학(~ 0 684 4 [건강이~ 3 2 [아니오~
## 5 10299 2 [여] 84 3 [사별(~ 2 [무학(~ 0 1420 2 [건강한~ 3 2 [아니오~
## 6 10300 1 [남] 66 4 [이혼(~ 5 [고등학~ 12 1179 3 [그저 ~ 3 2 [아니오~
## # ... with 55 more variables: ID_B2_2 <dbl+lbl>, ID_B3 <dbl>, ID_B4 <dbl>,
## # ID_B5 <dbl>, M_total <dbl>, M_target <dbl+lbl>, card_V <dbl>,
## # v1_1 <dbl+lbl>, v1_2 <dbl+lbl>, v1_3 <dbl+lbl>, v1_4 <dbl+lbl>,
## # v1_5 <dbl+lbl>, v2_1 <dbl+lbl>, v2_2 <dbl+lbl>, v2_3 <dbl+lbl>,
## # v2_4 <dbl+lbl>, v2_5 <dbl+lbl>, v3_1 <dbl+lbl>, v3_2 <dbl+lbl>,
## # v3_3 <dbl+lbl>, v4_1 <dbl+lbl>, v4_2 <dbl+lbl>, v4_3 <dbl+lbl>,
## # v4_4 <dbl+lbl>, v4_5 <dbl+lbl>, v5_1 <dbl+lbl>, v5_2 <dbl+lbl>,
## # v5_3 <dbl+lbl>, v6_1 <dbl+lbl>, v6_2 <dbl+lbl>, v7 <dbl+lbl>,
## # v8_1 <dbl+lbl>, v8_2 <dbl+lbl>, v8_3 <dbl+lbl>, v9 <dbl+lbl>,
## # v10_1 <dbl+lbl>, v10_2 <dbl+lbl>, card_M <dbl>, M1 <dbl>, M3 <dbl>,
## # M2 <dbl>, M4 <dbl>, M5 <dbl>, M6 <dbl>, card_K <dbl>, K1 <dbl>,
## # K2 <dbl>, K3 <dbl>, K5 <dbl>, K4 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>,
## # K9 <dbl>, K10 <dbl>
#인지기능 저하집단
newdata <- mdata %>% filter(M_target == 1)
head(newdata)
## # A tibble: 6 x 65
## ID ID_A1 ID_A2 ID_A3 ID_A4 ID_A4_1 ID_A5 ID_B1 ID_B2 ID_B2_1
## <dbl> <dbl+> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl+l> <dbl> <dbl+l>
## 1 4 1 [남] 82 2 [유배우~ 7 [대학교~ 18 3200 4 [건강이~ 7 1 [예]
## 2 7 1 [남] 75 2 [유배우~ 5 [고등학~ 12 1819 2 [건강한~ 1 2 [아니오~
## 3 8 2 [여] 71 2 [유배우~ 4 [중학교~ 9 1819 4 [건강이~ 4 2 [아니오~
## 4 14 2 [여] 68 2 [유배우~ 5 [고등학~ 12 2212 2 [건강한~ 1 2 [아니오~
## 5 30 2 [여] 65 2 [유배우~ 3 [초등학~ 6 3117 4 [건강이~ 2 2 [아니오~
## 6 35 2 [여] 68 3 [사별(~ 4 [중학교~ 9 1116 4 [건강이~ 3 2 [아니오~
## # ... with 55 more variables: ID_B2_2 <dbl+lbl>, ID_B3 <dbl>, ID_B4 <dbl>,
## # ID_B5 <dbl>, M_total <dbl>, M_target <dbl+lbl>, card_V <dbl>,
## # v1_1 <dbl+lbl>, v1_2 <dbl+lbl>, v1_3 <dbl+lbl>, v1_4 <dbl+lbl>,
## # v1_5 <dbl+lbl>, v2_1 <dbl+lbl>, v2_2 <dbl+lbl>, v2_3 <dbl+lbl>,
## # v2_4 <dbl+lbl>, v2_5 <dbl+lbl>, v3_1 <dbl+lbl>, v3_2 <dbl+lbl>,
## # v3_3 <dbl+lbl>, v4_1 <dbl+lbl>, v4_2 <dbl+lbl>, v4_3 <dbl+lbl>,
## # v4_4 <dbl+lbl>, v4_5 <dbl+lbl>, v5_1 <dbl+lbl>, v5_2 <dbl+lbl>,
## # v5_3 <dbl+lbl>, v6_1 <dbl+lbl>, v6_2 <dbl+lbl>, v7 <dbl+lbl>,
## # v8_1 <dbl+lbl>, v8_2 <dbl+lbl>, v8_3 <dbl+lbl>, v9 <dbl+lbl>,
## # v10_1 <dbl+lbl>, v10_2 <dbl+lbl>, card_M <dbl>, M1 <dbl>, M3 <dbl>,
## # M2 <dbl>, M4 <dbl>, M5 <dbl>, M6 <dbl>, card_K <dbl>, K1 <dbl>,
## # K2 <dbl>, K3 <dbl>, K5 <dbl>, K4 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>,
## # K9 <dbl>, K10 <dbl>
tail(newdata)
## # A tibble: 6 x 65
## ID ID_A1 ID_A2 ID_A3 ID_A4 ID_A4_1 ID_A5 ID_B1 ID_B2 ID_B2_1
## <dbl> <dbl+> <dbl> <dbl+l> <dbl+l> <dbl> <dbl> <dbl+l> <dbl> <dbl+l>
## 1 10252 1 [남] 71 2 [유배우~ 5 [고등학~ 12 2276 4 [건강이~ 2 2 [아니오~
## 2 10257 2 [여] 70 2 [유배우~ 4 [중학교~ 9 4151 2 [건강한~ 3 2 [아니오~
## 3 10287 1 [남] 94 2 [유배우~ 7 [대학교~ 16 1431 5 [건강이~ 4 2 [아니오~
## 4 10288 2 [여] 90 2 [유배우~ 5 [고등학~ 12 1431 5 [건강이~ 2 2 [아니오~
## 5 10290 2 [여] 69 3 [사별(~ 4 [중학교~ 9 723 5 [건강이~ 3 2 [아니오~
## 6 10291 1 [남] 85 2 [유배우~ 3 [초등학~ 8 1801 2 [건강한~ 3 2 [아니오~
## # ... with 55 more variables: ID_B2_2 <dbl+lbl>, ID_B3 <dbl>, ID_B4 <dbl>,
## # ID_B5 <dbl>, M_total <dbl>, M_target <dbl+lbl>, card_V <dbl>,
## # v1_1 <dbl+lbl>, v1_2 <dbl+lbl>, v1_3 <dbl+lbl>, v1_4 <dbl+lbl>,
## # v1_5 <dbl+lbl>, v2_1 <dbl+lbl>, v2_2 <dbl+lbl>, v2_3 <dbl+lbl>,
## # v2_4 <dbl+lbl>, v2_5 <dbl+lbl>, v3_1 <dbl+lbl>, v3_2 <dbl+lbl>,
## # v3_3 <dbl+lbl>, v4_1 <dbl+lbl>, v4_2 <dbl+lbl>, v4_3 <dbl+lbl>,
## # v4_4 <dbl+lbl>, v4_5 <dbl+lbl>, v5_1 <dbl+lbl>, v5_2 <dbl+lbl>,
## # v5_3 <dbl+lbl>, v6_1 <dbl+lbl>, v6_2 <dbl+lbl>, v7 <dbl+lbl>,
## # v8_1 <dbl+lbl>, v8_2 <dbl+lbl>, v8_3 <dbl+lbl>, v9 <dbl+lbl>,
## # v10_1 <dbl+lbl>, v10_2 <dbl+lbl>, card_M <dbl>, M1 <dbl>, M3 <dbl>,
## # M2 <dbl>, M4 <dbl>, M5 <dbl>, M6 <dbl>, card_K <dbl>, K1 <dbl>,
## # K2 <dbl>, K3 <dbl>, K5 <dbl>, K4 <dbl>, K6 <dbl>, K7 <dbl>, K8 <dbl>,
## # K9 <dbl>, K10 <dbl>
nrow(newdata)
## [1] 1998
#문항 6
data6 <- newdata %>% .[c(1:999), c(49:54)]
data6 <- data6[c(1,3,2,4,5,6)]
head(data6)
## # A tibble: 6 x 6
## M1 M2 M3 M4 M5 M6
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 8 3 4 5 1 2
## 2 8 3 5 6 1 2
## 3 7 1 4 6 1 2
## 4 9 3 5 5 1 2
## 5 9 1 3 6 0 2
## 6 10 2 5 5 1 1
tail(data6)
## # A tibble: 6 x 6
## M1 M2 M3 M4 M5 M6
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 5 1 3 5 0 2
## 2 9 0 4 6 0 1
## 3 4 0 6 5 0 1
## 4 10 1 3 3 1 2
## 5 8 2 4 6 1 2
## 6 7 0 3 4 0 2
nrow(data6)
## [1] 999
#문항 10
data10 <- newdata %>% .[c(1:999), c(56:65)]
data10 <- data10[c(1,2,3,5,4,6,7,8,9,10)]
head(data10)
## # A tibble: 6 x 10
## K1 K2 K3 K4 K5 K6 K7 K8 K9 K10
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 4 4 3 3 1 2 0 3 1 2
## 2 4 4 3 3 2 2 1 3 1 2
## 3 3 4 2 1 2 2 1 3 1 2
## 4 4 5 3 3 2 2 1 2 1 2
## 5 4 5 3 1 0 2 1 3 0 2
## 6 5 5 3 2 2 2 1 2 1 1
tail(data10)
## # A tibble: 6 x 10
## K1 K2 K3 K4 K5 K6 K7 K8 K9 K10
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 4 3 1 0 2 0 3 0 2
## 2 5 4 3 0 1 2 1 3 0 1
## 3 1 3 3 0 3 2 1 2 0 1
## 4 5 5 3 1 0 2 0 1 1 2
## 5 4 4 3 2 1 2 1 3 1 2
## 6 3 4 2 0 1 2 0 2 0 2
nrow(data10)
## [1] 999
#문항 6 결측치 확인
colSums(is.na(data6))
## M1 M2 M3 M4 M5 M6
## 0 0 0 1 0 0
cdata6 <- data6 %>% filter(!is.na(M4))
colSums(is.na(cdata6))
## M1 M2 M3 M4 M5 M6
## 0 0 0 0 0 0
#문항 10 결측치 확인
colSums(is.na(data10))
## K1 K2 K3 K4 K5 K6 K7 K8 K9 K10
## 0 0 0 0 0 0 0 1 0 0
cdata10 <- data10 %>% filter(!is.na(K8))
#K8이외에 결측치가 있는 문항은 &로 연결함.
#filter(!is.na(v8_1) & !is.na(v8_2) & !is.na(v8_3) & !is.na(v9))
colSums(is.na(cdata10))
## K1 K2 K3 K4 K5 K6 K7 K8 K9 K10
## 0 0 0 0 0 0 0 0 0 0
#문항 6 요약, 평균, 표준편차
as.table(apply(cdata6, 2, summary))
## M1 M2 M3 M4 M5 M6
## Min. 0.0000000 0.0000000 0.0000000 2.0000000 0.0000000 0.0000000
## 1st Qu. 7.0000000 0.0000000 3.0000000 5.0000000 0.0000000 1.0000000
## Median 8.0000000 1.0000000 4.0000000 6.0000000 0.0000000 2.0000000
## Mean 8.0040080 1.3597194 3.7795591 5.2284569 0.3777555 1.6442886
## 3rd Qu. 10.0000000 2.0000000 5.0000000 6.0000000 1.0000000 2.0000000
## Max. 10.0000000 5.0000000 6.0000000 6.0000000 1.0000000 2.0000000
as.table(apply(cdata6, 2, mean))
## M1 M2 M3 M4 M5 M6
## 8.0040080 1.3597194 3.7795591 5.2284569 0.3777555 1.6442886
as.table(apply(cdata6, 2, sd))
## M1 M2 M3 M4 M5 M6
## 1.9455950 1.3473332 1.1495510 1.0173578 0.4850691 0.5054591
#문항 10 요약, 평균, 표준편차
as.table(apply(cdata10, 2, summary))
## K1 K2 K3 K4 K5 K6
## Min. 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
## 1st Qu. 3.0000000 4.0000000 3.0000000 0.0000000 0.0000000 2.0000000
## Median 4.0000000 5.0000000 3.0000000 1.0000000 1.0000000 2.0000000
## Mean 3.6082164 4.3957916 2.8376754 1.3597194 0.9418838 1.9839679
## 3rd Qu. 5.0000000 5.0000000 3.0000000 2.0000000 2.0000000 2.0000000
## Max. 5.0000000 5.0000000 3.0000000 5.0000000 3.0000000 2.0000000
## K7 K8 K9 K10
## Min. 0.0000000 0.0000000 0.0000000 0.0000000
## 1st Qu. 0.0000000 2.0000000 0.0000000 1.0000000
## Median 1.0000000 3.0000000 0.0000000 2.0000000
## Mean 0.7144289 2.5300601 0.3777555 1.6442886
## 3rd Qu. 1.0000000 3.0000000 1.0000000 2.0000000
## Max. 1.0000000 3.0000000 1.0000000 2.0000000
as.table(apply(cdata10, 2, mean))
## K1 K2 K3 K4 K5 K6 K7
## 3.6082164 4.3957916 2.8376754 1.3597194 0.9418838 1.9839679 0.7144289
## K8 K9 K10
## 2.5300601 0.3777555 1.6442886
as.table(apply(cdata10, 2, sd))
## K1 K2 K3 K4 K5 K6 K7
## 1.3955843 0.9494032 0.5064315 1.3473332 0.9733816 0.1476784 0.4519125
## K8 K9 K10
## 0.8164545 0.4850691 0.5054591
#6문항 histogram
ggplot(data = melt(cdata6), aes(x = value)) +
facet_wrap(~variable) + geom_histogram()
## No id variables; using all as measure variables
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#6문항 box plot
ggplot(data = melt(cdata6), aes(x = variable, y = value)) +
geom_boxplot(aes(fill = variable))
## No id variables; using all as measure variables
#10문항 histogram
ggplot(data = melt(cdata10), aes(x = value)) +
facet_wrap(~variable) + geom_histogram()
## No id variables; using all as measure variables
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#10문항 box plot
ggplot(data = melt(cdata10), aes(x = variable, y = value)) +
geom_boxplot(aes(fill = variable))
## No id variables; using all as measure variables
library(psych)
#parallel plot
fa.parallel(cdata6)
## Parallel analysis suggests that the number of factors = 3 and the number of components = 1
#scree plot
scree(cdata6)
#EFA factor 1 ~ 6
#1
fff1 <- fa(cdata6, 1, fm = "ml")
print(fff1)
## Factor Analysis using method = ml
## Call: fa(r = cdata6, nfactors = 1, fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 h2 u2 com
## M1 0.57 0.329 0.67 1
## M2 0.54 0.297 0.70 1
## M3 0.29 0.085 0.92 1
## M4 0.33 0.111 0.89 1
## M5 0.47 0.223 0.78 1
## M6 0.32 0.105 0.89 1
##
## ML1
## SS loadings 1.15
## Proportion Var 0.19
##
## Mean item complexity = 1
## Test of the hypothesis that 1 factor is sufficient.
##
## The degrees of freedom for the null model are 15 and the objective function was 0.41 with Chi Square of 407.14
## The degrees of freedom for the model are 9 and the objective function was 0.02
##
## The root mean square of the residuals (RMSR) is 0.03
## The df corrected root mean square of the residuals is 0.04
##
## The harmonic number of observations is 998 with the empirical chi square 25.1 with prob < 0.0029
## The total number of observations was 998 with Likelihood Chi Square = 18.83 with prob < 0.027
##
## Tucker Lewis Index of factoring reliability = 0.958
## RMSEA index = 0.033 and the 90 % confidence intervals are 0.011 0.054
## BIC = -43.32
## Fit based upon off diagonal values = 0.98
## Measures of factor score adequacy
## ML1
## Correlation of (regression) scores with factors 0.78
## Multiple R square of scores with factors 0.61
## Minimum correlation of possible factor scores 0.21
print(fff1$loadings, cutoff = 0.4)
##
## Loadings:
## ML1
## M1 0.573
## M2 0.545
## M3
## M4
## M5 0.473
## M6
##
## ML1
## SS loadings 1.149
## Proportion Var 0.192
fa.diagram(fff1, cut = 0, simple = T)
#2
fff2 <- fa(cdata6, 2, fm = "ml", rotate = "oblimin")
print(fff2)
## Factor Analysis using method = ml
## Call: fa(r = cdata6, nfactors = 2, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML2 ML1 h2 u2 com
## M1 0.60 -0.03 0.355 0.645 1.0
## M2 0.52 0.04 0.282 0.718 1.0
## M3 0.28 0.03 0.085 0.915 1.0
## M4 0.00 1.00 0.995 0.005 1.0
## M5 0.44 0.05 0.209 0.791 1.0
## M6 0.36 -0.07 0.121 0.879 1.1
##
## ML2 ML1
## SS loadings 1.04 1.01
## Proportion Var 0.17 0.17
## Cumulative Var 0.17 0.34
## Proportion Explained 0.51 0.49
## Cumulative Proportion 0.51 1.00
##
## With factor correlations of
## ML2 ML1
## ML2 1.00 0.32
## ML1 0.32 1.00
##
## Mean item complexity = 1
## Test of the hypothesis that 2 factors are sufficient.
##
## The degrees of freedom for the null model are 15 and the objective function was 0.41 with Chi Square of 407.14
## The degrees of freedom for the model are 4 and the objective function was 0.01
##
## The root mean square of the residuals (RMSR) is 0.02
## The df corrected root mean square of the residuals is 0.04
##
## The harmonic number of observations is 998 with the empirical chi square 12.25 with prob < 0.016
## The total number of observations was 998 with Likelihood Chi Square = 9.79 with prob < 0.044
##
## Tucker Lewis Index of factoring reliability = 0.945
## RMSEA index = 0.038 and the 90 % confidence intervals are 0.006 0.069
## BIC = -17.83
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy
## ML2 ML1
## Correlation of (regression) scores with factors 0.78 1.00
## Multiple R square of scores with factors 0.61 1.00
## Minimum correlation of possible factor scores 0.21 0.99
print(fff2$loadings, cutoff = 0.4)
##
## Loadings:
## ML2 ML1
## M1 0.604
## M2 0.518
## M3
## M4 0.997
## M5 0.439
## M6
##
## ML2 ML1
## SS loadings 1.037 1.004
## Proportion Var 0.173 0.167
## Cumulative Var 0.173 0.340
fa.diagram(fff2, cut = 0, simple = T)
#3
fff3 <- fa(cdata6, 3, fm = "ml", rotate = "oblimin")
print(fff3)
## Factor Analysis using method = ml
## Call: fa(r = cdata6, nfactors = 3, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 ML3 ML2 h2 u2 com
## M1 -0.02 0.53 0.11 0.32 0.679 1.1
## M2 0.02 0.59 -0.07 0.33 0.666 1.0
## M3 0.00 0.00 0.77 0.59 0.412 1.0
## M4 1.00 0.00 0.00 1.00 0.005 1.0
## M5 0.05 0.44 0.01 0.21 0.790 1.0
## M6 -0.07 0.37 0.00 0.12 0.876 1.1
##
## ML1 ML3 ML2
## SS loadings 1.00 0.96 0.61
## Proportion Var 0.17 0.16 0.10
## Cumulative Var 0.17 0.33 0.43
## Proportion Explained 0.39 0.37 0.24
## Cumulative Proportion 0.39 0.76 1.00
##
## With factor correlations of
## ML1 ML3 ML2
## ML1 1.00 0.32 0.14
## ML3 0.32 1.00 0.34
## ML2 0.14 0.34 1.00
##
## Mean item complexity = 1
## Test of the hypothesis that 3 factors are sufficient.
##
## The degrees of freedom for the null model are 15 and the objective function was 0.41 with Chi Square of 407.14
## The degrees of freedom for the model are 0 and the objective function was 0
##
## The root mean square of the residuals (RMSR) is 0
## The df corrected root mean square of the residuals is NA
##
## The harmonic number of observations is 998 with the empirical chi square 0 with prob < NA
## The total number of observations was 998 with Likelihood Chi Square = 0 with prob < NA
##
## Tucker Lewis Index of factoring reliability = -Inf
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy
## ML1 ML3 ML2
## Correlation of (regression) scores with factors 1.00 0.78 0.78
## Multiple R square of scores with factors 0.99 0.60 0.61
## Minimum correlation of possible factor scores 0.99 0.21 0.21
print(fff3$loadings, cutoff = 0.4)
##
## Loadings:
## ML1 ML3 ML2
## M1 0.527
## M2 0.591
## M3 0.765
## M4 0.997
## M5 0.436
## M6
##
## ML1 ML3 ML2
## SS loadings 1.002 0.953 0.603
## Proportion Var 0.167 0.159 0.100
## Cumulative Var 0.167 0.326 0.426
fa.diagram(fff3, cut = 0, simple = T)
#4
fff4 <- fa(cdata6, 4, fm = "ml", rotate = "oblimin")
print(fff4)
## Factor Analysis using method = ml
## Call: fa(r = cdata6, nfactors = 4, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 ML2 ML4 ML3 h2 u2 com
## M1 0.66 -0.01 0.00 0.01 0.43 0.57 1.0
## M2 0.25 0.19 0.15 -0.25 0.36 0.64 3.5
## M3 0.24 0.12 0.06 0.29 0.19 0.81 2.4
## M4 -0.03 0.54 -0.03 0.01 0.26 0.74 1.0
## M5 0.12 0.26 0.17 -0.03 0.22 0.78 2.3
## M6 -0.03 -0.03 0.50 0.01 0.22 0.78 1.0
##
## ML1 ML2 ML4 ML3
## SS loadings 0.67 0.48 0.37 0.15
## Proportion Var 0.11 0.08 0.06 0.03
## Cumulative Var 0.11 0.19 0.25 0.28
## Proportion Explained 0.40 0.29 0.22 0.09
## Cumulative Proportion 0.40 0.69 0.91 1.00
##
## With factor correlations of
## ML1 ML2 ML4 ML3
## ML1 1.00 0.58 0.68 -0.08
## ML2 0.58 1.00 0.39 -0.17
## ML4 0.68 0.39 1.00 -0.26
## ML3 -0.08 -0.17 -0.26 1.00
##
## Mean item complexity = 1.9
## Test of the hypothesis that 4 factors are sufficient.
##
## The degrees of freedom for the null model are 15 and the objective function was 0.41 with Chi Square of 407.14
## The degrees of freedom for the model are -3 and the objective function was 0
##
## The root mean square of the residuals (RMSR) is 0
## The df corrected root mean square of the residuals is NA
##
## The harmonic number of observations is 998 with the empirical chi square 0 with prob < NA
## The total number of observations was 998 with Likelihood Chi Square = 0 with prob < NA
##
## Tucker Lewis Index of factoring reliability = 1.038
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy
## ML1 ML2 ML4 ML3
## Correlation of (regression) scores with factors 0.77 0.68 0.68 0.44
## Multiple R square of scores with factors 0.59 0.47 0.46 0.20
## Minimum correlation of possible factor scores 0.19 -0.06 -0.08 -0.61
print(fff4$loadings, cutoff = 0.4)
##
## Loadings:
## ML1 ML2 ML4 ML3
## M1 0.662
## M2
## M3
## M4 0.541
## M5
## M6 0.501
##
## ML1 ML2 ML4 ML3
## SS loadings 0.576 0.412 0.308 0.146
## Proportion Var 0.096 0.069 0.051 0.024
## Cumulative Var 0.096 0.165 0.216 0.240
fa.diagram(fff4, cut = 0, simple = T)
#5
fff5 <- fa(cdata6, 5, fm = "ml", rotate = "oblimin")
print(fff5)
## Factor Analysis using method = ml
## Call: fa(r = cdata6, nfactors = 5, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML5 ML1 ML3 ML2 ML4 h2 u2 com
## M1 0.02 0.63 0.02 0.02 -0.01 0.44 0.56 1.0
## M2 0.61 0.04 0.00 -0.01 0.02 0.40 0.60 1.0
## M3 -0.03 0.04 -0.02 0.47 0.02 0.23 0.77 1.0
## M4 0.19 -0.08 0.24 0.13 -0.19 0.20 0.80 3.8
## M5 -0.01 0.09 0.46 -0.01 0.04 0.27 0.73 1.1
## M6 0.14 -0.02 0.10 0.08 0.33 0.19 0.81 1.7
##
## ML5 ML1 ML3 ML2 ML4
## SS loadings 0.50 0.45 0.36 0.28 0.15
## Proportion Var 0.08 0.08 0.06 0.05 0.03
## Cumulative Var 0.08 0.16 0.22 0.26 0.29
## Proportion Explained 0.29 0.26 0.20 0.16 0.09
## Cumulative Proportion 0.29 0.55 0.75 0.91 1.00
##
## With factor correlations of
## ML5 ML1 ML3 ML2 ML4
## ML5 1.00 0.70 0.75 0.35 0.19
## ML1 0.70 1.00 0.61 0.65 0.29
## ML3 0.75 0.61 1.00 0.51 0.05
## ML2 0.35 0.65 0.51 1.00 0.01
## ML4 0.19 0.29 0.05 0.01 1.00
##
## Mean item complexity = 1.6
## Test of the hypothesis that 5 factors are sufficient.
##
## The degrees of freedom for the null model are 15 and the objective function was 0.41 with Chi Square of 407.14
## The degrees of freedom for the model are -5 and the objective function was 0
##
## The root mean square of the residuals (RMSR) is 0
## The df corrected root mean square of the residuals is NA
##
## The harmonic number of observations is 998 with the empirical chi square 0 with prob < NA
## The total number of observations was 998 with Likelihood Chi Square = 0 with prob < NA
##
## Tucker Lewis Index of factoring reliability = 1.038
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy
## ML5 ML1 ML3 ML2
## Correlation of (regression) scores with factors 0.75 0.76 0.71 0.63
## Multiple R square of scores with factors 0.57 0.58 0.50 0.39
## Minimum correlation of possible factor scores 0.13 0.15 0.00 -0.21
## ML4
## Correlation of (regression) scores with factors 0.43
## Multiple R square of scores with factors 0.19
## Minimum correlation of possible factor scores -0.63
print(fff5$loadings, cutoff = 0.4)
##
## Loadings:
## ML5 ML1 ML3 ML2 ML4
## M1 0.626
## M2 0.613
## M3 0.470
## M4
## M5 0.461
## M6
##
## ML5 ML1 ML3 ML2 ML4
## SS loadings 0.434 0.409 0.280 0.245 0.146
## Proportion Var 0.072 0.068 0.047 0.041 0.024
## Cumulative Var 0.072 0.140 0.187 0.228 0.252
fa.diagram(fff5, cut = 0, simple = T)
#6
fff6 <- fa(cdata6, 6, fm = "ml", rotate = "oblimin")
## Warning in GPFoblq(L, Tmat = Tmat, normalize = normalize, eps = eps, maxit
## = maxit, : convergence not obtained in GPFoblq. 1000 iterations used.
print(fff6)
## Factor Analysis using method = ml
## Call: fa(r = cdata6, nfactors = 6, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 ML2 ML3 ML4 ML5 ML6 h2 u2 com
## M1 0.52 -0.03 0.03 0 0 0 0.27 0.73 1.0
## M2 0.51 0.01 -0.04 0 0 0 0.26 0.74 1.0
## M3 0.27 -0.01 0.12 0 0 0 0.10 0.90 1.4
## M4 0.33 0.11 0.03 0 0 0 0.13 0.87 1.2
## M5 0.46 0.03 -0.01 0 0 0 0.21 0.79 1.0
## M6 0.34 -0.10 -0.04 0 0 0 0.12 0.88 1.2
##
## ML1 ML2 ML3 ML4 ML5 ML6
## SS loadings 1.04 0.02 0.02 0.00 0.00 0.00
## Proportion Var 0.17 0.00 0.00 0.00 0.00 0.00
## Cumulative Var 0.17 0.18 0.18 0.18 0.18 0.18
## Proportion Explained 0.96 0.02 0.02 0.00 0.00 0.00
## Cumulative Proportion 0.96 0.98 1.00 1.00 1.00 1.00
##
## With factor correlations of
## ML1 ML2 ML3 ML4 ML5 ML6
## ML1 1.00 0.01 0.20 0 0 0
## ML2 0.01 1.00 0.16 0 0 0
## ML3 0.20 0.16 1.00 0 0 0
## ML4 0.00 0.00 0.00 1 0 0
## ML5 0.00 0.00 0.00 0 1 0
## ML6 0.00 0.00 0.00 0 0 1
##
## Mean item complexity = 1.1
## Test of the hypothesis that 6 factors are sufficient.
##
## The degrees of freedom for the null model are 15 and the objective function was 0.41 with Chi Square of 407.14
## The degrees of freedom for the model are -6 and the objective function was 0.02
##
## The root mean square of the residuals (RMSR) is 0.03
## The df corrected root mean square of the residuals is NA
##
## The harmonic number of observations is 998 with the empirical chi square 31 with prob < NA
## The total number of observations was 998 with Likelihood Chi Square = 19.65 with prob < NA
##
## Tucker Lewis Index of factoring reliability = 1.164
## Fit based upon off diagonal values = 0.97
## Measures of factor score adequacy
## ML1 ML2 ML3 ML4 ML5
## Correlation of (regression) scores with factors 0.74 0.16 0.21 0 0
## Multiple R square of scores with factors 0.55 0.03 0.05 0 0
## Minimum correlation of possible factor scores 0.09 -0.95 -0.91 -1 -1
## ML6
## Correlation of (regression) scores with factors 0
## Multiple R square of scores with factors 0
## Minimum correlation of possible factor scores -1
print(fff6$loadings, cutoff = 0.4)
##
## Loadings:
## ML1 ML2 ML3 ML4 ML5 ML6
## M1 0.516
## M2 0.512
## M3
## M4
## M5 0.457
## M6
##
## ML1 ML2 ML3 ML4 ML5 ML6
## SS loadings 1.034 0.023 0.018 0.000 0.000 0.000
## Proportion Var 0.172 0.004 0.003 0.000 0.000 0.000
## Cumulative Var 0.172 0.176 0.179 0.179 0.179 0.179
fa.diagram(fff6, cut = 0, simple = T)
#parallel plot
fa.parallel(cdata10)
## Parallel analysis suggests that the number of factors = 3 and the number of components = 2
#scree plot
scree(cdata10)
#EFA factor 1 ~ 6
#1
ffff1 <- fa(cdata10, 1, fm = "ml", rotate = "oblimin")
print(ffff1)
## Factor Analysis using method = ml
## Call: fa(r = cdata10, nfactors = 1, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 h2 u2 com
## K1 0.59 0.345 0.66 1
## K2 0.51 0.256 0.74 1
## K3 0.31 0.096 0.90 1
## K4 0.50 0.247 0.75 1
## K5 0.22 0.047 0.95 1
## K6 0.20 0.038 0.96 1
## K7 0.31 0.095 0.90 1
## K8 0.21 0.044 0.96 1
## K9 0.42 0.180 0.82 1
## K10 0.31 0.093 0.91 1
##
## ML1
## SS loadings 1.44
## Proportion Var 0.14
##
## Mean item complexity = 1
## Test of the hypothesis that 1 factor is sufficient.
##
## The degrees of freedom for the null model are 45 and the objective function was 0.69 with Chi Square of 689.77
## The degrees of freedom for the model are 35 and the objective function was 0.12
##
## The root mean square of the residuals (RMSR) is 0.04
## The df corrected root mean square of the residuals is 0.05
##
## The harmonic number of observations is 998 with the empirical chi square 172.06 with prob < 5.2e-20
## The total number of observations was 998 with Likelihood Chi Square = 116.14 with prob < 1.2e-10
##
## Tucker Lewis Index of factoring reliability = 0.838
## RMSEA index = 0.048 and the 90 % confidence intervals are 0.039 0.058
## BIC = -125.57
## Fit based upon off diagonal values = 0.91
## Measures of factor score adequacy
## ML1
## Correlation of (regression) scores with factors 0.81
## Multiple R square of scores with factors 0.65
## Minimum correlation of possible factor scores 0.30
print(ffff1$loadings, cutoff = 0.4)
##
## Loadings:
## ML1
## K1 0.587
## K2 0.506
## K3
## K4 0.497
## K5
## K6
## K7
## K8
## K9 0.424
## K10
##
## ML1
## SS loadings 1.441
## Proportion Var 0.144
fa.diagram(ffff1, cut = 0, simple = T)
#2
ffff2 <- fa(cdata10, 2, fm = "ml", rotate = "oblimin")
print(ffff2)
## Factor Analysis using method = ml
## Call: fa(r = cdata10, nfactors = 2, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML2 ML1 h2 u2 com
## K1 0.29 0.36 0.333 0.67 1.9
## K2 -0.02 0.66 0.418 0.58 1.0
## K3 0.01 0.34 0.122 0.88 1.0
## K4 0.56 0.01 0.322 0.68 1.0
## K5 0.11 0.12 0.041 0.96 2.0
## K6 -0.05 0.28 0.064 0.94 1.1
## K7 0.26 0.09 0.100 0.90 1.2
## K8 0.35 -0.12 0.092 0.91 1.2
## K9 0.48 0.00 0.232 0.77 1.0
## K10 0.23 0.12 0.094 0.91 1.5
##
## ML2 ML1
## SS loadings 0.95 0.87
## Proportion Var 0.10 0.09
## Cumulative Var 0.10 0.18
## Proportion Explained 0.52 0.48
## Cumulative Proportion 0.52 1.00
##
## With factor correlations of
## ML2 ML1
## ML2 1.00 0.56
## ML1 0.56 1.00
##
## Mean item complexity = 1.3
## Test of the hypothesis that 2 factors are sufficient.
##
## The degrees of freedom for the null model are 45 and the objective function was 0.69 with Chi Square of 689.77
## The degrees of freedom for the model are 26 and the objective function was 0.07
##
## The root mean square of the residuals (RMSR) is 0.03
## The df corrected root mean square of the residuals is 0.04
##
## The harmonic number of observations is 998 with the empirical chi square 94.09 with prob < 1.2e-09
## The total number of observations was 998 with Likelihood Chi Square = 65.94 with prob < 2.5e-05
##
## Tucker Lewis Index of factoring reliability = 0.893
## RMSEA index = 0.039 and the 90 % confidence intervals are 0.028 0.051
## BIC = -113.61
## Fit based upon off diagonal values = 0.95
## Measures of factor score adequacy
## ML2 ML1
## Correlation of (regression) scores with factors 0.77 0.77
## Multiple R square of scores with factors 0.60 0.60
## Minimum correlation of possible factor scores 0.19 0.20
print(ffff2$loadings, cutoff = 0.4)
##
## Loadings:
## ML2 ML1
## K1
## K2 0.656
## K3
## K4 0.561
## K5
## K6
## K7
## K8
## K9 0.484
## K10
##
## ML2 ML1
## SS loadings 0.892 0.806
## Proportion Var 0.089 0.081
## Cumulative Var 0.089 0.170
fa.diagram(ffff2, cut = 0, simple = T)
#3
ffff3 <- fa(cdata10, 3, fm = "ml", rotate = "oblimin")
print(ffff3)
## Factor Analysis using method = ml
## Call: fa(r = cdata10, nfactors = 3, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 ML2 ML3 h2 u2 com
## K1 0.65 -0.07 0.06 0.419 0.58 1.0
## K2 0.40 0.02 0.32 0.339 0.66 1.9
## K3 0.05 0.21 0.37 0.211 0.79 1.6
## K4 0.47 0.17 -0.13 0.300 0.70 1.4
## K5 0.16 0.05 0.08 0.046 0.95 1.7
## K6 0.07 0.04 0.25 0.083 0.92 1.2
## K7 -0.01 0.49 0.13 0.258 0.74 1.1
## K8 0.06 0.37 -0.12 0.160 0.84 1.3
## K9 0.40 0.17 -0.14 0.226 0.77 1.6
## K10 0.30 0.02 -0.02 0.095 0.90 1.0
##
## ML1 ML2 ML3
## SS loadings 1.17 0.55 0.41
## Proportion Var 0.12 0.06 0.04
## Cumulative Var 0.12 0.17 0.21
## Proportion Explained 0.55 0.26 0.19
## Cumulative Proportion 0.55 0.81 1.00
##
## With factor correlations of
## ML1 ML2 ML3
## ML1 1.00 0.40 0.28
## ML2 0.40 1.00 0.05
## ML3 0.28 0.05 1.00
##
## Mean item complexity = 1.4
## Test of the hypothesis that 3 factors are sufficient.
##
## The degrees of freedom for the null model are 45 and the objective function was 0.69 with Chi Square of 689.77
## The degrees of freedom for the model are 18 and the objective function was 0.03
##
## The root mean square of the residuals (RMSR) is 0.02
## The df corrected root mean square of the residuals is 0.03
##
## The harmonic number of observations is 998 with the empirical chi square 38.41 with prob < 0.0034
## The total number of observations was 998 with Likelihood Chi Square = 31.82 with prob < 0.023
##
## Tucker Lewis Index of factoring reliability = 0.946
## RMSEA index = 0.028 and the 90 % confidence intervals are 0.01 0.043
## BIC = -92.48
## Fit based upon off diagonal values = 0.98
## Measures of factor score adequacy
## ML1 ML2 ML3
## Correlation of (regression) scores with factors 0.81 0.66 0.60
## Multiple R square of scores with factors 0.65 0.44 0.36
## Minimum correlation of possible factor scores 0.30 -0.12 -0.28
print(ffff3$loadings, cutoff = 0.4)
##
## Loadings:
## ML1 ML2 ML3
## K1 0.652
## K2
## K3
## K4 0.472
## K5
## K6
## K7 0.491
## K8
## K9
## K10
##
## ML1 ML2 ML3
## SS loadings 1.091 0.488 0.382
## Proportion Var 0.109 0.049 0.038
## Cumulative Var 0.109 0.158 0.196
fa.diagram(ffff3, cut = 0, simple = T)
#4
ffff4 <- fa(cdata10, 4, fm = "ml", rotate = "oblimin")
print(ffff4)
## Factor Analysis using method = ml
## Call: fa(r = cdata10, nfactors = 4, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 ML3 ML2 ML4 h2 u2 com
## K1 0.07 0.39 0.33 -0.09 0.377 0.623 2.1
## K2 -0.02 0.02 0.64 0.03 0.437 0.563 1.0
## K3 0.07 -0.08 0.33 0.20 0.157 0.843 1.9
## K4 -0.03 0.57 -0.01 0.06 0.343 0.657 1.0
## K5 1.00 0.00 0.00 0.00 0.995 0.005 1.0
## K6 0.03 -0.07 0.26 0.06 0.065 0.935 1.3
## K7 0.01 0.04 0.07 0.53 0.321 0.679 1.0
## K8 0.01 0.22 -0.13 0.27 0.133 0.867 2.4
## K9 0.05 0.44 -0.02 0.06 0.220 0.780 1.1
## K10 0.02 0.26 0.10 -0.02 0.099 0.901 1.3
##
## ML1 ML3 ML2 ML4
## SS loadings 1.02 0.88 0.79 0.46
## Proportion Var 0.10 0.09 0.08 0.05
## Cumulative Var 0.10 0.19 0.27 0.31
## Proportion Explained 0.32 0.28 0.25 0.15
## Cumulative Proportion 0.32 0.60 0.85 1.00
##
## With factor correlations of
## ML1 ML3 ML2 ML4
## ML1 1.00 0.15 0.14 0.08
## ML3 0.15 1.00 0.51 0.32
## ML2 0.14 0.51 1.00 0.22
## ML4 0.08 0.32 0.22 1.00
##
## Mean item complexity = 1.4
## Test of the hypothesis that 4 factors are sufficient.
##
## The degrees of freedom for the null model are 45 and the objective function was 0.69 with Chi Square of 689.77
## The degrees of freedom for the model are 11 and the objective function was 0.02
##
## The root mean square of the residuals (RMSR) is 0.02
## The df corrected root mean square of the residuals is 0.03
##
## The harmonic number of observations is 998 with the empirical chi square 22.74 with prob < 0.019
## The total number of observations was 998 with Likelihood Chi Square = 17.78 with prob < 0.087
##
## Tucker Lewis Index of factoring reliability = 0.957
## RMSEA index = 0.025 and the 90 % confidence intervals are 0 0.045
## BIC = -58.18
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy
## ML1 ML3 ML2 ML4
## Correlation of (regression) scores with factors 1.00 0.77 0.77 0.64
## Multiple R square of scores with factors 0.99 0.59 0.59 0.41
## Minimum correlation of possible factor scores 0.99 0.19 0.17 -0.19
print(ffff4$loadings, cutoff = 0.4)
##
## Loadings:
## ML1 ML3 ML2 ML4
## K1
## K2 0.644
## K3
## K4 0.574
## K5 0.998
## K6
## K7 0.531
## K8
## K9 0.445
## K10
##
## ML1 ML3 ML2 ML4
## SS loadings 1.011 0.805 0.728 0.416
## Proportion Var 0.101 0.080 0.073 0.042
## Cumulative Var 0.101 0.182 0.254 0.296
fa.diagram(ffff4, cut = 0, simple = T)
#5
ffff5 <- fa(cdata10, 5, fm = "ml", rotate = "oblimin")
print(ffff5)
## Factor Analysis using method = ml
## Call: fa(r = cdata10, nfactors = 5, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 ML3 ML2 ML4 ML5 h2 u2 com
## K1 0.19 0.31 -0.01 -0.01 0.27 0.324 0.676 2.7
## K2 1.00 -0.01 0.00 0.00 -0.01 0.995 0.005 1.0
## K3 0.01 0.01 -0.01 0.60 0.01 0.368 0.632 1.0
## K4 -0.02 0.70 0.01 0.02 -0.03 0.481 0.519 1.0
## K5 -0.06 -0.07 0.01 0.10 0.44 0.195 0.805 1.2
## K6 0.06 0.02 -0.05 0.18 0.07 0.064 0.936 1.7
## K7 0.04 0.14 0.17 0.20 0.00 0.131 0.869 2.9
## K8 0.00 0.00 0.82 0.00 0.00 0.670 0.330 1.0
## K9 0.03 0.30 0.09 -0.04 0.21 0.206 0.794 2.1
## K10 0.08 0.25 -0.06 -0.02 0.10 0.104 0.896 1.7
##
## ML1 ML3 ML2 ML4 ML5
## SS loadings 1.09 0.85 0.73 0.47 0.40
## Proportion Var 0.11 0.08 0.07 0.05 0.04
## Cumulative Var 0.11 0.19 0.27 0.31 0.35
## Proportion Explained 0.31 0.24 0.21 0.13 0.11
## Cumulative Proportion 0.31 0.55 0.75 0.89 1.00
##
## With factor correlations of
## ML1 ML3 ML2 ML4 ML5
## ML1 1.00 0.30 0.07 0.34 0.28
## ML3 0.30 1.00 0.25 0.27 0.36
## ML2 0.07 0.25 1.00 0.09 0.12
## ML4 0.34 0.27 0.09 1.00 0.30
## ML5 0.28 0.36 0.12 0.30 1.00
##
## Mean item complexity = 1.6
## Test of the hypothesis that 5 factors are sufficient.
##
## The degrees of freedom for the null model are 45 and the objective function was 0.69 with Chi Square of 689.77
## The degrees of freedom for the model are 5 and the objective function was 0
##
## The root mean square of the residuals (RMSR) is 0.01
## The df corrected root mean square of the residuals is 0.02
##
## The harmonic number of observations is 998 with the empirical chi square 5.25 with prob < 0.39
## The total number of observations was 998 with Likelihood Chi Square = 3.99 with prob < 0.55
##
## Tucker Lewis Index of factoring reliability = 1.014
## RMSEA index = 0 and the 90 % confidence intervals are 0 0.039
## BIC = -30.54
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy
## ML1 ML3 ML2 ML4
## Correlation of (regression) scores with factors 1.00 0.78 0.83 0.68
## Multiple R square of scores with factors 0.99 0.61 0.68 0.46
## Minimum correlation of possible factor scores 0.99 0.22 0.36 -0.08
## ML5
## Correlation of (regression) scores with factors 0.62
## Multiple R square of scores with factors 0.39
## Minimum correlation of possible factor scores -0.23
print(ffff5$loadings, cutoff = 0.4)
##
## Loadings:
## ML1 ML3 ML2 ML4 ML5
## K1
## K2 0.999
## K3 0.596
## K4 0.703
## K5 0.440
## K6
## K7
## K8 0.819
## K9
## K10
##
## ML1 ML3 ML2 ML4 ML5
## SS loadings 1.054 0.769 0.715 0.441 0.330
## Proportion Var 0.105 0.077 0.072 0.044 0.033
## Cumulative Var 0.105 0.182 0.254 0.298 0.331
fa.diagram(ffff5, cut = 0, simple = T)
#6
ffff6 <- fa(cdata10, 6, fm = "ml", rotate = "oblimin")
print(ffff6)
## Factor Analysis using method = ml
## Call: fa(r = cdata10, nfactors = 6, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 ML2 ML3 ML5 ML4 ML6 h2 u2 com
## K1 0.29 0.29 -0.01 0.31 -0.07 -0.07 0.416 0.58 3.2
## K2 0.77 -0.03 0.01 -0.02 0.03 0.03 0.586 0.41 1.0
## K3 0.09 0.07 -0.02 0.06 0.47 -0.03 0.287 0.71 1.2
## K4 -0.04 0.69 0.03 -0.03 0.04 0.04 0.478 0.52 1.0
## K5 -0.09 -0.10 0.04 0.45 0.13 0.08 0.209 0.79 1.4
## K6 0.10 0.05 -0.07 0.07 0.20 -0.04 0.077 0.92 2.4
## K7 0.06 0.08 0.26 -0.03 0.21 0.06 0.181 0.82 2.5
## K8 0.01 0.00 0.59 0.00 -0.02 -0.02 0.349 0.65 1.0
## K9 0.05 0.20 0.16 0.17 -0.04 0.13 0.209 0.79 3.9
## K10 0.10 0.09 -0.04 0.04 -0.04 0.42 0.247 0.75 1.3
##
## ML1 ML2 ML3 ML5 ML4 ML6
## SS loadings 0.80 0.73 0.48 0.41 0.37 0.25
## Proportion Var 0.08 0.07 0.05 0.04 0.04 0.03
## Cumulative Var 0.08 0.15 0.20 0.24 0.28 0.30
## Proportion Explained 0.26 0.24 0.16 0.13 0.12 0.08
## Cumulative Proportion 0.26 0.50 0.66 0.80 0.92 1.00
##
## With factor correlations of
## ML1 ML2 ML3 ML5 ML4 ML6
## ML1 1.00 0.40 0.12 0.36 0.30 0.21
## ML2 0.40 1.00 0.33 0.36 0.12 0.35
## ML3 0.12 0.33 1.00 0.13 0.14 0.09
## ML5 0.36 0.36 0.13 1.00 0.16 0.14
## ML4 0.30 0.12 0.14 0.16 1.00 0.14
## ML6 0.21 0.35 0.09 0.14 0.14 1.00
##
## Mean item complexity = 1.9
## Test of the hypothesis that 6 factors are sufficient.
##
## The degrees of freedom for the null model are 45 and the objective function was 0.69 with Chi Square of 689.77
## The degrees of freedom for the model are 0 and the objective function was 0
##
## The root mean square of the residuals (RMSR) is 0
## The df corrected root mean square of the residuals is NA
##
## The harmonic number of observations is 998 with the empirical chi square 0.49 with prob < NA
## The total number of observations was 998 with Likelihood Chi Square = 0.36 with prob < NA
##
## Tucker Lewis Index of factoring reliability = -Inf
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy
## ML1 ML2 ML3 ML5
## Correlation of (regression) scores with factors 0.81 0.77 0.66 0.64
## Multiple R square of scores with factors 0.65 0.60 0.43 0.40
## Minimum correlation of possible factor scores 0.31 0.20 -0.13 -0.19
## ML4 ML6
## Correlation of (regression) scores with factors 0.59 0.54
## Multiple R square of scores with factors 0.35 0.29
## Minimum correlation of possible factor scores -0.30 -0.42
print(ffff6$loadings, cutoff = 0.4)
##
## Loadings:
## ML1 ML2 ML3 ML5 ML4 ML6
## K1
## K2 0.765
## K3 0.473
## K4 0.685
## K5 0.452
## K6
## K7
## K8 0.592
## K9
## K10 0.424
##
## ML1 ML2 ML3 ML5 ML4 ML6
## SS loadings 0.714 0.626 0.454 0.343 0.335 0.217
## Proportion Var 0.071 0.063 0.045 0.034 0.034 0.022
## Cumulative Var 0.071 0.134 0.179 0.214 0.247 0.269
fa.diagram(ffff6, cut = 0, simple = T)