Pertemuan X
ANALISIS KOMPONEN UTAMA
What is Principal Components?
• Principal components atau komponen utama adalah
kombinasi linier dari variabel-variabel original, dimana
antar komponen utama dibuat sedemikian hingga saling
tidak berkorelasi.
• Analisis komponen utama menjelaskan struktur
varians kovarians dari sekelompok variabel melalui
kombinasi linier dari variabel-variabel tersebut dalam
dimensi yang lebih kecil.
• Tujuan analisis komponen utama:
A) data reduction, dan
B) interpretation.
Dari gambar di atas, meski untuk mendapatkan gambaran 100%
mengenai keragaman data, kita butuh 2 komponen utama (KU).
Namun hanya dengan melihat KU 1 kita sudah cukup
mendapatkan gambaran mengenai keragaman data.
> data_polusi$negtemp<-(-1)*data_polusi$temp
> data_polusi$temp<-NULL
Eksplorasi data: fungsi panel.hist adalah untuk
menampilkan histogram pada diagonal utama dari matriks
scatter plot.
> panel.hist <- function(x, ...) {
+ usr <- par("usr"); on.exit(par(usr))
+ par(usr = c(usr[1:2], 0, 1.5) )
+ h <- hist(x, plot = FALSE)
+ breaks <- h$breaks; nB <- length(breaks)
+ y <- h$counts; y <- y/max(y)
+ rect(breaks[-nB], 0, breaks[-1], y, col="grey", ...)
+ }
> pairs(data_polusi, diag.panel = panel.hist,
+ pch = ".", cex = 1.5)
• A clear message from Figure above is that there is at least
one city, and probably more than one, that should be
considered an outlier.
OUTPUT:
Importance of components:
Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6
Standard deviation 1.4819456 1.2247218 1.1809526 0.8719099 0.33848287 0.185599752
Proportion of Variance 0.3660271 0.2499906 0.2324415 0.1267045 0.01909511 0.005741211
Cumulative Proportion 0.3660271 0.6160177 0.8484592 0.9751637 0.99425879 1.000000000
Loadings:
Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6
manu -0.612 0.168 0.273 -0.137 0.102 0.703
popul -0.578 0.222 0.350 -0.695
wind -0.354 -0.131 -0.297 0.869 -0.113
precip -0.623 0.505 0.171 0.568
predays -0.238 -0.708 -0.311 -0.580
negtemp -0.330 -0.128 -0.672 -0.306 0.558 -0.136
Screeplot:
> screeplot(polusi_pca,type = "lines",col=4)
Interpretation??
• Dari bagian importance of components terlihat bahwa tiga
komponen utama pertama memiliki nilai eigen lebih besar
dari 1, dan ketiganya telah menyumbangkan sekitar 85%
keragaman terhadap total varians.
• Sehingga tiga KU tersebut sudah cukup menggambarkan
struktur varians-kovarians data dalam dimensi yang lebih
sedikit dengan resiko kita hanya kehilangan sedikit informasi
keragaman.
• Setiap komponen utama bisa kita beri “label”.
1. Komponen utama pertama bisa kita pertimbangkan
untuk kita beri nama “quality of life", dengan nilai
yang besar mengindikasikan lingkungan yang relatif
buruk.
2. Komponen utama kedua terkait dengan precip dan
predays, sehingga bisa kita beri nama komponen
“wet weather".
3. Komponen ketiga merupakan kontras antara precip
dan negtemp sehingga akan memisahkan kota yang
memiliki temperatur dan curah hujan tinggi dengan
kota yang cenderung lebih dingin namun curah hujan
rendah. Maka komponen ini bisa kita beri label
“climate type".
Tapi … ingat!!!
It must be emphasized that no mathematical method is, or
could be, designed to give physically meaningful results. If a
mathematical expression of this sort has an obvious physical
meaning, it must be attributed to a lucky change, or to the
fact that the data have a strongly marked structure that
shows up in analysis. Even in the latter case, quite small
sampling fluctuations can upset the interpretation; for
example, the first two principal components may appear in
reverse order, or may become confused altogether.
Marriott (1974)
Visualisasi Komponen Utama
Call:
lm(formula = SO2 ~ polusi_pca$scores, data = data_polusi)
Residuals:
Min 1Q Median 3Q Max
-23.004 -8.542 -0.991 5.758 48.758
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 30.049 2.286 13.146 6.91e-15 ***
polusi_pca$scoresComp.1 9.942 1.542 6.446 2.28e-07 ***
polusi_pca$scoresComp.2 -2.240 1.866 -1.200 0.23845
polusi_pca$scoresComp.3 0.375 1.935 0.194 0.84752
polusi_pca$scoresComp.4 -8.549 2.622 -3.261 0.00253 **
polusi_pca$scoresComp.5 -15.176 6.753 -2.247 0.03122 *
polusi_pca$scoresComp.6 39.271 12.316 3.189 0.00306 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1