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
Jawaban:
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 )
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 )
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
Z i = 1√30 Ai+2√30 Bi+5√30 Ci
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 × ( 1√30 2√30 5√30 000)
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−||O−E||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.
sumber
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(Σ).
This might not be immediately obvious, because e.g. @probabilityislogic suggests to consider the reconstruction Xww⊤Xww⊤ and then to compute ‖X‖2−‖X−Xww⊤‖2‖X‖2,
Approach #2
Okay. Now consider a following example: XX is a d=2d=2 dataset with covariance matrix Σ=(10.990.991)
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 Xwv⊤Xwv⊤ 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=‖X‖2−‖X−Xwv⊤‖2‖X‖2,
It is a matter of straightforward algebra to use regression solution for vv to find that the whole expression simplifies to R2second=‖Σw‖2w⊤Σw⋅tr(Σ).
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.
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 ‖X−Xwv⊤‖2∥X−Xwv⊤∥2 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⊤Σ.
Next, the R2R2 formula can be simplified as R2=‖X‖2−‖X−Xwv⊤‖2‖X‖2=‖Xwv⊤‖2‖X‖2
Plugging now the equation for vv , we obtain for the numerator: ‖Xwv⊤‖2=tr(Xwv⊤(Xwv⊤)⊤)=tr(Xww⊤ΣΣww⊤X⊤)/(w⊤Σw)2=tr(w⊤ΣΣw)/(w⊤Σw)=‖Σw‖2/(w⊤Σw).
The denominator is equal to ‖X‖2=tr(Σ)∥X∥2=tr(Σ) resulting in the formula given above.
sumber
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)
Now let the predictor of xi, f(xi), be the projection of vector xi onto a unit vector c.
fc(xi)=(c⋅xi)c
Then the SSE for a given c is SSEc=∑i(xi−fc(xi))⋅(xi−fc(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 T−SSEc is the variance in the data described by using c as a predictor.
sumber