I would like to understand how I can get the percentage of variance of a data set, not in the coordinate space provided by PCA, but against a slightly different set of (rotated) vectors.
set.seed(1234) xx <- rnorm(1000) yy <- xx * 0.5 + rnorm(1000, sd = 0.6) vecs <- cbind(xx, yy) plot(vecs, xlim = c(-4, 4), ylim = c(-4, 4)) vv <- eigen(cov(vecs))$vectors ee <- eigen(cov(vecs))$values a1 <- vv[, 1] a2 <- vv[, 2] theta = pi/10 rotmat <- matrix(c(cos(theta), sin(theta), -sin(theta), cos(theta)), 2, 2) a1r <- a1 %*% rotmat a2r <- a2 %*% rotmat arrows(0, 0, a1, a1, lwd = 2, col = "red") arrows(0, 0, a2, a2, lwd = 2, col = "red") arrows(0, 0, a1r, a1r, lwd = 2, col = "green3") arrows(0, 0, a2r, a2r, lwd = 2, col = "green3") legend("topleft", legend = c("eigenvectors", "rotated"), fill = c("red", "green3"))
So basically I know that the variance of the dataset along each of the red axes, given by PCA, is represented by the eigenvalues. But how could I get the equivalent variances, totalling the same amount, but projected the two different axes in green, which are are a rotation by pi/10 of the principal component axes. IE given two orthogonal unit vectors from the origin, how can I get the variance of a dataset along each of these arbitrary (but orthogonal) axes, such that all the variance is accounted for (ie "eigenvalues" sum to the same as that of PCA).