Problem 1: Principal Component Analysis

Upload the file DECATHLON.txt into your R-workspace. The file contains the results of 48 decathletes from 1973. Familiarize yourself with the data and perform the covariance matrix based PCA transformation. Conduct the analysis without the variables: points, height and weight.

a) Familiarize yourself with the function princomp. Visualize the original data.

DATA <- read.table("DECATHLON.txt",header=TRUE,sep="\t",row.names=1)
DEC <- DATA[,-c(1,12,13)]
# Look at your data
str(DEC)
## 'data.frame':    48 obs. of  10 variables:
##  $ R100m       : int  853 853 879 826 879 905 879 853 804 853 ...
##  $ Long_jump   : int  931 853 951 931 840 859 848 828 848 830 ...
##  $ Shot_put    : int  725 814 799 793 924 647 785 772 795 815 ...
##  $ High_jump   : int  857 769 779 865 857 779 804 751 831 822 ...
##  $ R400m       : int  838 833 838 875 788 938 766 838 819 784 ...
##  $ Hurdles     : int  903 914 881 891 892 859 807 987 837 817 ...
##  $ Discus_throw: int  772 855 819 729 866 651 897 748 801 762 ...
##  $ Pole_vault  : int  981 884 1028 909 920 1028 909 960 884 859 ...
##  $ Javelin     : int  818 975 758 774 671 794 820 755 755 848 ...
##  $ R1500m      : int  528 438 408 543 497 661 585 528 642 587 ...
head(DEC)
##          R100m Long_jump Shot_put High_jump R400m Hurdles Discus_throw
## Skowrone   853       931      725       857   838     903          772
## Hedmark    853       853      814       769   833     914          855
## Le_Roy     879       951      799       779   838     881          819
## Zeilbaue   826       931      793       865   875     891          729
## Zigert     879       840      924       857   788     892          866
## Bennett    905       859      647       779   938     859          651
##          Pole_vault Javelin R1500m
## Skowrone        981     818    528
## Hedmark         884     975    438
## Le_Roy         1028     758    408
## Zeilbaue        909     774    543
## Zigert          920     671    497
## Bennett        1028     794    661
# Pairwise scatterplots
pairs(DEC)

# A way to plot two specific variables with the names of the athletes:
plot(DEC$R100m,DEC$R400m,xlab="Running 100m",ylab="Running 400m",type="n")
text(DEC$R100m,DEC$R400m,labels=rownames(DEC))


PC transformation can be applied with function princomp(), for example:
DEC.PCA <- princomp(DEC,cor=FALSE)
names(DEC.PCA)
## [1] "sdev"     "loadings" "center"   "scale"    "n.obs"    "scores"  
## [7] "call"
DEC.PCA$call # input of the function
## princomp(x = DEC, cor = FALSE)
DEC.PCA$scores # Y from lecture slides
##               Comp.1      Comp.2       Comp.3       Comp.4      Comp.5
## Skowrone   33.649901   32.808427    5.2886457 -129.0208027  -41.734435
## Hedmark   180.868056   25.217866  136.4300139 -105.5608514  103.258919
## Le_Roy    133.069947  141.825923  -66.6008641 -116.8956376   22.224933
## Zeilbaue   30.670328   16.854746   35.1390736  -46.6399307  -69.713661
## Zigert    189.557080   56.417797  -77.9969270   95.5571297  -22.944726
## Bennett  -203.443609   75.848749    0.4713267 -101.0129974    8.417874
## Blinjaje   92.413773  -24.426171   13.3033149    5.4286624   92.887351
## Katus      14.879012  105.836592  -10.9949468  -13.3745950  -16.187153
## Berendse    4.515914  -58.539571   10.6670403   56.1495486    7.579270
## Gorbacho   45.113032  -58.370301   62.2392843    9.9107469   56.875759
## Kiseljev  100.508744   19.931174   68.5865406   17.4971761 -113.176377
## Gough     180.981194  -41.268166   73.7416884   -4.1665372  -29.556240
## Sherbati -171.057639   -2.637601   31.5708399  -79.3600805  -84.722336
## Ghesquir   -2.140249 -108.164554   89.9591623   76.2276797   31.473032
## Avilov     35.728560 -121.915594  -24.6227813  -40.0926079  -94.895068
## Kratky    -44.403111   40.575033   31.8078509   34.5584000  -75.024067
## Schreyer  120.735186   42.618843    3.9937289  -17.8499498   -3.037098
## Linkmann  122.632315  162.459501  -46.5348113   14.2853701  -69.350700
## Thiemig    29.147028   99.467719  -19.9289337   79.6064966  -17.013862
## Pernica  -144.224324  -39.059689  -50.9349420   11.2267542  -36.599442
## Stroot   -100.225157  103.295508   92.3951316   12.9826902  -35.995411
## Bugay     -80.262405  -83.508119   -1.1157560   70.8816149 -101.442206
## Evans      80.562306 -157.047774   -5.6759346   -7.7532999    7.584326
## Tselnoko   -1.370384  -16.354897  122.5735660  -13.3030472  133.641318
## Ivanov     31.493805  -83.777708    4.5937035  -73.3621618  -39.539805
## Janczenk  143.702344   -2.569812  -25.1555609  -95.3555913   19.436243
## Demmig     10.359196  163.094183   63.5250713   79.8415545  -10.182445
## Schulze    19.536612  127.586014   -4.2933620   31.8518444   53.323554
## Andres   -193.289781    5.586002  -18.8853391  -31.8163837  -16.968649
## George   -215.718610  -23.411485    5.4942904  -14.9393725  -27.765324
## Jenner     34.346510  -56.767756   26.6323748   28.3408000  -31.892061
## Swoboda   -65.564040  -34.598567   71.3805181  -19.3232800   60.973453
## Apt       -26.177480   49.896709 -110.0227030   40.7153199   43.959609
## Herbrand   39.180881  -11.866167  -37.7595106    0.8353729  -96.220728
## Tregubje  -35.510095  -47.500071  -86.0636743  -34.3689573   38.763452
## Jachmien   81.948567 -133.542466  -20.2292926   58.6734843  -16.441865
## Pold       -1.646454  -30.609775  -35.8978341  123.6723476    3.516609
## Nikitin  -100.171947   73.513328   51.9082503  113.8918338   -6.995260
## Kozakiew -171.350974  -46.614022 -129.5547331  -65.4092692   52.981960
## Ormanov   -36.724014   99.250770  -75.8672593  121.4797263   56.812601
## Brigham   113.758422 -142.333791 -190.0251484  -28.2624881   27.136831
## Hoischen  -33.222852 -171.780493   31.4075023  -22.4511822   -3.846543
## Wanamake  -20.216951  -61.152960   95.3860010   29.7883812  -37.638274
## Novik      89.313465   12.094859  -45.2362397  -33.7027409  -12.245488
## Samara    -73.917027  149.241244  -42.5969776  -76.4463412   17.947691
## Bogdan   -155.309907  -36.329477   12.8376262   10.5781313   77.025939
## Schoebel  -64.278896   26.117640   31.9736645  -51.3668140   70.660574
## Dzhurov   -18.446272  -35.391636  -47.3126791   97.8538540  124.647927
##              Comp.6     Comp.7       Comp.8     Comp.9    Comp.10
## Skowrone -57.396291  40.260109  -4.41148864  21.329168   3.937407
## Hedmark  -36.358811  14.377536  86.01444102   1.802938 -23.795102
## Le_Roy   -60.439147  15.722990 -45.06362839 -10.474568 -29.040083
## Zeilbaue -67.069557  42.253783 -37.91640561 -55.128784 -14.342753
## Zigert   -80.986313  57.079453  -8.27158313 -18.848344  39.267980
## Bennett  -34.760534 100.605488  24.89609127  -5.119935   1.514836
## Blinjaje -41.408231  55.421256 -19.81268522  94.596741  61.836256
## Katus    -73.078281 -25.046827  96.61605493 -10.686204 -15.458655
## Berendse -74.216824  40.672280 -25.11008200  21.773211  15.945622
## Gorbacho -14.463288  33.502395   6.61366229 -28.390454  67.232042
## Kiseljev  20.526035  -7.058485  18.95667560 -38.882920  56.153055
## Gough    -55.059212 -70.607675 -63.50946601  46.476246 -29.608973
## Sherbati  -5.876393   6.401175  10.72991824 -20.485390  48.614631
## Ghesquir -48.465236  24.514796 -10.13104247  27.776591 -34.394739
## Avilov   -36.148197 -10.888177   4.97736141   6.526918 -36.303126
## Kratky   -42.788677 -30.103180 -46.33072960   3.565899  -1.776826
## Schreyer   8.193975 -36.522603  -8.40179094   1.632258  16.635084
## Linkmann  18.127225 -44.496182  22.54100922  16.270376  -3.497789
## Thiemig   47.743364  70.122801  25.09557819  10.858578 -39.067850
## Pernica  -30.402864  13.980046  36.62659997  29.558920  13.925223
## Stroot    56.579955  31.871202 -44.33952541  36.411320   2.991786
## Bugay     -2.630807  47.057830  16.22759568  20.948578 -21.827931
## Evans     46.289173  56.597806  11.60871213 -16.180456 -19.541631
## Tselnoko  32.718911  10.409502 -10.87909726 -27.985105   3.865344
## Ivanov    47.099231  -3.720620  82.51455824 -20.571416 -11.043427
## Janczenk 116.948376  64.725122 -96.84893028 -48.195267 -19.383498
## Demmig    10.929477 -22.922308  28.62935518 -25.561679 -36.655624
## Schulze   13.082439 -17.916414  27.21280453 -15.073269   3.504971
## Andres    12.733753  29.256204   3.44883038  32.964142 -26.069748
## George   -40.905007 -19.475868 -18.50238650 -15.475682 -16.419807
## Jenner    38.169820   1.092813   3.99421102  24.757531  -8.478420
## Swoboda   36.692432  -7.319653 -14.46871315   3.738978  46.389907
## Apt      -26.679940 -15.572663   0.03371406  -7.475592  -5.751801
## Herbrand   5.065377 -72.423566 -11.82652795  -9.779355  36.128541
## Tregubje -47.470547 -72.187746 -18.04330444   5.019980  15.048463
## Jachmien  44.373014  10.980139 -40.09801433   7.053220  -8.185110
## Pold      30.852722  10.659866  48.50640242  22.318152  11.496751
## Nikitin   48.036285  19.909418 -50.39672605 -62.976910  21.250453
## Kozakiew   8.652937  23.480930  -8.00119807 -23.049201 -19.364723
## Ormanov   42.734613  29.398545  40.16216559  15.660002  -2.020040
## Brigham   44.140246  13.011981  -0.67050099   3.636003  -5.045304
## Hoischen  25.886367 -62.824806  67.88116670 -13.039912  40.620848
## Wanamake  35.664883 -41.672744 -33.05642671  20.204290 -64.529948
## Novik     68.691666 -56.561370  35.52778981 -19.190129   8.306578
## Samara    76.781990 -63.786479 -59.03598005  68.708452  35.946110
## Bogdan   -51.684531 -76.977058 -47.65730382 -36.382196  -1.189538
## Schoebel  55.701408 -49.389365  44.49491436  29.779648 -32.599551
## Dzhurov  -64.126985 -55.891677 -20.52607520 -44.415371 -25.219892
DEC.PCA$n.obs # number of observations
## [1] 48
DEC.PCA$scale # Relevant when cor=TRUE (The scalings applied to each variable)
##        R100m    Long_jump     Shot_put    High_jump        R400m 
##            1            1            1            1            1 
##      Hurdles Discus_throw   Pole_vault      Javelin       R1500m 
##            1            1            1            1            1
DEC.PCA$center # The sample mean 
##        R100m    Long_jump     Shot_put    High_jump        R400m 
##     828.1875     840.1875     740.7708     805.8542     813.5000 
##      Hurdles Discus_throw   Pole_vault      Javelin       R1500m 
##     852.8750     747.4583     900.2708     760.0208     554.6250
colMeans(DEC) # Same as above
##        R100m    Long_jump     Shot_put    High_jump        R400m 
##     828.1875     840.1875     740.7708     805.8542     813.5000 
##      Hurdles Discus_throw   Pole_vault      Javelin       R1500m 
##     852.8750     747.4583     900.2708     760.0208     554.6250
DEC.PCA$loadings #matrix of eigenvectors (G-matrix) (columns are eigenvectors) (Small loadings are not printed due to visibility)
## 
## Loadings:
##              Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8
## R100m                0.606  0.135                0.255  0.415       
## Long_jump            0.175  0.220 -0.416 -0.234 -0.377 -0.176 -0.712
## Shot_put      0.462                0.340  0.183 -0.471  0.147       
## High_jump     0.233 -0.456 -0.113 -0.150 -0.649  0.132  0.494       
## R400m        -0.228  0.276  0.277               -0.111  0.573       
## Hurdles              0.321  0.184        -0.510 -0.395 -0.264  0.598
## Discus_throw  0.516                0.155  0.214 -0.226  0.211       
## Pole_vault   -0.139  0.145 -0.704 -0.511  0.177 -0.321  0.201  0.168
## Javelin       0.116 -0.305  0.546 -0.566  0.385         0.102  0.318
## R1500m       -0.609 -0.317  0.125  0.285        -0.479  0.193       
##              Comp.9 Comp.10
## R100m                0.605 
## Long_jump                  
## Shot_put     -0.598  0.187 
## High_jump            0.136 
## R400m        -0.175 -0.647 
## Hurdles       0.107        
## Discus_throw  0.731 -0.170 
## Pole_vault                 
## Javelin              0.102 
## R1500m        0.230  0.334 
## 
##                Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8
## SS loadings       1.0    1.0    1.0    1.0    1.0    1.0    1.0    1.0
## Proportion Var    0.1    0.1    0.1    0.1    0.1    0.1    0.1    0.1
## Cumulative Var    0.1    0.2    0.3    0.4    0.5    0.6    0.7    0.8
##                Comp.9 Comp.10
## SS loadings       1.0     1.0
## Proportion Var    0.1     0.1
## Cumulative Var    0.9     1.0
DEC.PCA$loadings[1,1] #How to access a single value from G
## [1] 0.01446843
DEC.PCA$sdev # The standard deviation of the principal components
##    Comp.1    Comp.2    Comp.3    Comp.4    Comp.5    Comp.6    Comp.7 
## 102.99508  83.83611  63.99022  63.48050  58.06222  47.35445  43.07928 
##    Comp.8    Comp.9   Comp.10 
##  39.76028  30.35520  28.98388
plot(DEC.PCA, las = 2) # Plots the variances of the principal components

(DEC.PCA$sdev)^2
##     Comp.1     Comp.2     Comp.3     Comp.4     Comp.5     Comp.6 
## 10607.9857  7028.4941  4094.7482  4029.7738  3371.2209  2242.4437 
##     Comp.7     Comp.8     Comp.9    Comp.10 
##  1855.8241  1580.8802   921.4380   840.0655
# Note that the variances of the principal components are equal to the eigenvalues
# of the covariance matrix of the original data matrix

n <- nrow(DEC)
DEC_cov <- (n-1)/n*cov(DEC)

# Note that the princomp package uses the maximum likelihood estimator
# of the covariance matrix (1/n divisor instead of 1/(n-1))

DEC_cov_eval <- eigen(DEC_cov)$values
DEC_cov_eval
##  [1] 10607.9857  7028.4941  4094.7482  4029.7738  3371.2209  2242.4437
##  [7]  1855.8241  1580.8802   921.4380   840.0655
(DEC.PCA$sdev)^2 #Same values as above
##     Comp.1     Comp.2     Comp.3     Comp.4     Comp.5     Comp.6 
## 10607.9857  7028.4941  4094.7482  4029.7738  3371.2209  2242.4437 
##     Comp.7     Comp.8     Comp.9    Comp.10 
##  1855.8241  1580.8802   921.4380   840.0655

b) How much of the variation of the original data is explained by k principal components, where k = 1,2,…,10.

summary(DEC.PCA)
## Importance of components:
##                             Comp.1     Comp.2     Comp.3     Comp.4
## Standard deviation     102.9950759 83.8361146 63.9902194 63.4804991
## Proportion of Variance   0.2900506  0.1921778  0.1119613  0.1101848
## Cumulative Proportion    0.2900506  0.4822284  0.5941898  0.7043745
##                             Comp.5     Comp.6      Comp.7      Comp.8
## Standard deviation     58.06221588 47.3544471 43.07927681 39.76028470
## Proportion of Variance  0.09217818  0.0613144  0.05074318  0.04322549
## Cumulative Proportion   0.79655273  0.8578671  0.90861031  0.95183579
##                             Comp.9     Comp.10
## Standard deviation     30.35519704 28.98388394
## Proportion of Variance  0.02519457  0.02296963
## Cumulative Proportion   0.97703037  1.00000000
sum(DEC_cov_eval[1:4])/sum(DEC_cov_eval) 
## [1] 0.7043745
# Approx 70% of the variation explained with 4 principal components
# One (more) way of visualizing this
plot(cumsum(DEC.PCA$sdev^2 / sum(DEC.PCA$sdev^2)), type = 'b', pch = 21, lty = 3, bg = 2, cex = 1.5, ylim = c(0,1),
     xlab = 'Principal component', ylab = 'Cumulative proportion of variance explained', xaxt = 'n', yaxt = 'n')
axis(1, at = 1:10, tck = 0.025)
axis(2, at = 0:10 / 10, tck = 0.025, las = 2)
abline(0,1/10, lty = 3)


c) Choose a sufficient amount of principal components and try to interpret them. Visualize the scores of the observations with respect to the first two principal components.

# PC visualization (Similar plot than biplot.princomp would achieve)
PC1PC2 <- DEC.PCA$scores[,1:2]
LD1LD2 <- DEC.PCA$loadings[,1:2]
pc.axis <- c(-max(abs(PC1PC2)),max(abs(PC1PC2)))
ld.axis <- c(-0.8,0.8)

plot(PC1PC2, xlim = pc.axis, ylim = pc.axis, pch = 21, bg = 8, cex = 1.25)
par(new = T)
plot(LD1LD2, axes = F, type = 'n', xlab = '', ylab = '', xlim = ld.axis, ylim = ld.axis)
axis(3, col = 2, tck = 0.025)
axis(4, col = 2, tck = 0.025)
arrows(0,0,LD1LD2[,1], LD1LD2[,2], length = 0.1, col = 2)
text(LD1LD2[,1], LD1LD2[,2], rownames(LD1LD2), pos = 3)
abline(h = 0, lty = 3)
abline(v = 0, lty = 3)

print(DEC.PCA$loadings) # Note the different scales in the axes
## 
## Loadings:
##              Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8
## R100m                0.606  0.135                0.255  0.415       
## Long_jump            0.175  0.220 -0.416 -0.234 -0.377 -0.176 -0.712
## Shot_put      0.462                0.340  0.183 -0.471  0.147       
## High_jump     0.233 -0.456 -0.113 -0.150 -0.649  0.132  0.494       
## R400m        -0.228  0.276  0.277               -0.111  0.573       
## Hurdles              0.321  0.184        -0.510 -0.395 -0.264  0.598
## Discus_throw  0.516                0.155  0.214 -0.226  0.211       
## Pole_vault   -0.139  0.145 -0.704 -0.511  0.177 -0.321  0.201  0.168
## Javelin       0.116 -0.305  0.546 -0.566  0.385         0.102  0.318
## R1500m       -0.609 -0.317  0.125  0.285        -0.479  0.193       
##              Comp.9 Comp.10
## R100m                0.605 
## Long_jump                  
## Shot_put     -0.598  0.187 
## High_jump            0.136 
## R400m        -0.175 -0.647 
## Hurdles       0.107        
## Discus_throw  0.731 -0.170 
## Pole_vault                 
## Javelin              0.102 
## R1500m        0.230  0.334 
## 
##                Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8
## SS loadings       1.0    1.0    1.0    1.0    1.0    1.0    1.0    1.0
## Proportion Var    0.1    0.1    0.1    0.1    0.1    0.1    0.1    0.1
## Cumulative Var    0.1    0.2    0.3    0.4    0.5    0.6    0.7    0.8
##                Comp.9 Comp.10
## SS loadings       1.0     1.0
## Proportion Var    0.1     0.1
## Cumulative Var    0.9     1.0
# PC visualization (Similar plot than biplot.princomp would achieve)
normalize <- function(x){(x - min(x)) / (max(x) - min(x))} # Normalize from zero to one
PC1PC2 <- DEC.PCA$scores[,1:2]
LD1LD2 <- DEC.PCA$loadings[,1:2]
pc.axis <- c(-max(abs(PC1PC2)),max(abs(PC1PC2)))
ld.axis <- c(-0.8,0.8)

plot(PC1PC2, xlim = pc.axis, ylim = pc.axis, pch = 21, bg = 8, cex = normalize(DEC$Shot_put) + 0.5,
     main = 'Point size scaled with Shot put performance')
par(new = T)
plot(LD1LD2, axes = F, type = 'n', xlab = '', ylab = '', xlim = ld.axis, ylim = ld.axis)
axis(3, col = 2, tck = 0.025)
axis(4, col = 2, tck = 0.025)
arrows(0,0,LD1LD2[,1], LD1LD2[,2], length = 0.1, col = 2)
text(LD1LD2[,1], LD1LD2[,2], rownames(LD1LD2), pos = 3, col = 1)
abline(h = 0, lty = 3)
abline(v = 0, lty = 3)

print(DEC.PCA$loadings) # Note the different scales in the axes
## 
## Loadings:
##              Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8
## R100m                0.606  0.135                0.255  0.415       
## Long_jump            0.175  0.220 -0.416 -0.234 -0.377 -0.176 -0.712
## Shot_put      0.462                0.340  0.183 -0.471  0.147       
## High_jump     0.233 -0.456 -0.113 -0.150 -0.649  0.132  0.494       
## R400m        -0.228  0.276  0.277               -0.111  0.573       
## Hurdles              0.321  0.184        -0.510 -0.395 -0.264  0.598
## Discus_throw  0.516                0.155  0.214 -0.226  0.211       
## Pole_vault   -0.139  0.145 -0.704 -0.511  0.177 -0.321  0.201  0.168
## Javelin       0.116 -0.305  0.546 -0.566  0.385         0.102  0.318
## R1500m       -0.609 -0.317  0.125  0.285        -0.479  0.193       
##              Comp.9 Comp.10
## R100m                0.605 
## Long_jump                  
## Shot_put     -0.598  0.187 
## High_jump            0.136 
## R400m        -0.175 -0.647 
## Hurdles       0.107        
## Discus_throw  0.731 -0.170 
## Pole_vault                 
## Javelin              0.102 
## R1500m        0.230  0.334 
## 
##                Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8
## SS loadings       1.0    1.0    1.0    1.0    1.0    1.0    1.0    1.0
## Proportion Var    0.1    0.1    0.1    0.1    0.1    0.1    0.1    0.1
## Cumulative Var    0.1    0.2    0.3    0.4    0.5    0.6    0.7    0.8
##                Comp.9 Comp.10
## SS loadings       1.0     1.0
## Proportion Var    0.1     0.1
## Cumulative Var    0.9     1.0

d) Calculate the sample mean and covariance matrix from the score matrix.

cov(DEC.PCA$scores) # Diagonal, as expected
##                Comp.1        Comp.2        Comp.3        Comp.4
## Comp.1   1.083369e+04  1.471364e-13 -2.996675e-12 -7.282331e-13
## Comp.2   1.471364e-13  7.178037e+03 -2.960781e-12 -5.793002e-13
## Comp.3  -2.996675e-12 -2.960781e-12  4.181870e+03  8.373727e-13
## Comp.4  -7.282331e-13 -5.793002e-13  8.373727e-13  4.115514e+03
## Comp.5  -3.361141e-13 -5.237796e-13  2.226597e-12  3.544588e-13
## Comp.6   9.690688e-13 -1.076066e-13  2.905510e-12  1.973835e-14
## Comp.7   6.218761e-13 -7.136372e-14 -2.373988e-12  3.343330e-13
## Comp.8   4.267561e-13  3.816309e-13 -2.377885e-13  1.565140e-12
## Comp.9  -2.542995e-12  6.417089e-13 -5.912764e-13  1.305169e-12
## Comp.10 -1.232832e-12  3.569219e-12  1.569265e-12  3.722318e-14
##                Comp.5        Comp.6        Comp.7        Comp.8
## Comp.1  -3.361141e-13  9.690688e-13  6.218761e-13  4.267561e-13
## Comp.2  -5.237796e-13 -1.076066e-13 -7.136372e-14  3.816309e-13
## Comp.3   2.226597e-12  2.905510e-12 -2.373988e-12 -2.377885e-13
## Comp.4   3.544588e-13  1.973835e-14  3.343330e-13  1.565140e-12
## Comp.5   3.442949e+03 -2.906800e-13 -1.599666e-12  7.263551e-13
## Comp.6  -2.906800e-13  2.290155e+03  1.444584e-12  2.506600e-13
## Comp.7  -1.599666e-12  1.444584e-12  1.895310e+03  5.529572e-13
## Comp.8   7.263551e-13  2.506600e-13  5.529572e-13  1.614516e+03
## Comp.9   2.717089e-12 -1.087475e-12  6.815636e-13 -1.944827e-13
## Comp.10  4.511899e-13 -2.992051e-13 -2.996161e-13  4.243709e-13
##                Comp.9       Comp.10
## Comp.1  -2.542995e-12 -1.232832e-12
## Comp.2   6.417089e-13  3.569219e-12
## Comp.3  -5.912764e-13  1.569265e-12
## Comp.4   1.305169e-12  3.722318e-14
## Comp.5   2.717089e-12  4.511899e-13
## Comp.6  -1.087475e-12 -2.992051e-13
## Comp.7   6.815636e-13 -2.996161e-13
## Comp.8  -1.944827e-13  4.243709e-13
## Comp.9   9.410431e+02  7.000877e-13
## Comp.10  7.000877e-13  8.579393e+02
(n-1)/n*diag(cov(DEC.PCA$scores)) # The diagonal elements are equal to the variances of the principal components
##     Comp.1     Comp.2     Comp.3     Comp.4     Comp.5     Comp.6 
## 10607.9857  7028.4941  4094.7482  4029.7738  3371.2209  2242.4437 
##     Comp.7     Comp.8     Comp.9    Comp.10 
##  1855.8241  1580.8802   921.4380   840.0655
colMeans(DEC.PCA$scores) # Zero as expected
##        Comp.1        Comp.2        Comp.3        Comp.4        Comp.5 
##  8.028300e-14 -3.226123e-14 -1.995279e-14 -4.972411e-14  4.770258e-14 
##        Comp.6        Comp.7        Comp.8        Comp.9       Comp.10 
## -7.685519e-14  6.969888e-14  3.053547e-14  6.059967e-15  1.337819e-14