Hi everybody, this is my first post on this list, and I would like to thank the people who made R freely available on the net. I am looking for R code to perform canonical variates analysis on a matrix of data. Has anybody already developed such a code? Is it available somewhere? Thank you for your help. Mauro ------------------------------------------- Mauro Andrea Cremonini, Ph.D. Food Science and Technology Laboratory University of Bologna Via Ravennate 1020 - 47023 - Cesena - Italy Phone: +39.0547.636106 FAX: +39.0547.382348 e-mail: mac at foodsci.unibo.it ------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
canonical variates
2 messages · Mauro Andrea Cremonini, Kaspar Pflugshaupt
I am looking for R code to perform canonical variates analysis on a matrix of data. Has anybody already developed such a code? Is it available somewhere?
Hello Mauro,
there's the function cancor in library mva. Additionally, Brian Ripley
provided his own inplementation lately on this list:
---start quote---
Suppose you have data matrices
A and B on the same observations. Then
cancor <- function(A, B)
{
Ap <- prcomp(scale(A, T, F), retx=T)
Apc <- Ap$x %*% diag(1/Ap$sdev)
Bp <- prcomp(scale(B, T, F), retx=T)
Bpc <- Bp$x %*% diag(1/Bp$sdev)
Sigma <- crossprod(Apc, Bpc)/(nrow(A) - 1)
s <- svd(Sigma, ncol(A), ncol(B))
return(list(cor=s$d, canvar.x=Apc %*% s$u, canvar.y=Bpc %*% s$v))
}
should do the trick. The canonical variates are zero-mean, unit-variance
---end quote---
Cheers
Kaspar
--
Kaspar Pflugshaupt
Geobotanisches Institut
Zuerichbergstr. 38
CH-8044 Zuerich
Tel. ++41 1 632 43 19
Fax ++41 1 632 12 15
mailto:pflugshaupt at geobot.umnw.ethz.ch
privat:pflugshaupt at mails.ch
http://www.geobot.umnw.ethz.ch
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._