Principle Component Analysis (PCA)
Posted by admin on Sunday Jul 4, 2010 Under Statistics
Performing a PCA after standardizing the variables and obtain estimates for the principal components for the standardized variables.
Reading in athelete’s data
ath.dat <- read.table("athelete.txt")
Standardizing the data
ath.dat.std <- scale(ath.dat)
Correlation matrix (since covariance of standardized data is correlation)
R = cov(ath.dat.std)
Eigen Values
lambda = eigen(R)$val
Eigen values are read to assess which components explain the variance the most. In this case, the first two show values above 1 therefore we will take the first two components.
[1] 1.0900625 1.0290211 0.8809163
Eigen Vector
es= eigen(R)$vec
[,1] [,2] [,3]
[1,] 0.7476122 -0.1215134 -0.6529246
[2,] -0.2827011 0.8313790 -0.4784235
[3,] 0.6009626 0.5422577 0.5871971
Three eigen vectors associated with the labmda values. The three vectors are eigen vectors of the covariance matrix and also the loadings of Principle components.
You can find the loadings (eigen vectors) by obtaining loadings of the princomp output
loadings(ath.pca)
Loadings:
Comp.1 Comp.2 Comp.3
X1 0.748 -0.122 -0.653
X2 -0.283 0.831 -0.478
X3 0.601 0.542 0.587
July 19th, 2010 at 10:08 AM
Keep posting stuff like this i really like it
July 29th, 2010 at 5:28 PM
it was very interesting to read http://www.soisos.com
I want to quote your post in my blog. It can?
And you et an account on Twitter?
July 29th, 2010 at 6:19 PM
Hello don_t_panic, sure you can quote my post. I will be posting more topics and will also write it more descriptively.
August 2nd, 2010 at 2:52 PM
I would like to exchange links with your site http://www.soisos.com
Is this possible?
August 5th, 2010 at 8:05 PM
Great site. A lot of useful information here. I’m sending it to some friends!
August 6th, 2010 at 12:01 AM
Sure, we can exchange the links.
August 10th, 2010 at 2:17 PM
Genial post and this enter helped me alot in my college assignement. Gratefulness you on your information.