Analyse en composantes principales «à rebours»: quelle est la variance des données expliquée par une combinaison linéaire donnée des variables?

17

J'ai effectué une analyse en composantes principales de six variables AA , BB , CC , DD , EE et FF . Si je comprends bien, PC1 non rotatif me dit quelle combinaison linéaire de ces variables décrit / explique la plus grande variance dans les données et PC2 me dit quelle combinaison linéaire de ces variables décrit la plus grande variance suivante dans les données et ainsi de suite.

Je suis juste curieux - y a-t-il un moyen de faire ça "à l'envers"? Disons que je choisis une combinaison linéaire de ces variables - par exemple A + 2 B + 5 CA+2B+5C , pourrais-je déterminer la variance des données que cela décrit?

N26
la source
7
Strictement, PC2 est la combinaison linéaire orthogonale à PC1 qui décrit la plus grande variance suivante dans les données.
Henry
1
Essayez-vous d'estimer V a r ( A + 2 B + 5 C )Var(A+2B+5C) ?
vqv
Toutes les bonnes réponses (trois + 1). Je suis curieux de savoir si les gens formulent le problème formulé via des approches à variables latentes (SEM / LVM), si nous considérons une ou plusieurs variables latentes "une combinaison linéaire des variables".
Aleksandr Blekh
1
@Aleksandr, ma réponse est en fait directement en contradiction avec les deux autres. J'ai édité ma réponse pour clarifier le désaccord (et je prévois de l'éditer davantage pour énoncer les mathématiques). Imaginez un jeu de données avec deux variables normalisées identiques X = YX=Y . Quelle variance est décrite par XX ? Deux autres solutions donnent 50 %50% . Je soutiens que la bonne réponse est 100 %100% .
amibe dit Réintégrer Monica le
1
@amoeba: En dépit de mes difficultés à comprendre complètement le contenu, je comprends que votre réponse est différente. Quand j'ai dit "toutes les bonnes réponses", j'ai laissé entendre que j'aime le niveau des réponses en soi, pas leur exactitude . Je trouve que cela a une valeur éducative pour des gens comme moi, qui sont dans leur quête d'auto-éducation dans un pays accidenté, appelée Statistiques :-). J'espère que cela a du sens.
Aleksandr Blekh

Réponses:

11

Si nous partons du principe que toutes les variables ont été centrées (pratique standard en ACP), alors la variance totale dans les données n'est que la somme des carrés:

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)

Ceci est égal à la trace de la matrice de covariance des variables, qui est égale à la somme des valeurs propres de la matrice de covariance. C'est la même quantité dont PCA parle en termes d '«explication des données» - c'est-à-dire que vous voulez que vos PC expliquent la plus grande proportion des éléments diagonaux de la matrice de covariance. Maintenant, si nous en faisons une fonction objective pour un ensemble de valeurs prédites comme ceci:

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

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

Ensuite , les premiers composants principaux Minimise SS parmi tous les rang 1 valeurs prédites ( A i , ... , F i )(A^i,,F^i) . Il semblerait donc que la quantité appropriée que vous recherchez soit P = 1 - ST

P=1ST
Pour utiliser votre exempleA+2B+5CA+2B+5C, nous devons transformer cette équation en prédictions de rang 1. Vous devez d'abord normaliser les poids pour avoir la somme des carrés 1. Nous remplaçons donc(1,2,5,0,0,0)(1,2,5,0,0,0)(somme des carrés3030) par(130 ,230 ,530 ,0,0,0)(130,230,530,0,0,0). Ensuite, nous «notons» chaque observation en fonction des poids normalisés:

Z i = 130 Ai+230 Bi+530 Ci

Zi=130Ai+230Bi+530Ci

Ensuite, nous multiplions les scores par le vecteur de poids pour obtenir notre prédiction de rang 1.

( 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
la source
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
la source
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
la source
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