Analisis komponen utama “mundur”: berapa banyak varian data dijelaskan oleh kombinasi linear dari variabel?

17

Saya telah melakukan analisis komponen utama dari enam variabel AA , BB , CC , DD , EE dan . Jika saya mengerti dengan benar, PC1 yang tidak diputar memberitahu saya apa kombinasi linear dari variabel-variabel ini menggambarkan / menjelaskan varians paling banyak dalam data dan PC2 memberi tahu saya apa kombinasi linear dari variabel-variabel ini yang menggambarkan varians terbanyak berikutnya dalam data dan seterusnya.FF

Saya hanya ingin tahu - apakah ada cara untuk melakukan ini "mundur"? Katakanlah saya memilih beberapa kombinasi linear dari variabel-variabel ini - misalnya , dapatkah saya menghitung berapa banyak varians dalam data yang dijelaskan ini?A + 2 B + 5 CA+2B+5C

N26
sumber
7
Secara ketat, PC2 adalah kombinasi linear ortogonal dengan PC1 yang menggambarkan varian terbanyak berikutnya dalam data.
Henry
1
Apakah Anda mencoba untuk memperkirakan V sebuah r ( A + 2 B + 5 C )Var(A+2B+5C) ?
vqv
Semua jawaban yang bagus (tiga +1). Saya ingin tahu tentang pendapat orang tentang apakah masalah yang dirumuskan dapat dipecahkan melalui pendekatan variabel laten (SEM / LVM), jika kita menganggap satu atau lebih variabel laten "kombinasi linear dari variabel".
Aleksandr Blekh
1
@Alexandr, jawaban saya sebenarnya langsung berselisih dengan dua lainnya. Saya mengedit jawaban saya untuk mengklarifikasi perbedaan pendapat (dan berencana untuk mengeditnya lebih lanjut untuk menjelaskan matematika). Bayangkan sebuah dataset dengan dua variabel identik standar X = YX=Y . Berapa varians yang dijelaskan oleh XX ? Dua solusi lain memberi 50 %50% . Saya berpendapat bahwa jawaban yang benar adalah 100 %100% .
Amoeba berkata Reinstate Monica
1
@amoeba: Meskipun masih berjuang untuk memahami materi sepenuhnya, saya mengerti bahwa jawaban Anda berbeda. Ketika saya mengatakan "semua jawaban yang bagus", saya menyiratkan bahwa saya menyukai tingkat jawaban itu sendiri, bukan kebenarannya . Saya menemukan bahwa itu memiliki nilai pendidikan untuk orang-orang seperti saya, yang sedang dalam pencarian pendidikan diri mereka di negara medan kasar, yang disebut Statistik :-). Semoga masuk akal.
Aleksandr Blekh

Jawaban:

11

Jika kita mulai dengan premis bahwa semua variabel telah dipusatkan (praktik standar dalam PCA), maka total varians dalam data hanyalah jumlah kuadrat:

T = i ( A 2 i + B 2 i + C 2 i + D 2 i + E 2 i + F 2 i )

T=i(A2i+B2i+C2i+D2i+E2i+F2i)

Ini sama dengan jejak matriks kovarians variabel, yang sama dengan jumlah nilai eigen dari matriks kovarians. Ini adalah jumlah yang sama dengan yang PCA bicarakan dalam hal "menjelaskan data" - yaitu Anda ingin PC Anda menjelaskan proporsi terbesar elemen diagonal dari matriks kovarians. Sekarang jika kita menjadikan ini sebagai fungsi objektif untuk sekumpulan nilai yang diprediksi seperti:

S = Σ i ( [ A i - A i ] 2 + + [ F i - F i ] 2 )

S=i([AiA^i]2++[FiF^i]2)

Maka yang pertama pokok meminimalkan komponen SS di antara semua peringkat 1 nilai fitted ( A i , ... , F i )(A^i,,F^i) . Jadi sepertinya jumlah yang tepat yang Anda cari adalah P = 1 - ST

P=1ST
Untuk menggunakan contoh AndaA+2B+5CA+2B+5C, kita perlu mengubah persamaan ini menjadi prediksi peringkat 1. Pertama, Anda perlu menormalkan bobot untuk memiliki jumlah kuadrat 1. Jadi, kami mengganti(1,2,5,0,0,0)(1,2,5,0,0,0)(jumlah kuadrat3030) dengan(130 ,230 ,530 ,0,0,0)(130,230,530,0,0,0). Selanjutnya kita "menilai" setiap pengamatan sesuai dengan bobot yang dinormalisasi:

Z i = 130 Ai+230 Bi+530 Ci

Zi=130Ai+230Bi+530Ci

Kemudian kita gandakan skor dengan vektor bobot untuk mendapatkan prediksi peringkat 1 kita.

( A i B i C i D i E i F i ) = Z i × ( 130 230 530 000)

A^iB^iC^iD^iE^iF^i=Zi×130230530000

Then we plug these estimates into SS calculate PP. You can also put this into matrix norm notation, which may suggest a different generalisation. If we set OO as the N×qN×q matrix of observed values of the variables (q=6q=6 in your case), and EE as a corresponding matrix of predictions. We can define the proportion of variance explained as:

||O||22||OE||22||O||22

||O||22||OE||22||O||22

Where ||.||2||.||2 is the Frobenius matrix norm. So you could "generalise" this to be some other kind of matrix norm, and you will get a difference measure of "variation explained", although it won't be "variance" per se unless it is sum of squares.

probabilityislogic
sumber
This is a reasonable approach, but your expression can be greatly simplified and shown to be equal to the sum of squares of ZiZi divided by the total sum of squares TT. Also, I think this is not the best way to interpret the question; see my answer for an alternative approach that I argue makes more sense (in particular, see my example figure there).
amoeba says Reinstate Monica
Think about it like that. Imagine a dataset with two standardized identical variables X=YX=Y. How much variance is described by XX? Your calculation gives 50%50%. I argue that the correct answer is 100%100%.
amoeba says Reinstate Monica
@amoeba - if X=YX=Y then the first PC is (12,12)(12,12) - this makes rank 11 scores of zi=xi+yi2=xi2zi=xi+yi2=xi2 (assuming xi=yixi=yi). This gives rank 11 predictions of ˆxi=xix^i=xi, and similarly ˆyi=yiy^i=yi. Hence you get OE=0OE=0 and S=0S=0. Hence you get 100% as your intuition suggests.
probabilityislogic
Hey, yes, sure, the 1st PC explains 100% variance, but that's not what I meant. What I meant is that X=YX=Y, but the question is how much variance is described by XX, i.e. by (1,0)(1,0) vector? What does your formula say then?
amoeba says Reinstate Monica
@amoeba - this says 50%, but note that the (1,0)(1,0) vector says that the best rank 11 predictor for (xi,yi)(xi,yi) is given as ˆxi=xix^i=xi and ˆyi=0y^i=0 (noting that zi=xizi=xi under your choice of vector). This is not an optimal prediction, which is why you don't get 100%. You need to predict both XX and YY in this set-up.
probabilityislogic
8

Let's say I choose some linear combination of these variables -- e.g. A+2B+5CA+2B+5C, could I work out how much variance in the data this describes?

This question can be understood in two different ways, leading to two different answers.

A linear combination corresponds to a vector, which in your example is [1,2,5,0,0,0][1,2,5,0,0,0]. This vector, in turn, defines an axis in the 6D space of the original variables. What you are asking is, how much variance does projection on this axis "describe"? The answer is given via the notion of "reconstruction" of original data from this projection, and measuring the reconstruction error (see Wikipedia on Fraction of variance unexplained). Turns out, this reconstruction can be reasonably done in two different ways, yielding two different answers.


Approach #1

Let XX be the centered dataset (nn rows correspond to samples, dd columns correspond to variables), let ΣΣ be its covariance matrix, and let ww be a unit vector from RdRd. The total variance of the dataset is the sum of all dd variances, i.e. the trace of the covariance matrix: T=tr(Σ)T=tr(Σ). The question is: what proportion of TT does ww describe? The two answers given by @todddeluca and @probabilityislogic are both equivalent to the following: compute projection XwXw, compute its variance and divide by TT: R2first=Var(Xw)T=wΣwtr(Σ).

R2first=Var(Xw)T=wΣwtr(Σ).

This might not be immediately obvious, because e.g. @probabilityislogic suggests to consider the reconstruction XwwXww and then to compute X2XXww2X2,

X2XXww2X2,
but with a little algebra this can be shown to be an equivalent expression.

Approach #2

Okay. Now consider a following example: XX is a d=2d=2 dataset with covariance matrix Σ=(10.990.991)

Σ=(10.990.991)
and w=(10)w=(10) is simply an xx vector:

variance explained

The total variance is T=2T=2. The variance of the projection onto ww (shown in red dots) is equal to 11. So according to the above logic, the explained variance is equal to 1/21/2. And in some sense it is: red dots ("reconstruction") are far away from the corresponding blue dots, so a lot of the variance is "lost".

On the other hand, the two variables have 0.990.99 correlation and so are almost identical; saying that one of them describes only 50%50% of the total variance is weird, because each of them contains "almost all the information" about the second one. We can formalize it as follows: given projection XwXw, find a best possible reconstruction XwvXwv with vv not necessarily the same as ww, and then compute the reconstruction error and plug it into the expression for the proportion of explained variance: R2second=X2XXwv2X2,

R2second=X2XXwv2X2,
where vv is chosen such that XXwv2XXwv2 is minimal (i.e. R2R2 is maximal). This is exactly equivalent to computing R2R2 of multivariate regression predicting original dataset XX from the 11-dimensional projection XwXw.

It is a matter of straightforward algebra to use regression solution for vv to find that the whole expression simplifies to R2second=Σw2wΣwtr(Σ).

R2second=Σw2wΣwtr(Σ).
In the example above this is equal to 0.99010.9901, which seems reasonable.

Note that if (and only if) ww is one of the eigenvectors of ΣΣ, i.e. one of the principal axes, with eigenvalue λλ (so that Σw=λwΣw=λw), then both approaches to compute R2R2 coincide and reduce to the familiar PCA expression R2PCA=R2first=R2second=λ/tr(Σ)=λ/λi.

R2PCA=R2first=R2second=λ/tr(Σ)=λ/λi.

PS. See my answer here for an application of the derived formula to the special case of ww being one of the basis vectors: Variance of the data explained by a single variable.


Appendix. Derivation of the formula for R2secondR2second

Finding vv minimizing the reconstruction XXwv2XXwv2 is a regression problem (with XwXw as univariate predictor and XX as multivariate response). Its solution is given by v=((Xw)(Xw))1(Xw)X=(wΣw)1wΣ.

v=((Xw)(Xw))1(Xw)X=(wΣw)1wΣ.

Next, the R2R2 formula can be simplified as R2=X2XXwv2X2=Xwv2X2

R2=X2XXwv2X2=Xwv2X2
due to the Pythagoras theorem, because the hat matrix in regression is an orthogonal projection (but it is also easy to show directly).

Plugging now the equation for vv, we obtain for the numerator: Xwv2=tr(Xwv(Xwv))=tr(XwwΣΣwwX)/(wΣw)2=tr(wΣΣw)/(wΣw)=Σw2/(wΣw).

Xwv2=tr(Xwv(Xwv))=tr(XwwΣΣwwX)/(wΣw)2=tr(wΣΣw)/(wΣw)=Σw2/(wΣw).

The denominator is equal to X2=tr(Σ)X2=tr(Σ) resulting in the formula given above.

amoeba says Reinstate Monica
sumber
I think this is an answer to a different question. For example, it not the case that that optimising your R2R2 wrt ww will give the first PC as the unique answer (in those cases where it is unique). The fact that (1,0)(1,0) and 12(1,1)12(1,1) both give 100% when X=YX=Y is evidence enough. Your proposed method seems to assume that the "normalised" objective function for PCA will always understate the variance explained (yours isn't a normalised PCA objective function as it normalises by the quantity being optimised in PCA).
probabilityislogic
I agree that our answers are to different questions, but it's not clear to me which one OP had in mind. Also, note that my interpretation is not something very weird: it's a standard regression approach: when we say that x explains so and so much variance in y, we compute reconstruction error of yxb with an optimal b, not just yx. Here is another argument: if all n variables are standardized, then in your approach each one explains 1/n amount of variance. This is not very informative: some variables can be much more predictive than others! My approach reflects that.
amoeba says Reinstate Monica
@amoeba (+1) Great answer, it's really helpful! Would you know any reference that tackles this issue? Thanks!
PierreE
@PierreE Thanks. No, I don't think I have any reference for that.
amoeba says Reinstate Monica
4

Let the total variance, T, in a data set of vectors be the sum of squared errors (SSE) between the vectors in the data set and the mean vector of the data set, T=i(xiˉx)(xiˉx)

where ˉx is the mean vector of the data set, xi is the ith vector in the data set, and is the dot product of two vectors. Said another way, the total variance is the SSE between each xi and its predicted value, f(xi), when we set f(xi)=ˉx.

Now let the predictor of xi, f(xi), be the projection of vector xi onto a unit vector c.

fc(xi)=(cxi)c

Then the SSE for a given c is SSEc=i(xifc(xi))(xifc(xi))

I think that if you choose c to minimize SSEc, then c is the first principal component.

If instead you choose c to be the normalized version of the vector (1,2,5,...), then TSSEc is the variance in the data described by using c as a predictor.

todddeluca
sumber
This is a reasonable approach, but I think this is not the best way to interpret the question; see my answer for an alternative approach that I argue makes more sense (in particular, see my example figure there).
amoeba says Reinstate Monica
Think about it like that. Imagine a dataset with two standardized identical variables X=Y. How much variance is described by X? Your calculation gives 50%. I argue that the correct answer is 100%.
amoeba says Reinstate Monica