0.1 Analisis Faktor

Dalam analisis faktor kita melihat faktor-faktor dalam statsitik. Dalam ilmu statistik kalau kita melihat bahwa ada pengaruh dalam suatu faktor. maka kalau kita bandingkan dengan beberapa faktor maka kita kan melihat faktor yang mempegaruhinya. Tujuan dari Analisis faktor adalah beberapa hal yang ada di bawah ini: 1. Menyederhanakan bentuk faktor. ada dugaan banyak sekali faktor yang berhubungan maka dengan mencari yang lebih penting akan membuat faktor tersebut lebih penting. 2. Mengelompokkan variabel. Ada faktor yang mungkin akan bisa mengelompokkan ke dalam kelompok 3. Identifikasi struktur menjelaskan hubungan antara beberapa variabel.

Untuk memahami contoh dalam analisis faktor ini kita akan menggunakan data atau set data yang bernama Swiss. Ini sudah ada di Rstudio dan kita tinggal menampilkan saja data ini. Langkah-langkahnya adalah seperti ini.

data("swiss")
head(swiss)
##              Fertility Agriculture Examination
## Courtelary        80.2        17.0          15
## Delemont          83.1        45.1           6
## Franches-Mnt      92.5        39.7           5
## Moutier           85.8        36.5          12
## Neuveville        76.9        43.5          17
## Porrentruy        76.1        35.3           9
##              Education Catholic Infant.Mortality
## Courtelary          12     9.96             22.2
## Delemont             9    84.84             22.2
## Franches-Mnt         5    93.40             20.2
## Moutier              7    33.77             20.3
## Neuveville          15     5.16             20.6
## Porrentruy           7    90.57             26.6
str(swiss)
## 'data.frame':    47 obs. of  6 variables:
##  $ Fertility       : num  80.2 83.1 92.5 85.8 76.9 76.1 83.8 92.4 82.4 82.9 ...
##  $ Agriculture     : num  17 45.1 39.7 36.5 43.5 35.3 70.2 67.8 53.3 45.2 ...
##  $ Examination     : int  15 6 5 12 17 9 16 14 12 16 ...
##  $ Education       : int  12 9 5 7 15 7 7 8 7 13 ...
##  $ Catholic        : num  9.96 84.84 93.4 33.77 5.16 ...
##  $ Infant.Mortality: num  22.2 22.2 20.2 20.3 20.6 26.6 23.6 24.9 21 24.4 ...
# Memilih variabel untuk analisis faktor
swiss_subset <- swiss[, c("Fertility", "Agriculture", "Examination", "Education")]

0.2 Langkah Utama

Pada dasarnya kita bisa melakukan beberapa hal dalam analisis faktor seperti :

  1. Ekstaksi Faktor : MEnemukan faktor dari beberapa faktor atau mengesktraknya

  2. Rotasi FAktor: Dengan menggunakan VArimax atau oblimin untuk mempermudah interrestasi faktor

  3. Interprestasi faktor menentukan nama atau makna faktor yang memili loading tinggi

Kemudian kita memeriksa kelengkapan data. setelah melakukan standarisasi data

# Memeriksa data yang hilang
summary(swiss_subset)
##    Fertility      Agriculture     Examination   
##  Min.   :35.00   Min.   : 1.20   Min.   : 3.00  
##  1st Qu.:64.70   1st Qu.:35.90   1st Qu.:12.00  
##  Median :70.40   Median :54.10   Median :16.00  
##  Mean   :70.14   Mean   :50.66   Mean   :16.49  
##  3rd Qu.:78.45   3rd Qu.:67.65   3rd Qu.:22.00  
##  Max.   :92.50   Max.   :89.70   Max.   :37.00  
##    Education    
##  Min.   : 1.00  
##  1st Qu.: 6.00  
##  Median : 8.00  
##  Mean   :10.98  
##  3rd Qu.:12.00  
##  Max.   :53.00
# Standarisasi data
swiss_standardized <- scale(swiss_subset)
summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

0.3 Analisis Faktor FA

Melakukan analisis faktor FA dan menggunakan rotasi Varimax

library(psych)
## Warning: package 'psych' was built under R version
## 4.3.2
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
factor_analysis <- fa(swiss_standardized, nfactors = 2, rotate = "varimax")

Setelah itu kita bisa menampilkan hasil analisis seperti dibawah ini Hasilnya menunjukkan dari struktur tersebut Variabel Fertility dan Agriculture cenderung berkorelasi positif dengan faktor 1, sementara variabel Examination dan Education cenderung berkorelasi positif dengan faktor 2.

# Tampilkan hasil analisis faktor
print(factor_analysis)
## Factor Analysis using method =  minres
## Call: fa(r = swiss_standardized, nfactors = 2, rotate = "varimax")
## Standardized loadings (pattern matrix) based upon correlation matrix
##               MR1   MR2   h2   u2 com
## Fertility   -0.19 -0.92 0.88 0.12 1.1
## Agriculture -0.93 -0.19 0.90 0.10 1.1
## Examination  0.62  0.57 0.72 0.28 2.0
## Education    0.57  0.60 0.69 0.31 2.0
## 
##                       MR1  MR2
## SS loadings           1.6 1.58
## Proportion Var        0.4 0.39
## Cumulative Var        0.4 0.79
## Proportion Explained  0.5 0.50
## Cumulative Proportion 0.5 1.00
## 
## Mean item complexity =  1.5
## Test of the hypothesis that 2 factors are sufficient.
## 
## df null model =  6  with the objective function =  2.22 with Chi Square =  97.29
## df of  the model are -1  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 n.obs is  47 with the empirical chi square  0  with prob <  NA 
## The total n.obs was  47  with Likelihood Chi Square =  0  with prob <  NA 
## 
## Tucker Lewis Index of factoring reliability =  1.068
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    MR1
## Correlation of (regression) scores with factors   0.94
## Multiple R square of scores with factors          0.89
## Minimum correlation of possible factor scores     0.78
##                                                    MR2
## 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
# Tampilkan loadings faktor
print(factor_analysis$loadings)
## 
## Loadings:
##             MR1    MR2   
## Fertility   -0.191 -0.919
## Agriculture -0.927 -0.191
## Examination  0.623  0.573
## Education    0.565  0.605
## 
##                  MR1   MR2
## SS loadings    1.602 1.575
## Proportion Var 0.401 0.394
## Cumulative Var 0.401 0.794
# Plot scree plot
plot(factor_analysis$values, type = "b", 
     main = "Scree Plot", xlab = "Factor", ylab = "Eigenvalue", col = "red")