library(psych)
library(tidyverse)
library(haven)
library(nFactors)
library(EGAnet)
library(psychTools)
library(haven)
library(dplyr)
library(tidyr)
library(ggcorrplot)
library(knitr)
#Bu kod baya işlevsel oldu
setwd(dirname(rstudioapi::getActiveDocumentContext()$path))

1 Giriş

Bu derste AFA ve DFA’nın adımlarına değinildi. Öğrenme günlüğünde AFA’nın örnek bir uygulamasına yer verilmiştir.

2 Veri Setini Yükle

# Veri setini yükle
data <- read_sav("D:/doktora/OLC733/hafta09/ASGTURR5.sav")
data <- data %>%
  select(starts_with("ASBR01")) %>% na.omit()

3 Korelasyon Matrisi

pmat <- cor_pmat(data)
cormat <- cor(data)
ggcorrplot(cormat)

4 KMO

round(psych::KMO(data)$MSA,2)
## [1] 0.85
psych::KMO(data)
## Kaiser-Meyer-Olkin factor adequacy
## Call: psych::KMO(r = data)
## Overall MSA =  0.85
## MSA for each item = 
## ASBR01A ASBR01B ASBR01C ASBR01D ASBR01E ASBR01F ASBR01G ASBR01H ASBR01I 
##    0.84    0.83    0.82    0.87    0.85    0.86    0.86    0.86    0.87

KMO değeri 0.85’dır. Değişken bazında KMO değerleri 0.82-0.87 arasında değişmektedir.

5 Bartlett Testi

psych::cortest.bartlett(data)
## R was not square, finding R from data
## $chisq
## [1] 7092.084
## 
## $p.value
## [1] 0
## 
## $df
## [1] 36

KMO değeri 0.6’dan büyük olması veri setinin faktör analizi için uygun olduğunu ve Bartlett Testi ise korelasyon matrisinin birim matristen farklılaştığına işaret eder. Bu nedenle veri seti açımlayıcı faktör analizi için uygundur.

6 Özdeğerler

eigen(cormat)$values
## [1] 2.9666326 0.9964183 0.8962892 0.8110252 0.7227678 0.7034246 0.6428716
## [8] 0.6371380 0.6234328

1’den büyük özdeğer sayısı 1’dir. Bu nedenle 1 faktörlü bir model oluşturulabilir. Ancak 2. ve 3. özdeğerin büyüklüğü 1’e çok yakın olduğu için 2 ve 3 faktörlü modeller de oluşturulabilir. Bu nedenle 1, 2 ve 3 faktörlü modeller karşılaştırılacaktır.

7 Scree Plot

psych::scree(cormat, main = "Scree Plot", factors = FALSE)

8 Paralel Analiz

psych::fa.parallel(data, n.iter = 100, main = "Paralel Analiz", fa = "fa", show.legend = TRUE)

## Parallel analysis suggests that the number of factors =  4  and the number of components =  NA

PA ise 4 faktörlü bir yapı öneriyor.

9 AFA

library(psych)
out1 <- fa(data, nfactors = 1,fm = "pa", cor = "poly")
out2 <- fa(data, nfactors = 2,fm = "pa",rotate = "oblimin", cor = "poly")
out3 <- fa(data, nfactors = 3,fm = "pa", rotate = "oblimin", cor = "poly")
out1
## Factor Analysis using method =  pa
## Call: fa(r = data, nfactors = 1, fm = "pa", cor = "poly")
## Standardized loadings (pattern matrix) based upon correlation matrix
##          PA1   h2   u2 com
## ASBR01A 0.58 0.33 0.67   1
## ASBR01B 0.52 0.27 0.73   1
## ASBR01C 0.51 0.26 0.74   1
## ASBR01D 0.57 0.32 0.68   1
## ASBR01E 0.72 0.52 0.48   1
## ASBR01F 0.72 0.52 0.48   1
## ASBR01G 0.72 0.51 0.49   1
## ASBR01H 0.68 0.47 0.53   1
## ASBR01I 0.66 0.44 0.56   1
## 
##                 PA1
## SS loadings    3.64
## Proportion Var 0.40
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## df null model =  36  with the objective function =  2.93 with Chi Square =  16264.57
## df of  the model are 27  and the objective function was  0.16 
## 
## 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 n.obs is  5560 with the empirical chi square  679.64  with prob <  6.9e-126 
## The total n.obs was  5560  with Likelihood Chi Square =  861.26  with prob <  4.8e-164 
## 
## Tucker Lewis Index of factoring reliability =  0.931
## RMSEA index =  0.075  and the 90 % confidence intervals are  0.07 0.079
## BIC =  628.43
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy             
##                                                    PA1
## Correlation of (regression) scores with factors   0.93
## Multiple R square of scores with factors          0.87
## Minimum correlation of possible factor scores     0.73
out2
## Factor Analysis using method =  pa
## Call: fa(r = data, nfactors = 2, rotate = "oblimin", fm = "pa", cor = "poly")
## Standardized loadings (pattern matrix) based upon correlation matrix
##          PA1   PA2   h2   u2 com
## ASBR01A 0.66 -0.20 0.41 0.59 1.2
## ASBR01B 0.45  0.23 0.30 0.70 1.5
## ASBR01C 0.40  0.39 0.38 0.62 2.0
## ASBR01D 0.55  0.06 0.32 0.68 1.0
## ASBR01E 0.81 -0.20 0.62 0.38 1.1
## ASBR01F 0.67  0.17 0.52 0.48 1.1
## ASBR01G 0.70  0.07 0.51 0.49 1.0
## ASBR01H 0.64  0.13 0.46 0.54 1.1
## ASBR01I 0.63  0.10 0.43 0.57 1.1
## 
##                        PA1  PA2
## SS loadings           3.55 0.42
## Proportion Var        0.39 0.05
## Cumulative Var        0.39 0.44
## Proportion Explained  0.89 0.11
## Cumulative Proportion 0.89 1.00
## 
##  With factor correlations of 
##      PA1  PA2
## PA1 1.00 0.22
## PA2 0.22 1.00
## 
## Mean item complexity =  1.2
## Test of the hypothesis that 2 factors are sufficient.
## 
## df null model =  36  with the objective function =  2.93 with Chi Square =  16264.57
## df of  the model are 19  and the objective function was  0.09 
## 
## 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 n.obs is  5560 with the empirical chi square  348.57  with prob <  2e-62 
## The total n.obs was  5560  with Likelihood Chi Square =  485.8  with prob <  5.3e-91 
## 
## Tucker Lewis Index of factoring reliability =  0.945
## RMSEA index =  0.066  and the 90 % confidence intervals are  0.061 0.072
## BIC =  321.96
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy             
##                                                    PA1   PA2
## Correlation of (regression) scores with factors   0.93  0.63
## Multiple R square of scores with factors          0.87  0.40
## Minimum correlation of possible factor scores     0.75 -0.20
out3
## Factor Analysis using method =  pa
## Call: fa(r = data, nfactors = 3, rotate = "oblimin", fm = "pa", cor = "poly")
## Standardized loadings (pattern matrix) based upon correlation matrix
##           PA1   PA3   PA2   h2   u2 com
## ASBR01A -0.02  0.78  0.01 0.60 0.40 1.0
## ASBR01B  0.19  0.14  0.31 0.29 0.71 2.2
## ASBR01C  0.00 -0.01  0.82 0.66 0.34 1.0
## ASBR01D  0.26  0.23  0.18 0.32 0.68 2.8
## ASBR01E  0.40  0.42  0.00 0.57 0.43 2.0
## ASBR01F  0.61  0.06  0.11 0.52 0.48 1.1
## ASBR01G  0.66  0.08  0.02 0.53 0.47 1.0
## ASBR01H  0.79 -0.07 -0.03 0.53 0.47 1.0
## ASBR01I  0.67 -0.01  0.02 0.46 0.54 1.0
## 
##                        PA1  PA3  PA2
## SS loadings           2.44 1.09 0.95
## Proportion Var        0.27 0.12 0.11
## Cumulative Var        0.27 0.39 0.50
## Proportion Explained  0.54 0.24 0.21
## Cumulative Proportion 0.54 0.79 1.00
## 
##  With factor correlations of 
##      PA1  PA3  PA2
## PA1 1.00 0.68 0.59
## PA3 0.68 1.00 0.38
## PA2 0.59 0.38 1.00
## 
## Mean item complexity =  1.4
## Test of the hypothesis that 3 factors are sufficient.
## 
## df null model =  36  with the objective function =  2.93 with Chi Square =  16264.57
## df of  the model are 12  and the objective function was  0.02 
## 
## 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 n.obs is  5560 with the empirical chi square  87.4  with prob <  1.6e-13 
## The total n.obs was  5560  with Likelihood Chi Square =  136.74  with prob <  2.7e-23 
## 
## Tucker Lewis Index of factoring reliability =  0.977
## RMSEA index =  0.043  and the 90 % confidence intervals are  0.037 0.05
## BIC =  33.26
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    PA1  PA3  PA2
## Correlation of (regression) scores with factors   0.92 0.86 0.85
## Multiple R square of scores with factors          0.85 0.74 0.73
## Minimum correlation of possible factor scores     0.70 0.48 0.45

Principal Axis yöntemi ve çok boyutlu yapılar için Oblimin rotasyonu kullanılarak yapılan AFA sonucunda elde edilen çıktılar şu şekildedir:

data.frame(
  Model = c("F1","F2","F3"),
  AVO = c(out1$Vaccounted[2,],
           sum(out2$Vaccounted[2,]),
           sum(out3$Vaccounted[2,]))) %>% kable(.,digits = 2)
Model AVO
F1 0.40
F2 0.44
F3 0.50

Uygun faktör sayısı, faktör sayısı belirleme yöntemleri, açıklanan varyans oranı ve hipotetik yapı karşılaştırılarak belirlenebilir. Bu aşamada tek faktörlü model sunum kolaylığı açısından raporlanmıştır.

10 Maddelerin Faktör Yükleri, Ortaklıkları ve Özgül Varyans Değerleri

data.frame(
  Maddeler = rownames(out1$loadings),
  FY = out1$loadings[,1],
  COM = out1$communality,
  UNI = out1$uniquenesses, 
  COMPLEX = out1$complexity,
  row.names = NULL
) %>% kable(., digits = 2)
Maddeler FY COM UNI COMPLEX
ASBR01A 0.58 0.33 0.67 1
ASBR01B 0.52 0.27 0.73 1
ASBR01C 0.51 0.26 0.74 1
ASBR01D 0.57 0.32 0.68 1
ASBR01E 0.72 0.52 0.48 1
ASBR01F 0.72 0.52 0.48 1
ASBR01G 0.72 0.51 0.49 1
ASBR01H 0.68 0.47 0.53 1
ASBR01I 0.66 0.44 0.56 1

Madde faktör yüklerinin 0.51-0.72 arasında değiştiği ve orta-yüksek faktör yüklerine karşılık geldiği söylenebilir.

11 Model Veri Uyumu İndeksleri

out1$RMSEA
##      RMSEA      lower      upper confidence 
## 0.07454719 0.07031862 0.07887595 0.90000000
out1$TLI
## [1] 0.9314489
out1$CFI
## [1] 0.9485929
out1$BIC
## [1] 628.4338
out1$chi
## [1] 679.6436

Model veri uyumu indeksleri değerlendirildiğinde RMSEA, CFI ve TLI değerlerinin kabul edilebilir uyuma işaret ettiği söylenebilir.

12 Faktör Skorlarının Yeterliliği

data.frame(
  factor_cor = c(0.93),
  R_square = 0.87,
  min_cor = 0.73) %>% kable()
factor_cor R_square min_cor
0.93 0.87 0.73

Bu değerler tek faktörün güvenilir faktör skorlar ürettiğini ve analizlerde kullanılabilir olacağına işaret eder.

13 EGA

library(EGAnet)
uva_data <- UVA(data = data)
uva_data
## Variable pairs with wTO > 0.30 (large-to-very large redundancy)
## 
## ----
## 
## Variable pairs with wTO > 0.25 (moderate-to-large redundancy)
## 
## ----
## 
## Variable pairs with wTO > 0.20 (small-to-moderate redundancy)
## 
##   node_i  node_j   wto
##  ASBR01A ASBR01E 0.244

Unique Variable Analysis (UVA) sonucunda ilgisiz/alakasız bir düğüm bulunmamıştır (<0.25). Bu bağlamda değişken atılmadan analizler devam edecektir.

EGA(data=data,
    corr = "auto",
    model = "glasso",
    algorithm = "louvain",
    consensus.method = "highest_modularity",
    uni.method = "louvain",
    consensus.iter = 1000)

## Model: GLASSO (EBIC with gamma = 0.5)
## Correlations: auto
## Lambda: 0.0531858630786678 (n = 100, ratio = 0.1)
## 
## Number of nodes: 9
## Number of edges: 32
## Edge density: 0.889
## 
## Non-zero edge weights: 
##      M    SD   Min   Max
##  0.112 0.063 0.007 0.292
## 
## ----
## 
## Algorithm:  Louvain
## 
## Number of communities:  1
## 
## ASBR01A ASBR01B ASBR01C ASBR01D ASBR01E ASBR01F ASBR01G ASBR01H ASBR01I 
##       1       1       1       1       1       1       1       1       1 
## 
## ----
## 
## Unidimensional Method: Louvain
## Unidimensional: Yes
## 
## ----
## 
## TEFI: 0

EGA-GLASSO sonucunda AFA’da kestirilen tek faktörlü yapı doğrulanmıştır.

Sonuç olarak EGA boyut sayısını belirlemek için faktör sayısı belirleme yöntemlerine bir alternatif olabilir. Ancak yöntemlerin sınırlılıkları temel aldıkları matematiksel ilişkilere dayanmaktadır.