2
$\begingroup$

I have $2$ $n\times p$ matrices, where $n$ are the rows (samples), and $p$ the columns (measurements). Each matrix has samples and measurements from different groups. I call these the "raw" data. I've conducted a principal components analyses of the complete raw data, and computed the mean of each PC score by group. The latter I call the mean of the PC scores by group.

My question is whether the means of the PC scores by group (raw-data $\rightarrow$ PCA $\rightarrow$ mean PCs by group) would differ from the PC scores derived from a PCA conducted on the "raw" group means (raw data $\rightarrow$ mean by group $\rightarrow$ PCA)?


Example analysis of simulated data

set.seed(123) 
a <- matrix(rnorm(900),ncol=3,byrow=F) 
a[1:100,] <- 4 + a[1:100,] 
a[101:200,] <- -4 + a[101:200,]
# compute PCA and extract PC scores
pc <- prcomp(a)$x 
    plot(pc[,1:2],col=rep(c("red","blue","green"),each=100))
    # compute PC means and plot
    m <-rbind(colMeans(pc[1:100,1:2]),colMeans(pc[101:200,1:2]),colMeans(pc[201:300,1‌​‌​:2]))
    points(m,col="black", pch=19,cex=1)
    # compute means of raw data by group
    b <- rbind(colMeans(a[1:100,]),colMeans(a[101:200,]),colMeans(a[201:300,]))
    # conduct PCA on "raw means" and plot 
    pc2 <- prcomp(b)$x
points(pc2[,1:2],col="black", pch=17,cex=1)
$\endgroup$
  • 2
    $\begingroup$ The mean of a random variable is a number and therefore has no covariance. It sounds like you might be asking about the difference between the distribution of a random variable and the distribution of the mean of a sample from that variable, but it is hard to tell: perhaps you could edit this question to clarify what you are looking for. PCA, by the way, does not model the data as realizations of random variables: it is a descriptive procedure. $\endgroup$ – whuber Oct 27 '13 at 17:11
  • $\begingroup$ I am not sure how you would do PCA on the means. But, if you know what you mean, why not just do it both ways and see if they are different? $\endgroup$ – Peter Flom - Reinstate Monica Oct 27 '13 at 17:50
  • 1
    $\begingroup$ I have, and there is a slight difference between means. I believe this is happening because the covariance between the sample Ps do not equal the covariance between their means (mean of P by group). I am assuming that this is happening because in the latter not all deviations are going into the computation of the covariance matrix (i.e.,1/(n-1)*sum(x-xbar * y-ybar)). I wondered if there is a more general reason for the differences. $\endgroup$ – user2925487 Oct 27 '13 at 18:18
  • $\begingroup$ The command "colMeans(pc[1:100,1:2])" would not run (or even worse maybe calculates recycled loadings...). If you are interested in PC-scores, you need to use the "predict" method of "prcomp", i.e. "predict(pc)". Besides all other issues: Is there a particular reason why you run the PCA on unscaled variables? $\endgroup$ – Michael M Oct 28 '13 at 19:21
1
$\begingroup$

The answer to your question should logicaly be "Yes." The group means of the PC should differ from the PC of the means. This should happen for two reasons.

  1. You're transforming your variables into PCs, which try to maximize the total interia. This depends on the spread of the data in the different variables.
  2. Once you take the means you eliminate most of the inertia. The PCA will be much more "accurate" (not surprisingly almost 100% of the intertia is explained by the first component), but the composition of the PC will be different because there is no longer much intertia to explain.

You can think of this in terms of how a PCA operates. The PCA is computed using squared distances, maximized for the first PCA. If you remove all this variability, the estimations change.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.