To make things more interesting, we rotate the matrix of values by 45 degrees:

Using the eigen and cov functions in R we find:

If we use the E$vectors to rotate the matrix we analyzed (M2), we get:

So, I hope you can see what PCA does. It takes the ellipsoid shape of M2's points, and rotates them so that the maximum variance is along the x axis.

The first eigenvector of the covariance matrix constructed from M2 identifies the direction in which the variance is the maximum, and the first eigenvalue (E$values[1]) is this variance.

Finally, we use R's implementation of principal component analysis:

Notice that the standard deviations match what we started with.

## No comments:

Post a Comment