[R] PCA with spearman and kendall correlations
David L Carlson
dcarlson at tamu.edu
Thu Feb 28 15:09:04 CET 2013
Spearman would be easier since you just convert the data to ranks and use
the Pearson correlation:
> set.seed(42)
> x <- data.frame(matrix(sample(1:9, 20, replace=TRUE), 10, 2))
> x
X1 X2
1 9 5
2 9 7
3 3 9
4 8 3
5 6 5
6 5 9
7 7 9
8 2 2
9 6 5
10 7 6
> cor(x)
X1 X2
X1 1.00000000 0.01897427
X2 0.01897427 1.00000000
> cor(x, method="spearman")
X1 X2
X1 1.00000000 -0.03135181
X2 -0.03135181 1.00000000
> cor(sapply(x, rank))
X1 X2
X1 1.00000000 -0.03135181
X2 -0.03135181 1.00000000
----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of BOURGADE Eric
> Sent: Thursday, February 28, 2013 3:50 AM
> To: r-help at r-project.org
> Subject: [R] PCA with spearman and kendall correlations
>
> Hello,
>
> I would like to do a PCA with dudi.pca or PCA, but also with the use of
> Spearman or Kendall correlations
> Is it possible ?
> Otherwise, how can I do, according to you ?
>
> Thanking you in advance
>
> Eric Bourgade
> RTE
> France
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list