Message-ID: <B4EC3857.2311%pflugshaupt@geobot.umnw.ethz.ch>
Date: 2000-03-08T16:03:19Z
From: Kaspar Pflugshaupt
Subject: canonical variates
In-Reply-To: <Pine.LNX.4.10.10003081629430.5153-100000@carbon.foodsci.unibo.it>
> 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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._