Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ade4 package - principal component analysis

Tags:

r

pca

I intend to to some principal component analysis and I am using this PCA tutorial as a guide. I have the following code:

library("ade4")
Data <- read.table("D:/Bla/Data1.txt", header = TRUE, sep="\t")    
plot(Data$X, Data$Y)
pc <- dudi.pca(Data, scale = FALSE, scan = FALSE)    
pc$eig

However, I just don't get the some eigen values as the ones in the tutorial. Am I doing something wrong or does dudi.pca have known 'issues'? BTW how do I obtain the eigen vectors?

PS:

I used this data:

X   Y
2.5 2.4
0.5 0.7
2.2 2.9
1.9 2.2
3.1 3
2.3 2.7
2   1.6
1   1.1
1.5 1.6
1.1 0.9

which dudi.pca normalises by substracting the mean.

like image 372
cs0815 Avatar asked Feb 17 '26 09:02

cs0815


1 Answers

In the pdf you linked to, the eigenvalues are obtained via the command:

eigen(cov(Data))

whereas the eigenvalues from dudi.pca (I presume), come from the centred and scaled covariance matrix.

like image 158
csgillespie Avatar answered Feb 21 '26 15:02

csgillespie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!