heptathlon=matrix(c(12.69,12.85,13.20,13.61,13.51,13.75,13.38,13.55,13.63,13.25,13.75,13.24,13.85,13.71,13.79,13.93,13.47,14.07,14.39,14.04,14.31,14.23,14.85,14.53,16.42,1.86,1.80,1.83,1.80,1.74,1.83,1.80,1.80,1.83,1.77,1.86,1.80,1.86,1.83,1.80,1.86,1.80,1.83,1.71,1.77,1.77,1.71,1.68,1.71,1.50,15.80,16.23,14.20,15.23,14.76,13.50,12.88,14.13,14.28,12.62,13.01,12.88,11.58,13.16,12.32,14.21,12.75,12.69,12.68,11.81,11.66,12.95,10,10.83,11.78,22.56,23.65,23.10,23.92,23.93,24.65,23.59,24.48,24.86,23.59,25.03,23.59,24.87,24.78,24.61,25,25.47,24.83,24.92,25.61,25.69,25.50,25.23,26.61,26.16,7.27,6.71,6.68,6.25,6.32,6.33,6.37,6.47,6.11,6.28,6.34,6.37,6.05,6.12,6.08,6.40,6.34,6.13,6.10,5.99,5.75,5.50,5.47,5.50,4.88,45.66,42.56,44.54,42.78,47.46,42.82,40.28,38,42.20,39.06,37.86,40.28,47.50,44.58,45.44,38.60,35.76,44.34,37.76,35.68,39.48,39.64,39.14,39.26,46.33,128.51,126.12,124.20,132.24,127.90,125.79,132.54,133.65,136.05,134.74,131.49,132.54,134.93,142.82,137.06,146.67,138.48,146.43,138.02,133.90,133.35,144.02,137.30,139.17,163.43,7291,6897,6858,6540,6540,6411,6351,6297,6252,6252,6205,6171,6137,6109,6101,6087,5975,5972,5746,5734,5686,5508,5290,5289,4566),25,8)
colnames(heptathlon)=c("hurdles","highjump","shot","run200m","longjump","javelin","run800m","score")
heptathlon
score <- which(colnames(heptathlon) == "score")
round(cor(heptathlon[,-score]), 2)
pairs(heptathlon[,-score])
heptathlon <- matrix(c(12.69,12.85,13.20,13.61,13.51,13.75,13.38,13.55,13.63,13.25,13.75,13.24,13.85,13.71,13.79,13.93,13.47,14.07,14.39,14.04,14.31,14.23,14.85,14.53,1.86,1.80,1.83,1.80,1.74,1.83,1.80,1.80,1.83,1.77,1.86,1.80,1.86,1.83,1.80,1.86,1.80,1.83,1.71,1.77,1.77,1.71,1.68,1.71,15.80,16.23,14.20,15.23,14.76,13.50,12.88,14.13,14.28,12.62,13.01,12.88,11.58,13.16,12.32,14.21,12.75,12.69,12.68,11.81,11.66,12.95,10,10.83,22.56,23.65,23.10,23.92,23.93,24.65,23.59,24.48,24.86,23.59,25.03,23.59,24.87,24.78,24.61,25,25.47,24.83,24.92,25.61,25.69,25.50,25.23,26.61,7.27,6.71,6.68,6.25,6.32,6.33,6.37,6.47,6.11,6.28,6.34,6.37,6.05,6.12,6.08,6.40,6.34,6.13,6.10,5.99,5.75,5.50,5.47,5.50,45.66,42.56,44.54,42.78,47.46,42.82,40.28,38,42.20,39.06,37.86,40.28,47.50,44.58,45.44,38.60,35.76,44.34,37.76,35.68,39.48,39.64,39.14,39.26,128.51,126.12,124.20,132.24,127.90,125.79,132.54,133.65,136.05,134.74,131.49,132.54,134.93,142.82,137.06,146.67,138.48,146.43,138.02,133.90,133.35,144.02,137.30,139.17,7291,6897,6858,6540,6540,6411,6351,6297,6252,6252,6205,6171,6137,6109,6101,6087,5975,5972,5746,5734,5686,5508,5290,5289),24,8)
colnames(heptathlon)=c("hurdles","highjump","shot","run200m","longjump","javelin","run800m","score")
heptathlon
score <- which(colnames(heptathlon) == "score")
round(cor(heptathlon[,-score]), 2)
heptathlon_pca <- prcomp(heptathlon[, -score], scale = TRUE)
print(heptathlon_pca)
pairs(heptathlon[,-score],pch=".",cex=1.5)
summary(heptathlon_pca)
a1 <- heptathlon_pca$rotation[,1]
a1
colMeans(heptathlon)
cov(heptathlon)
center <- heptathlon_pca$center
scale <- heptathlon_pca$scale
hm <- as.matrix(heptathlon[,-score])
hm
drop(scale(hm, center = center, scale = scale) %*%
 heptathlon_pca$rotation[,1])
predict(heptathlon_pca)[,1]
plot(heptathlon_pca)
hm1 <- as.matrix(heptathlon)
cor(hm1[,8],heptathlon_pca$x[,1])
plot(hm1[,8],heptathlon_pca$x[,1])

