I need some help, would you please use the R to answer the question for me? # 1)
ID: 3075056 • Letter: I
Question
I need some help, would you please use the R to answer the question for me? # 1) Suppose our multivariate data have covariance matrix S = [5 0 0 0 9 0 0 0 9] a) Find the eigenvalues and eigenvectors of S. HINT: You can use the 'eigen' function in R, e.g.: eigen(M) gives the eigenvalues and eigenvectors of some matrix M. b) Determine all three principal components for such a data set, using a PCA based on S. Remember that a principal component is a linear combination of the original variables, so your answer should be in the form of linear combinations of X1, X2, and X3. c) What can you say about the principal components associated with eigenvalues that are the same value?
Explanation / Answer
> S = cbind( c(5 ,0,0), c(0,9,0), c(0,0,9))
> S
[,1] [,2] [,3]
[1,] 5 0 0
[2,] 0 9 0
[3,] 0 0 9
> eigen (S)
eigen() decomposition
$values
[1] 9 9 5
$vectors
[,1] [,2] [,3]
[1,] 0 0 1
[2,] 0 1 0
[3,] 1 0 0
b)
pcaData <- prcomp(S , center = FALSE, scale.= FALSE)
> pcaData
Standard deviations (1, .., p=3):
[1] 6.363961 6.363961 3.535534
Rotation (n x k) = (3 x 3):
PC1 PC2 PC3
[1,] 0 0 1
[2,] 1 0 0
[3,] 0 1 0