Beberapa tahun terakhir, gaya hidup sehat menjadi perhatian utama bagi banyak kota di dunia. Masyarakat mulai menyadari akan pentingnya kesejahteraan fisik dan mental. Diperlukan pembiasaan penerapan gaya hidup yang sehat sejak dini agar di masa tua nanti badan tetap bugar dan terhindar dari penyakit. Gaya hidup perkotaan seringkali dikaitkan dengan berbagai tantangan kesehatan seperti peningkatan polusi, tingkat obesitas yang tinggi, serta kualitas hidup yang menurun.Berbagai kota di dunia menawarkan pengalaman hidup yang berbeda-beda. Hal ini menjadikan topik mengenai perbedaan aspek gaya hidup di berbagai kota menarik untuk dianalisis lebih lanjut.
Penelitian ini menggunakan dataset Healthy Lifestyle Cities Report 2021, yang menyajikan metrik gaya hidup sehat di 44 kota teratas di dunia. Dataset ini mencakup berbagai variabel yang mempengaruhi kualitas hidup dan kesehatan masyarakat, seperti jumlah jam sinar matahari, biaya air minum, tingkat obesitas, harapan hidup, tingkat polusi, tingkat kebahagiaan, aktivitas luar ruangan, jumlah tempat makan siap saji, dan biaya keanggotaan bulanan di pusat kebugaran.Untuk mempermudah dalam memperoleh gambaran mengenai faktor utama yang mendasari gaya hidup sehat, diperlukan analisis yang mampu menyederhanakan sejumlah besar variabel ini menjadi beberapa faktor utama yang lebih representatif. Dengan menggunakan analisis faktor, diharapkan hasilnya dapat memberikan informasi mengenai aspek-aspek utama yang mempengaruhi gaya hidup sehat di berbagai kota dan membantu pembuat kebijakan merancang langkah-langkah yang lebih efektif untuk meningkatkan kualitas hidup masyarakat perkotaan.
Analisis faktor adalah kajian tentang saling ketergantungan antara variabel variabel, dengan tujuan untuk menemukan himpunan variabel-variabel baru, yang lebih sedikit jumlahnya dari pada variabel semula, dan yang menunjukkan yang mana di antara variabel-variabel semula itu yang merupakan faktor-faktor persekutuan (Suryanto, 1988:234). Analisis Faktor bertujuan untuk mengidentifikasi struktur tersembunyi dalam sekumpulan variabel observasi dan menguranginya menjadi beberapa faktor atau komponen yang mewakili variabilitas data secara signifikan.
Terdapat dua jenis Analisis Faktor. Pertama Exploratory Factor Analysis (EFA), yang digunakan ketika peneliti memiliki tujuan untuk mengidentifikasi struktur dasar dari suatu set variabel tanpa adanya hipotesis awal. EFA membantu mengelompokkan variabel berdasarkan korelasi mereka dan mengidentifikasi faktor-faktor potensial yang mendasari data. Jenis Analisis Faktor lain adalah Confirmatory Factor Analysis (CFA) yang digunakan ketika ada hipotesis atau model awal tentang struktur faktor data. CFA memungkinkan peneliti untuk menguji apakah data cocok dengan model faktor yang telah ditentukan sebelumnya.
Tujuan Analisis Faktor Analisis faktor bertujuan untuk menjelaskan hubungan dari sekian banyak faktor terhadap variabel yang diteliti. Selain itu, analisis faktor juga memiliki tujuan lain seperti: 1. Mengeleminasi faktor-faktor atau variabel-variabel lama yang banyak menjadi faktor-faktor baru yang lebih sedikit. 2. Mengidentifikasi hubungan antar variabel dengan faktor yang terbentuk menggunakan pengujian koefisien korelasi antar faktor. Jenis ini juga disebut analisis faktor konfirmatori. 3. Menguji validitas dan reliabilitas dengan analisis faktor konfirmatori. 4. Validasi data digunakan untuk mengetahui apakah hasil analisis bisa digeneralisasi ke dalam populasi guna mengetahui hipotesis yang dihasilkan.
Adapun tujuan dari penelitian ini adalah: 1. Mengetahui faktor-faktor yang mempengaruhi gaya hidup sehat masyarakat di lingkungan perkotaan tahun 2021. 2.Mengetahui faktor yang paling berpengaruh terhadap gaya hidup sehat masyarakat di lingkungan perkotaan tahun 2021.
Secara matematis model analisis faktor ditulis sebagai berikut (Johnson, 2007:482): \[ X_{(𝒑×1)}-\mu_{(𝒑×1)} = L_{(𝒑×m)}F_{(m×1)} +\epsilon_{(𝒑×1)} \] Dimana: L : matriks factor loading. 𝑿𝟏 : vektor acak yang memiliki 𝑝 komponen pada amatan ke-𝑖 𝝁𝒊 : rataan dari variabel ke-𝑖 𝑭𝒋 : faktor bersama (common factor) yang ke ke-𝑗 atau disebut disebut faktor-faktor umum 𝛆𝐢 : sisaan atau error dari variabel ke-𝑖 (spesific factor) atau disebut faktor khusus
Asumsi yang harus dipenuhi: \[ E(F)=0_{(m×n)}, Cov(F)=E[EF']=I_{m×m} \] \[ E(\epsilon)=0_{(p×1)}, Cov(\epsilon)=E[\epsilon\epsilon']=ψ_{(p×p)} \] \[ Cov(\epsilon, F) = E(\epsilon, F)=0_{(p×m)} \] ## Data Data yang digunakan diambil dari kaggle.com dengan judul “Healthy Lifestyle Cities Report 2021”. Dataset tersebut terdiri atas variabel-variabel yang mempengaruhi gaya hidup sehat masyarakat di 44 kota pada tahun 2021. Berikut data penelitian yang digunakan.
| Sunshine hours(City) | Cost of a bottle of water(City) | Obesity levels(Country) (£) | Life expectancy(years) (Country) | Pollution(Index score) (City) | Happiness levels(Country) | Outdoor activities(City) | Number of take out places(City) | Cost of a monthly gym membership(City) (£) |
|---|---|---|---|---|---|---|---|---|
| 1858.00 | 1.92 | 0.204 | 81.2 | 30.93000 | 7.44 | 422 | 1048 | 34.90 |
| 2636.00 | 1.48 | 0.290 | 82.1 | 26.86000 | 7.22 | 406 | 1103 | 41.66 |
| 1884.00 | 1.94 | 0.201 | 81.0 | 17.33000 | 7.29 | 132 | 1008 | 25.74 |
| 1821.00 | 1.72 | 0.206 | 81.8 | 19.63000 | 7.35 | 129 | 598 | 37.31 |
| 1630.00 | 2.19 | 0.197 | 79.8 | 21.24000 | 7.64 | 154 | 523 | 32.53 |
| 1662.00 | 1.60 | 0.222 | 80.4 | 13.08000 | 7.80 | 113 | 309 | 35.23 |
| 2769.00 | 0.78 | 0.043 | 83.2 | 51.12233 | 5.87 | 35 | 539 | 55.87 |
| 1626.00 | 1.55 | 0.223 | 80.6 | 39.41000 | 7.07 | 254 | 1729 | 26.11 |
| 2591.00 | 1.19 | 0.238 | 82.2 | 65.19000 | 6.40 | 585 | 2344 | 37.80 |
| 1938.00 | 1.08 | 0.294 | 81.7 | 24.26000 | 7.23 | 218 | 788 | 31.04 |
| 2363.00 | 1.57 | 0.290 | 82.1 | 25.90000 | 7.22 | 243 | 813 | 36.89 |
| 2671.00 | 0.26 | 0.062 | 75.4 | 85.43000 | 5.12 | 223 | 261 | 38.62 |
| 2624.00 | 0.22 | 0.100 | 74.1 | 76.64000 | 5.99 | 377 | 1796 | 50.03 |
| 2525.00 | 0.57 | 0.283 | 75.9 | 52.64000 | 5.97 | 246 | 1435 | 22.45 |
| 2066.00 | 1.09 | 0.294 | 81.7 | 37.83000 | 7.23 | 174 | 1656 | 32.64 |
| 2769.00 | 1.30 | 0.238 | 82.2 | 52.68000 | 6.40 | 216 | 2491 | 34.54 |
| 2983.00 | 0.21 | 0.069 | 68.5 | 84.39000 | 5.28 | 114 | 833 | 29.94 |
| 2066.00 | 0.59 | 0.047 | 81.3 | 57.82000 | 5.87 | 144 | 389 | 43.03 |
| 1662.00 | 1.95 | 0.223 | 80.6 | 37.78000 | 7.07 | 23 | 551 | 39.01 |
| 2245.86 | 2.62 | 0.195 | 82.6 | 27.25000 | 7.56 | 44 | 444 | 70.00 |
| 3311.00 | 1.63 | 0.261 | 81.9 | 47.28000 | 7.12 | 139 | 420 | 58.31 |
| 2218.00 | 0.15 | 0.321 | 74.7 | 69.49000 | 5.13 | 419 | 934 | 16.97 |
| 3542.00 | 0.16 | 0.320 | 70.7 | 91.74000 | 4.15 | 323 | 250 | 23.25 |
| 1405.00 | 0.57 | 0.062 | 75.4 | 49.32000 | 5.12 | 134 | 717 | 34.76 |
| 3254.00 | 1.52 | 0.362 | 78.8 | 66.07000 | 6.94 | 223 | 1439 | 32.00 |
| 2584.00 | 0.15 | 0.039 | 67.3 | 82.84000 | 3.57 | 187 | 1183 | 19.54 |
| 2634.00 | 1.39 | 0.362 | 78.8 | 27.03000 | 6.94 | 88 | 588 | 46.27 |
| 1453.00 | 1.40 | 0.253 | 80.5 | 40.07000 | 7.09 | 159 | 659 | 37.35 |
| 1877.00 | 0.76 | 0.043 | 83.2 | 42.84000 | 5.87 | 387 | 5802 | 70.82 |
| 2508.00 | 1.20 | 0.362 | 78.8 | 43.33000 | 6.94 | 171 | 1320 | 41.14 |
| 1836.00 | 0.75 | 0.062 | 75.4 | 67.46000 | 5.51 | 277 | 1257 | 57.95 |
| 1776.00 | 0.29 | 0.062 | 75.4 | 77.40000 | 5.12 | 108 | 346 | 44.68 |
| 1546.00 | 2.11 | 0.221 | 80.4 | 62.67000 | 6.86 | 55 | 988 | 25.34 |
| 3062.00 | 1.60 | 0.362 | 78.8 | 47.36000 | 6.94 | 242 | 1031 | 65.13 |
| 1662.00 | 1.95 | 0.216 | 81.8 | 65.10000 | 6.66 | 331 | 4363 | 35.93 |
| 2003.00 | 0.44 | 0.221 | 73.9 | 79.78000 | 6.37 | 158 | 3355 | 16.07 |
| 1566.00 | 3.20 | 0.195 | 82.6 | 17.31000 | 7.56 | 69 | 538 | 73.11 |
| 1633.00 | 1.16 | 0.278 | 80.4 | 58.91000 | 7.16 | 433 | 6417 | 42.71 |
| 3124.00 | 0.59 | 0.283 | 56.3 | 61.83000 | 4.81 | 194 | 492 | 24.28 |
| 1915.00 | 1.15 | 0.199 | 82.7 | 67.19000 | 6.38 | 110 | 2396 | 53.49 |
| 2528.00 | 1.45 | 0.362 | 78.8 | 39.18000 | 6.94 | 83 | 744 | 65.99 |
| 2535.00 | 1.32 | 0.362 | 78.8 | 57.36000 | 6.94 | 359 | 3081 | 64.66 |
| 1901.00 | 0.41 | 0.231 | 69.5 | 57.63000 | 5.54 | 322 | 3206 | 31.40 |
| 2555.00 | 0.45 | 0.289 | 76.4 | 82.78000 | 6.46 | 192 | 1313 | 41.99 |
> library(readxl) #Import data format excel
> library(corrplot) #Plot Korelasi
> library(REdaS) #KMO dan Bartlett`s Test
> library(psych) #Analisis faktor
> library(readxl)
> healthy_lifestyle <- read_excel("E:/1Firdha/healthy_lifestyle.xlsx")
> str(healthy_lifestyle)
tibble [44 × 9] (S3: tbl_df/tbl/data.frame)
$ Sunshine hours(City) : num [1:44] 1858 2636 1884 1821 1630 ...
$ Cost of a bottle of water(City) : num [1:44] 1.92 1.48 1.94 1.72 2.19 1.6 0.78 1.55 1.19 1.08 ...
$ Obesity levels(Country) (£) : num [1:44] 0.204 0.29 0.201 0.206 0.197 0.222 0.043 0.223 0.238 0.294 ...
$ Life expectancy(years) (Country) : num [1:44] 81.2 82.1 81 81.8 79.8 80.4 83.2 80.6 82.2 81.7 ...
$ Pollution(Index score) (City) : num [1:44] 30.9 26.9 17.3 19.6 21.2 ...
$ Happiness levels(Country) : num [1:44] 7.44 7.22 7.29 7.35 7.64 7.8 5.87 7.07 6.4 7.23 ...
$ Outdoor activities(City) : num [1:44] 422 406 132 129 154 113 35 254 585 218 ...
$ Number of take out places(City) : num [1:44] 1048 1103 1008 598 523 ...
$ Cost of a monthly gym membership(City) (£): num [1:44] 34.9 41.7 25.7 37.3 32.5 ...
Terdapat 44 data dengan 9 variabel yang memiliki tipe data numerik.
> summary(healthy_lifestyle)
Sunshine hours(City) Cost of a bottle of water(City)
Min. :1405 Min. :0.150
1st Qu.:1810 1st Qu.:0.570
Median :2142 Median :1.195
Mean :2246 Mean :1.173
3rd Qu.:2626 3rd Qu.:1.600
Max. :3542 Max. :3.200
Obesity levels(Country) (£) Life expectancy(years) (Country)
Min. :0.0390 Min. :56.30
1st Qu.:0.1950 1st Qu.:75.40
Median :0.2230 Median :80.40
Mean :0.2192 Mean :78.17
3rd Qu.:0.2900 3rd Qu.:81.80
Max. :0.3620 Max. :83.20
Pollution(Index score) (City) Happiness levels(Country)
Min. :13.08 Min. :3.570
1st Qu.:36.07 1st Qu.:5.870
Median :51.88 Median :6.900
Mean :51.12 Mean :6.435
3rd Qu.:66.35 3rd Qu.:7.175
Max. :91.74 Max. :7.800
Outdoor activities(City) Number of take out places(City)
Min. : 23.0 Min. : 250
1st Qu.:125.2 1st Qu.: 548
Median :189.5 Median : 998
Mean :214.0 Mean :1443
3rd Qu.:288.2 3rd Qu.:1674
Max. :585.0 Max. :6417
Cost of a monthly gym membership(City) (£)
Min. :16.07
1st Qu.:31.31
Median :37.33
Mean :40.42
3rd Qu.:47.21
Max. :73.11
Fungsi summary() digunakan untuk menampilkan statistika
deskriptif dari data (healthy_lifestyle).
> korelasi <- cor(healthy_lifestyle)
> print(korelasi)
Sunshine hours(City)
Sunshine hours(City) 1.00000000
Cost of a bottle of water(City) -0.33123908
Obesity levels(Country) (£) 0.28111462
Life expectancy(years) (Country) -0.35338765
Pollution(Index score) (City) 0.38346569
Happiness levels(Country) -0.32897948
Outdoor activities(City) 0.12676733
Number of take out places(City) -0.21053912
Cost of a monthly gym membership(City) (£) 0.02924382
Cost of a bottle of water(City)
Sunshine hours(City) -0.33123908
Cost of a bottle of water(City) 1.00000000
Obesity levels(Country) (£) 0.29304736
Life expectancy(years) (Country) 0.61238234
Pollution(Index score) (City) -0.73265904
Happiness levels(Country) 0.81315927
Outdoor activities(City) -0.26029684
Number of take out places(City) -0.08996306
Cost of a monthly gym membership(City) (£) 0.35646062
Obesity levels(Country) (£)
Sunshine hours(City) 0.28111462
Cost of a bottle of water(City) 0.29304736
Obesity levels(Country) (£) 1.00000000
Life expectancy(years) (Country) 0.09107146
Pollution(Index score) (City) -0.24697162
Happiness levels(Country) 0.44639865
Outdoor activities(City) 0.15017086
Number of take out places(City) 0.01683277
Cost of a monthly gym membership(City) (£) -0.07090413
Life expectancy(years) (Country)
Sunshine hours(City) -0.35338765
Cost of a bottle of water(City) 0.61238234
Obesity levels(Country) (£) 0.09107146
Life expectancy(years) (Country) 1.00000000
Pollution(Index score) (City) -0.55271478
Happiness levels(Country) 0.72458708
Outdoor activities(City) -0.04486383
Number of take out places(City) 0.12816279
Cost of a monthly gym membership(City) (£) 0.41798576
Pollution(Index score) (City)
Sunshine hours(City) 0.3834657
Cost of a bottle of water(City) -0.7326590
Obesity levels(Country) (£) -0.2469716
Life expectancy(years) (Country) -0.5527148
Pollution(Index score) (City) 1.0000000
Happiness levels(Country) -0.7629349
Outdoor activities(City) 0.2368367
Number of take out places(City) 0.1862806
Cost of a monthly gym membership(City) (£) -0.2417568
Happiness levels(Country)
Sunshine hours(City) -0.32897948
Cost of a bottle of water(City) 0.81315927
Obesity levels(Country) (£) 0.44639865
Life expectancy(years) (Country) 0.72458708
Pollution(Index score) (City) -0.76293487
Happiness levels(Country) 1.00000000
Outdoor activities(City) -0.13761226
Number of take out places(City) 0.03311558
Cost of a monthly gym membership(City) (£) 0.29742503
Outdoor activities(City)
Sunshine hours(City) 0.12676733
Cost of a bottle of water(City) -0.26029684
Obesity levels(Country) (£) 0.15017086
Life expectancy(years) (Country) -0.04486383
Pollution(Index score) (City) 0.23683670
Happiness levels(Country) -0.13761226
Outdoor activities(City) 1.00000000
Number of take out places(City) 0.52819990
Cost of a monthly gym membership(City) (£) -0.11540023
Number of take out places(City)
Sunshine hours(City) -0.21053912
Cost of a bottle of water(City) -0.08996306
Obesity levels(Country) (£) 0.01683277
Life expectancy(years) (Country) 0.12816279
Pollution(Index score) (City) 0.18628062
Happiness levels(Country) 0.03311558
Outdoor activities(City) 0.52819990
Number of take out places(City) 1.00000000
Cost of a monthly gym membership(City) (£) 0.09260972
Cost of a monthly gym membership(City) (£)
Sunshine hours(City) 0.02924382
Cost of a bottle of water(City) 0.35646062
Obesity levels(Country) (£) -0.07090413
Life expectancy(years) (Country) 0.41798576
Pollution(Index score) (City) -0.24175676
Happiness levels(Country) 0.29742503
Outdoor activities(City) -0.11540023
Number of take out places(City) 0.09260972
Cost of a monthly gym membership(City) (£) 1.00000000
Fungsi cor() digunakan untuk menghitung korelasi antar
variabel dalam suatu dataset. Kemudian hasil korelasi disimpan dalam
variabel korelasi.
> library(REdaS)
> kmo_result <- KMOS(healthy_lifestyle)
> print(kmo_result)
Kaiser-Meyer-Olkin Statistics
Call: KMOS(x = healthy_lifestyle)
Measures of Sampling Adequacy (MSA):
Sunshine hours(City)
0.4765490
Cost of a bottle of water(City)
0.8687709
Obesity levels(Country) (£)
0.4015657
Life expectancy(years) (Country)
0.7799179
Pollution(Index score) (City)
0.8237615
Happiness levels(Country)
0.7136634
Outdoor activities(City)
0.5353500
Number of take out places(City)
0.3721913
Cost of a monthly gym membership(City) (£)
0.5277982
KMO-Criterion: 0.670467
Uji KMO digunakan untuk mengetahui komponen atau faktor mana saja yang akan dianalisis lanjut dan yang tidak dianalisis lanjut. Nilai KMO harus lebih dari 0.5 agar variabel layak untuk dianalisis ke tahapan selanjutnya.
> library(readxl)
> healthy_lifestyle2 <- read_excel("E:/1Firdha/healthy_lifestyle2.xlsx")
Karena variabel Sunshine hours,
Obesity levels, dan Number of take out places
memiliki nilai MSA < 0.5 maka harus dikeluarkan terlebih dahulu
sebelum dilakukan analisis lebih lanjut.
> library(REdaS)
> bart_spher(healthy_lifestyle2)
Bartlett's Test of Sphericity
Call: bart_spher(x = healthy_lifestyle2)
X2 = 126.571
df = 15
p-value < 2.22e-16
Uji Bartlett digunakan untuk menguji apakah setiap variabel saling independen atau tidak.
Scree plot digunakan untuk menentukan banyaknya faktor yang optimal untuk dipertahankan dalam model, yaitu faktor yang memiliki nilai eigen lebih dari 1. Faktor-faktor tersebut merupakan faktor bermakna yang nantinya akan diekstrak dengan PCA dan PFA.
> eigen = eigen(korelasi)
> eigen
eigen() decomposition
$values
[1] 3.5931491 1.6031401 1.3781225 1.0289855 0.4602604 0.3740913 0.2372168
[8] 0.2164747 0.1085597
$vectors
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 0.23273715 -0.08709175 0.58610475 -0.47036012 0.16147797 -0.16658189
[2,] -0.47496352 -0.05010406 0.06636821 0.01276653 -0.10397522 0.16431178
[3,] -0.15623060 0.16215214 0.73124737 0.16186658 -0.33565242 -0.03036251
[4,] -0.42128069 0.17677131 -0.13659065 -0.15288496 0.36881724 -0.70155775
[5,] 0.45321935 0.10725811 -0.04193501 -0.17026599 -0.24212756 -0.48023399
[6,] -0.48993283 0.09364897 0.15065760 0.08878143 -0.04324779 -0.13472080
[7,] 0.13945894 0.65086860 0.14283472 0.04565937 0.60736633 0.31155211
[8,] 0.02223379 0.69671167 -0.19472172 -0.01928919 -0.51628223 -0.04851605
[9,] -0.23015771 0.05524201 -0.12618315 -0.83047834 -0.13597055 0.32241906
[,7] [,8] [,9]
[1,] -0.183359949 0.53370527 -0.03470111
[2,] -0.811375775 -0.04156367 0.26356047
[3,] 0.282218020 -0.36012618 0.25583759
[4,] 0.137721703 -0.03477799 0.31758063
[5,] -0.391047924 -0.50971501 -0.22441159
[6,] -0.001213919 0.05805311 -0.83499948
[7,] -0.137557818 -0.20983594 -0.07431615
[8,] -0.008384725 0.44509369 0.09343464
[9,] 0.193705430 -0.27786994 -0.03440579
> screeplot = plot(eigen$values, main = "Scree Plot", xlab = "Faktor", ylab = "Eigen Values", pch = 16, type = "o", col = "green", lwd = 1) + axis(1, at = seq(1,9)) + abline(h=1, col = "red")
eigen(): Menghitung nilai eigen (eigenvalues) dan vektor
eigen (eigenvectors) dari matriks korelasi. eigen$values:
Menyimpan nilai eigen. main = "Scree Plot": Menetapkan
judul grafik menjadi “Scree Plot”. xlab = "Faktor": Label
sumbu x sebagai “Faktor”. ylab = "Eigen Values": Label
sumbu y sebagai “Eigen Values”. pch = 16: Menggunakan
simbol titik penuh untuk setiap nilai eigen. type = "o":
Menghubungkan titik-titik dengan garis. col = "green":
Warna garis hijau. lwd = 1: Menentukan lebar garis.
axis(1, at = seq(1,9)): Menambahkan sumbu x dengan nilai
dari 1 hingga 9. abline(h=1, col = "red"): Menambahkan
garis horizontal pada nilai eigen 1 dengan warna merah.
> PCA = principal(r = korelasi, nfactors = 4, rotate = "varimax")
> PCA$communality
Sunshine hours(City)
0.9078507
Cost of a bottle of water(City)
0.8208423
Obesity levels(Country) (£)
0.8937271
Life expectancy(years) (Country)
0.7375609
Pollution(Index score) (City)
0.7887581
Happiness levels(Country)
0.9159292
Outdoor activities(City)
0.7792819
Number of take out places(City)
0.8325884
Cost of a monthly gym membership(City) (£)
0.9268587
principal(): Fungsi dari paket psych di R yang digunakan
untuk melakukan Analisis Komponen Utama (PCA). r=korelasi:
Matriks korelasi nfactors = 1: Menentukan jumlah faktor
(komponen) yang diinginkan, yaitu 1 faktor, sesuai dengan hasil scree
plot yang didapat. rotate = "varimax": Teknik rotasi
varimax, yang bertujuan untuk memaksimalkan varians faktor agar
interpretasi lebih mudah. PCA$communality: Mengakses jumlah
varians tiap variabel yang dijelaskan oleh faktor yang dipertahankan
dalam model. Nilai ini menunjukkan seberapa besar faktor berhasil
merepresentasikan variabel.
> library(psych)
> PFA = fa(r = healthy_lifestyle2, nfactors = 4, rotate = "varimax", fm = "pa")
Error in La.svd(B): infinite or missing values in 'x'
> PFA
Error: object 'PFA' not found
> PFA$scores
Error: object 'PFA' not found
fa(): Fungsi dari paket psych untuk melakukan Analisis
Faktor (Factor Analysis). rotate = "varimax": Teknik rotasi
“varimax” untuk memperjelas interpretasi faktor. fm = "pa":
Metode “pa” (principal axis factoring), yaitu metode estimasi faktor
utama.
> loads = PFA$loadings
Error: object 'PFA' not found
> fa.diagram(loads)
Error: object 'loads' not found
>
> round(PFA$loadings[1:6,],4)
Error: object 'PFA' not found
PFA$loadings: Matriks loadings dari hasil analisis
faktor, yang menunjukkan kontribusi tiap variabel terhadap faktor yang
terbentuk. fa.diagram(loads): Menggunakan fungsi
fa.diagram() dari psych untuk membuat diagram faktor berdasarkan
loadings, yang menggambarkan hubungan antar variabel dan faktor.
round(): Membulatkan nilai loadings menjadi empat desimal.
PFA$loadings[1:6,]: Menampilkan loadings untuk enam
variabel pertama dari matriks loadings hasil analisis faktor.
Sunshine hours(City) Cost of a bottle of water(City)
Min. :1405 Min. :0.150
1st Qu.:1810 1st Qu.:0.570
Median :2142 Median :1.195
Mean :2246 Mean :1.173
3rd Qu.:2626 3rd Qu.:1.600
Max. :3542 Max. :3.200
Obesity levels(Country) (£) Life expectancy(years) (Country)
Min. :0.0390 Min. :56.30
1st Qu.:0.1950 1st Qu.:75.40
Median :0.2230 Median :80.40
Mean :0.2192 Mean :78.17
3rd Qu.:0.2900 3rd Qu.:81.80
Max. :0.3620 Max. :83.20
Pollution(Index score) (City) Happiness levels(Country)
Min. :13.08 Min. :3.570
1st Qu.:36.07 1st Qu.:5.870
Median :51.88 Median :6.900
Mean :51.12 Mean :6.435
3rd Qu.:66.35 3rd Qu.:7.175
Max. :91.74 Max. :7.800
Outdoor activities(City) Number of take out places(City)
Min. : 23.0 Min. : 250
1st Qu.:125.2 1st Qu.: 548
Median :189.5 Median : 998
Mean :214.0 Mean :1443
3rd Qu.:288.2 3rd Qu.:1674
Max. :585.0 Max. :6417
Cost of a monthly gym membership(City) (£)
Min. :16.07
1st Qu.:31.31
Median :37.33
Mean :40.42
3rd Qu.:47.21
Max. :73.11
Dari hasil di atas, didapat informasi nilai minimum, maksimum, median, mean, kuartil 1, dan kuartil 2 dari masing-masing variabel.
Kaiser-Meyer-Olkin Statistics
Call: KMOS(x = healthy_lifestyle)
Measures of Sampling Adequacy (MSA):
Sunshine hours(City)
0.4765490
Cost of a bottle of water(City)
0.8687709
Obesity levels(Country) (£)
0.4015657
Life expectancy(years) (Country)
0.7799179
Pollution(Index score) (City)
0.8237615
Happiness levels(Country)
0.7136634
Outdoor activities(City)
0.5353500
Number of take out places(City)
0.3721913
Cost of a monthly gym membership(City) (£)
0.5277982
KMO-Criterion: 0.670467
Dari hasil di atas, didapat statistik KMO-Criterion sebesar 0.67 > 0.5, sehingga dapat disimpulkan analisis faktor dapat diterapkan menggunakan matriks korelasi antar variabel data.
Nilai MSA untuk variabel Sunshine hours, Obesity levels, dan Number of take out places < 0.5 sehingga variabel tersebut tidak dapat dianalisis lebih lanjut. Data perlu diperbarui, dengan membuang variabel-variabel di atas sebelum analisis dapat dilanjutkan.
| Cost of a bottle of water(City) (Pound) | Life expectancy(years) (Country) | Pollution(Index score) (City) | Happiness levels(Country) | Outdoor activities(City) | Cost of a monthly gym membership(City) (Pound) |
|---|---|---|---|---|---|
| 1.92 | 81.2 | 30.93000 | 7.44 | 422 | 34.90 |
| 1.48 | 82.1 | 26.86000 | 7.22 | 406 | 41.66 |
| 1.94 | 81.0 | 17.33000 | 7.29 | 132 | 25.74 |
| 1.72 | 81.8 | 19.63000 | 7.35 | 129 | 37.31 |
| 2.19 | 79.8 | 21.24000 | 7.64 | 154 | 32.53 |
| 1.60 | 80.4 | 13.08000 | 7.80 | 113 | 35.23 |
| 0.78 | 83.2 | 51.12233 | 5.87 | 35 | 55.87 |
| 1.55 | 80.6 | 39.41000 | 7.07 | 254 | 26.11 |
| 1.19 | 82.2 | 65.19000 | 6.40 | 585 | 37.80 |
| 1.08 | 81.7 | 24.26000 | 7.23 | 218 | 31.04 |
| 1.57 | 82.1 | 25.90000 | 7.22 | 243 | 36.89 |
| 0.26 | 75.4 | 85.43000 | 5.12 | 223 | 38.62 |
| 0.22 | 74.1 | 76.64000 | 5.99 | 377 | 50.03 |
| 0.57 | 75.9 | 52.64000 | 5.97 | 246 | 22.45 |
| 1.09 | 81.7 | 37.83000 | 7.23 | 174 | 32.64 |
| 1.30 | 82.2 | 52.68000 | 6.40 | 216 | 34.54 |
| 0.21 | 68.5 | 84.39000 | 5.28 | 114 | 29.94 |
| 0.59 | 81.3 | 57.82000 | 5.87 | 144 | 43.03 |
| 1.95 | 80.6 | 37.78000 | 7.07 | 23 | 39.01 |
| 2.62 | 82.6 | 27.25000 | 7.56 | 44 | 70.00 |
| 1.63 | 81.9 | 47.28000 | 7.12 | 139 | 58.31 |
| 0.15 | 74.7 | 69.49000 | 5.13 | 419 | 16.97 |
| 0.16 | 70.7 | 91.74000 | 4.15 | 323 | 23.25 |
| 0.57 | 75.4 | 49.32000 | 5.12 | 134 | 34.76 |
| 1.52 | 78.8 | 66.07000 | 6.94 | 223 | 32.00 |
| 0.15 | 67.3 | 82.84000 | 3.57 | 187 | 19.54 |
| 1.39 | 78.8 | 27.03000 | 6.94 | 88 | 46.27 |
| 1.40 | 80.5 | 40.07000 | 7.09 | 159 | 37.35 |
| 0.76 | 83.2 | 42.84000 | 5.87 | 387 | 70.82 |
| 1.20 | 78.8 | 43.33000 | 6.94 | 171 | 41.14 |
| 0.75 | 75.4 | 67.46000 | 5.51 | 277 | 57.95 |
| 0.29 | 75.4 | 77.40000 | 5.12 | 108 | 44.68 |
| 2.11 | 80.4 | 62.67000 | 6.86 | 55 | 25.34 |
| 1.60 | 78.8 | 47.36000 | 6.94 | 242 | 65.13 |
| 1.95 | 81.8 | 65.10000 | 6.66 | 331 | 35.93 |
| 0.44 | 73.9 | 79.78000 | 6.37 | 158 | 16.07 |
| 3.20 | 82.6 | 17.31000 | 7.56 | 69 | 73.11 |
| 1.16 | 80.4 | 58.91000 | 7.16 | 433 | 42.71 |
| 0.59 | 56.3 | 61.83000 | 4.81 | 194 | 24.28 |
| 1.15 | 82.7 | 67.19000 | 6.38 | 110 | 53.49 |
| 1.45 | 78.8 | 39.18000 | 6.94 | 83 | 65.99 |
| 1.32 | 78.8 | 57.36000 | 6.94 | 359 | 64.66 |
| 0.41 | 69.5 | 57.63000 | 5.54 | 322 | 31.40 |
| 0.45 | 76.4 | 82.78000 | 6.46 | 192 | 41.99 |
Data baru tidak lagi mengandung variabel Sunshine hours, Obesity levels, dan Number of take out places.
Bartlett's Test of Sphericity
Call: bart_spher(x = healthy_lifestyle2)
X2 = 126.571
df = 15
p-value < 2.22e-16
Hipotesis: H0: R = I (Tidak terdapat korelasi yang signifikan antar variabel)
H1: R ≠ I (Terdapat korelasi yang signifikan antar variabel)
Keputusan: nilai-p < α (0.05), maka tolak H0
Kesimpulan: Dengan tingkat kepercayaan 95%, dapat disimpulkan bahwa terdapat korelasi yang signifikan antar variabel, sehingga layak dilanjutkan dengan analisis faktor.
eigen() decomposition
$values
[1] 3.5931491 1.6031401 1.3781225 1.0289855 0.4602604 0.3740913 0.2372168
[8] 0.2164747 0.1085597
$vectors
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 0.23273715 -0.08709175 0.58610475 -0.47036012 0.16147797 -0.16658189
[2,] -0.47496352 -0.05010406 0.06636821 0.01276653 -0.10397522 0.16431178
[3,] -0.15623060 0.16215214 0.73124737 0.16186658 -0.33565242 -0.03036251
[4,] -0.42128069 0.17677131 -0.13659065 -0.15288496 0.36881724 -0.70155775
[5,] 0.45321935 0.10725811 -0.04193501 -0.17026599 -0.24212756 -0.48023399
[6,] -0.48993283 0.09364897 0.15065760 0.08878143 -0.04324779 -0.13472080
[7,] 0.13945894 0.65086860 0.14283472 0.04565937 0.60736633 0.31155211
[8,] 0.02223379 0.69671167 -0.19472172 -0.01928919 -0.51628223 -0.04851605
[9,] -0.23015771 0.05524201 -0.12618315 -0.83047834 -0.13597055 0.32241906
[,7] [,8] [,9]
[1,] -0.183359949 0.53370527 -0.03470111
[2,] -0.811375775 -0.04156367 0.26356047
[3,] 0.282218020 -0.36012618 0.25583759
[4,] 0.137721703 -0.03477799 0.31758063
[5,] -0.391047924 -0.50971501 -0.22441159
[6,] -0.001213919 0.05805311 -0.83499948
[7,] -0.137557818 -0.20983594 -0.07431615
[8,] -0.008384725 0.44509369 0.09343464
[9,] 0.193705430 -0.27786994 -0.03440579
Berdasarkan scree plot di atas, terdapat 4 faktor yang memiliki nilai
eigen lebih dari 1. Sehingga faktor yang optimal untuk dipertahankan
dalam model ada sebanyak 4 faktor.
Sunshine hours(City)
0.9078507
Cost of a bottle of water(City)
0.8208423
Obesity levels(Country) (£)
0.8937271
Life expectancy(years) (Country)
0.7375609
Pollution(Index score) (City)
0.7887581
Happiness levels(Country)
0.9159292
Outdoor activities(City)
0.7792819
Number of take out places(City)
0.8325884
Cost of a monthly gym membership(City) (£)
0.9268587
Berdasarkan output di atas, dapat nilai komunalitas setiap variabel < 1. Nilai komunalisme merupakan jumlah varians tiap variabel yang dijelaskan oleh faktor yang dipertahankan dalam model. Nilai ini menunjukkan seberapa besar faktor berhasil merepresentasikan variabel. Nilai yang kurang dari satu dapat berarti terdapat informasi yang hilang. Jadi PCA kurang tepat digunakan sebagai metode ekstraksi faktor pada kasus ini.
Factor Analysis using method = pa
Call: fa(r = healthy_lifestyle2, nfactors = 4, rotate = "varimax",
SMC = FALSE, fm = "pa")
Standardized loadings (pattern matrix) based upon correlation matrix
PA1 PA3 PA2 PA4 h2
Cost of a bottle of water(City) (Pound) 0.83 0.19 -0.14 0.20 0.78
Life expectancy(years) (Country) 0.50 0.22 0.02 0.82 0.97
Pollution(Index score) (City) -0.81 -0.08 0.13 -0.17 0.70
Happiness levels(Country) 0.87 0.11 -0.02 0.33 0.87
Outdoor activities(City) -0.14 -0.05 0.99 0.01 1.00
Cost of a monthly gym membership(City) (Pound) 0.17 0.97 -0.05 0.15 1.00
u2 com
Cost of a bottle of water(City) (Pound) 0.21554 1.3
Life expectancy(years) (Country) 0.02722 1.8
Pollution(Index score) (City) 0.30068 1.2
Happiness levels(Country) 0.12697 1.3
Outdoor activities(City) 0.00075 1.0
Cost of a monthly gym membership(City) (Pound) 0.00293 1.1
PA1 PA3 PA2 PA4
SS loadings 2.39 1.05 1.02 0.87
Proportion Var 0.40 0.17 0.17 0.14
Cumulative Var 0.40 0.57 0.74 0.89
Proportion Explained 0.45 0.20 0.19 0.16
Cumulative Proportion 0.45 0.65 0.84 1.00
Mean item complexity = 1.3
Test of the hypothesis that 4 factors are sufficient.
df null model = 15 with the objective function = 3.15 with Chi Square = 126.57
df of 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 n.obs is 44 with the empirical chi square 0 with prob < NA
The total n.obs was 44 with Likelihood Chi Square = 0.02 with prob < NA
Tucker Lewis Index of factoring reliability = 1.147
Fit based upon off diagonal values = 1
Measures of factor score adequacy
PA1 PA3 PA2 PA4
Correlation of (regression) scores with factors 0.94 1.00 1.00 0.95
Multiple R square of scores with factors 0.88 1.00 1.00 0.91
Minimum correlation of possible factor scores 0.76 0.99 0.99 0.81
PA1 PA3 PA2 PA4
[1,] 1.2516318 -0.50220007 1.80014682 0.030288387
[2,] 0.8560066 -0.02850473 1.63654020 0.333775777
[3,] 1.2170307 -1.27646553 -0.54709082 0.251295668
[4,] 1.0051313 -0.46529413 -0.56371055 0.348816310
[5,] 1.5389045 -0.76627390 -0.29757476 -0.317908046
[6,] 1.3705432 -0.60102292 -0.64313536 -0.118547775
[7,] -0.9949274 0.92197378 -1.53149316 1.459155507
[8,] 0.7062349 -1.14125388 0.35636583 0.406404857
[9,] -0.1356023 -0.14800672 2.91185627 0.917092506
[10,] 0.6523249 -0.84102501 0.07268550 0.609410466
[11,] 0.8339878 -0.44057977 0.31796546 0.482940172
[12,] -1.5296944 0.09239194 -0.13605573 0.240739807
[13,] -0.8141279 0.96369255 1.23481260 -0.685126933
[14,] -0.3635131 -1.15787288 0.14926058 -0.008764156
[15,] 0.4468638 -0.73119465 -0.30063454 0.715816651
[16,] -0.1442656 -0.54699348 -0.04118717 1.093076519
[17,] -1.1207619 -0.36691996 -0.94993473 -1.351641269
[18,] -0.9351024 0.11814411 -0.69261059 1.194961645
[19,] 0.7024280 -0.32654976 -1.43790836 0.249346938
[20,] 1.2028258 1.78203133 -1.09826911 -0.133973610
[21,] 0.3513427 1.08261393 -0.50056065 0.364603610
[22,] -1.0887177 -1.37073010 1.41283616 0.153630639
[23,] -1.8541210 -0.76672603 0.58244930 -0.421600820
[24,] -0.9513163 -0.26735012 -0.77791414 -0.002808623
[25,] 0.3103483 -0.64229688 0.08318373 0.134144256
[26,] -1.9920239 -0.96257199 -0.51849234 -1.022823264
[27,] 0.5712763 0.29300633 -0.90678126 -0.239554430
[28,] 0.5130537 -0.36532158 -0.38787405 0.323453696
[29,] -0.7549357 2.12835701 1.35968058 0.940700736
[30,] 0.3525076 -0.01807633 -0.29440325 -0.043978612
[31,] -0.8963750 1.44479382 0.45161012 -0.475962067
[32,] -1.5225791 0.47142366 -1.03003088 0.161863959
[33,] 0.4492923 -1.25904439 -1.26441750 0.583563086
[34,] 0.4108785 1.71899558 0.36591448 -0.528941448
[35,] 0.2676058 -0.41377597 0.94113496 0.719368960
[36,] -0.4538477 -1.57658961 -0.57949981 -0.243285969
[37,] 1.6186199 1.98320929 -0.82830278 -0.438118975
[38,] 0.3489441 0.15675104 1.79146574 0.220242899
[39,] -0.2292057 -0.37638106 -0.15528147 -4.556258258
[40,] -0.6190574 0.77408596 -0.88721945 1.173833447
[41,] 0.3306232 1.71423081 -0.90989032 -0.450782769
[42,] 0.2226065 1.75296453 1.26957441 -0.446870479
[43,] -0.4462807 -0.25565391 0.80225403 -1.601672367
[44,] -0.6845571 0.21600966 -0.25946398 -0.019906629
Karena komunalitas setiap variable bernilai nilai < 1, maka Analsis Faktor sudah tepat digunakan untuk kasus ini.
Model analisis faktor yang terbentuk adalah: \[ x_{1} = 0.83PA_{1} - 0.14PA_{2}+0.19PA_{3}+0.20PA_4+ \epsilon_{1} \] \[ x_{2} = 0.50PA_{2}+0.02PA_2+0.22PA_3+0.82PA_4 + \epsilon_{2} \] \[ x_{3} = -0.81PA_{3} +0.13PA_2-0.08PA_3-0.17PA_4 + \epsilon_{3} \] \[ x_{4} = 0.87PA_{4} -0.02PA_2+0.11PA_3+0.33PA_4 + \epsilon_{4} \] \[ x_{5} = -0.14PA_{5} +0.99PA_2-0.05PA_3+0.01PA_4 + \epsilon_{5} \] \[ x_{6} = 0.17PA_{6} -0.05PA_2+0.97PA_3+0.15PA_4 + \epsilon_{6} \] Dengan analisis dengan 4 faktor, varian yang dijelaskan oleh PA1 adalah 40%, PA3 menjelaskan 17%, PA2 menjelaskan 17%, dan PA4 menjelaskan 14%. Secara kumulatif, keempat faktor menjelaskan variansi sebesar 89%.
PA1 PA3 PA2 PA4
Cost of a bottle of water(City) (Pound) 0.8311 0.1877 -0.1420 0.1958
Life expectancy(years) (Country) 0.4987 0.2199 0.0239 0.8217
Pollution(Index score) (City) -0.8059 -0.0794 0.1272 -0.1655
Happiness levels(Country) 0.8689 0.1076 -0.0189 0.3258
Outdoor activities(City) -0.1358 -0.0467 0.9892 0.0116
Cost of a monthly gym membership(City) (Pound) 0.1653 0.9721 -0.0498 0.1495
Berdasarkan visualisasi di atas, dapat dilihat bahwa faktor PA1 memiliki korelasi signifikan terhadap Happiness levels, Cost of a bottle of water, dan Pollution (hubungan negatif). PA2 berkorelasi signifikan terhadap Outdoor activities, PA3 berkorelasi signifikan terhadap Cost of a monthly gym membership, dan PA4 berkorelasi signifikan terhadap Life expectancy.
Dari hasil yang diperoleh, dapat disimpulkan bahwa terdapat 3 variabel yaitu Sunshine hours, Obesity levels, dan Number of take out places yang memiliki nilai MSA < 0.5, sehingga perlu dibuang. Setelah data diperbarui dengan membuang ketiga variabel tersebut, analisis dilanjutkan dan didapat 4 faktor bermakna yang dapat diekstrak dari 6 variabel/indikator gaya hidup sehat. Dengan menggunakan 4 faktor, variansi keseluruhan yang dapat dijelaskan oleh keempat faktor adalah sebesar 89%.
Sumber Data: https://www.kaggle.com/datasets/prasertk/healthy-lifestyle-cities-report-2021 Johnson, Richard, A.W & Dean W. 2007. Applied Multivariate Statistical Analysis.Edisi VI. New Jersey: Pretice-Hall International, Inc. Suryanto. 1988. Metode Statistika Multivariat. Jakarta: Departemen Pendidikan dan Kebudayaan. Wiratmanto. (2014). Analisis Faktor dan Penerapannya dalam Mengidentifikasi Faktor-Faktor yang Mempengaruhi Kepuasan Konsumen terhadap Penjualan Media Pembelajaran. Universitas Negeri Yogyakarta.