# Explained variance of non-negative matrix factorisation

How can I calculate R2 or another measure of explained variance for non-negative matrix factorisation. Currently I calculate the total sum of squares (TSS) as the sum of the squared distance of every data point to the mean and residual sum of squares (RSS) as the squared sum of the distance of every residuum to the origin. Then R2=1-RSS/TSS. So basically I did the same as one would for a regression.

Now sometimes it can happen that one component/factor yields a R2 of .15 whereas two (with the same data) results in an R2 of .90. Can this be correct? After checking, all data points are roughly the same "size" (distance to origin) and the first component is similar to the mean. Can it be that TSS is wrongly calculated?

Thanks.

edit: I think what I am really looking for is a method to judge how many components/factors are needed to explain my data. For example a method can be to want to have an R2 of >.9. Is there a better way than to use R2, especially regarding the fact that one factor (under special circumstances might explain very little variance, whereas 2 already describe a lot.

edit2: Would it be meaningful to describe the relate the root mean square residual to Dr=sqrt(norm(A-W*H,'fro')/(N*M)) to the root mean square of the original matrix Dtot=sqrt(norm(A,'fro')/(N*M)). A is the original matrix of size N-by-M and, W and H the factors as determined by the NNMF. 'fro' is the matlab code for the Frobenius norm. Thus, I would use 1-(Dr/Dtot) and a cutoff value to choose the number of 'factors' that describe enough of my data.

• Feb 19 '13 at 15:59
• Thanks for the link. I am aware how the explained variance of the PCA is calculated. What I want to accomplish is to have a method-independend way of determining how well a method explains my data and R2 seemed to be the right value. Feb 20 '13 at 8:01