Temel bileşen analizi “geriye”: Verilerin ne kadar varyansı, değişkenlerin belirli bir doğrusal kombinasyonu ile açıklanır?


17

AA , BB , CC , DD , EE ve F değişkenlerinin altı temel bileşen analizi yaptım F. Doğru anlıyorsam, döndürülmemiş PC1 bu değişkenlerin hangi doğrusal kombinasyonunun verilerdeki en çok varyasyonu açıkladığını / açıkladığını ve PC2 bu değişkenlerin hangi doğrusal kombinasyonunun verilerdeki bir sonraki en fazla varyasyonu tanımladığını vb.

Sadece merak ediyorum - bunu "geriye" yapmanın bir yolu var mı? Bu değişkenlerin doğrusal bir kombinasyonunu seçtiğimi varsayalım - örneğin A + 2 B + 5 CA+2B+5C , bunun açıkladığı verilerde ne kadar varyans olduğunu hesaplayabilir miyim?


7
Kesinlikle, PC2, verilerde bir sonraki en fazla varyansı tanımlayan PC1'e dik doğrusal bir kombinasyondur .
Henry

1
V a r ( A + 2 B + 5 C ) tahmin etmeye mi çalışıyorsunuz Var(A+2B+5C)?
vqv

Tüm güzel cevaplar (üç + 1). Bir ya da daha fazla gizli değişkeni "değişkenlerin doğrusal bir kombinasyonu" olarak değerlendirdiğimizde , formüle edilen sorunun gizli değişken yaklaşımlar (SEM / LVM) ile çözülüp çözülemeyeceği konusunda insanların fikrini merak ediyorum .
Aleksandr Blekh

1
@Aleksandr, cevabım aslında diğer ikisiyle doğrudan çelişiyor. Anlaşmazlığı netleştirmek için cevabımı düzenledim (ve matematiği hecelemek için daha fazla düzenlemeyi planlıyorum). Standart iki özdeş değişken X = Y olan bir veri kümesi düşünün X=Y. X tarafından ne kadar varyans açıklanmaktadır X? Diğer iki çözelti % 50 verir 50%. Doğru cevabın % 100 olduğunu iddia ediyorum 100%.
amip diyor Reinstate Monica

1
@amoeba: Materyali hala tam olarak anlamakta zorlanmasına rağmen, cevabınızın farklı olduğunu anlıyorum. "Tüm güzel cevaplar" dediğimde, cevapların düzeyini değil, doğruluklarını sevdiğimi ima ettim . Arazi ülkesinde kendi kendine eğitim arayışında olan İstatistikler :-) gibi benim gibi insanlar için eğitimsel bir değere sahip olduğunu düşünüyorum . Umarım mantıklıdır.
Aleksandr Blekh

Yanıtlar:


11

Tüm değişkenlerin ortalandığı öncülüyle başlarsak (PCA'da standart uygulama), verilerdeki toplam varyans sadece karelerin toplamıdır:

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)

Bu, değişkenlerin kovaryans matrisinin izine eşittir, bu kovaryans matrisinin özdeğerlerinin toplamına eşittir. Bu, PCA'nın "verileri açıklama" açısından bahsettiği miktarla aynıdır - yani PC'lerinizin kovaryans matrisinin köşegen öğelerinin en büyük oranını açıklamasını istersiniz. Şimdi bunu bir dizi öngörülen değer için nesnel bir işlev yaparsak:

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

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

Daha sonra birinci ana bileşeni en aza indirir SS tüm sıralaması 1 monte değerleri arasında ( A i , ... , K i )(A^i,,F^i) . Yani peşinde olduğunuz uygun miktar P = 1 - ST

P=1ST
To use your example A+2B+5CA+2B+5C, we need to turn this equation into rank 1 predictions. First you need to normalise the weights to have sum of squares 1. So we replace (1,2,5,0,0,0)(1,2,5,0,0,0) (sum of squares 3030) with (130,230,530,0,0,0)(130,230,530,0,0,0). Next we "score" each observation according to the normalised weights:

Zi=130Ai+230Bi+530Ci

Zi=130Ai+230Bi+530Ci

Then we multiply the scores by the weight vector to get our rank 1 prediction.

(ˆAiˆBiˆCiˆDiˆEiˆFi)=Zi×(130230530000)

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.


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.


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 xx explains so and so much variance in yy, we compute reconstruction error of yxbyxb with an optimal bb, not just yxyx. Here is another argument: if all nn variables are standardized, then in your approach each one explains 1/n1/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, TT, 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)

T=i(xix¯)(xix¯)
where ˉxx¯ is the mean vector of the data set, xixi 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 xixi and its predicted value, f(xi)f(xi), when we set f(xi)=ˉxf(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.


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
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.