When I use the function cancor of mva package, I found that it doesn't work when one of the matrix has only one column, or both have only one column. The function in Splus 5 with the same name works under those situations. The version of R I am using is 0.63.2 (released on Jan., 1999) on Solaris. Kenny Ye Assistant Professor Department of Applied Math and Statistics SUNY at Stony Brook Stony Brook, New York 11794-3600 (516)632 9344 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
bug on cancor (PR#116)
4 messages · Kenny Ye, Peter Dalgaard, Brian Ripley +1 more
kye@ams.sunysb.edu writes:
When I use the function cancor of mva package, I found that it doesn't work when one of the matrix has only one column, or both have only one column. The function in Splus 5 with the same name works under those situations.
Just for those who wondered: I resent the message to R-bugs, making it appear on R-devel for the 2nd time but with a PR#. (Resending - in my mailer at least - leaves the original author as sender, which I think is desirable. It also came out with a double R-devel signature, but that probably can't be helped). This is clearly a bug:
cancor(1:10,1:10)
Error in qr.qty(qx, qr.qy(qy, diag(1, nr, dy)))[1:dx, , drop = FALSE] : incorrect number of dimensions Probably a dimension getting dropped somewhere...
O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On 9 Feb 1999, Peter Dalgaard BSA wrote:
kye@ams.sunysb.edu writes:
When I use the function cancor of mva package, I found that it doesn't work when one of the matrix has only one column, or both have only one column. The function in Splus 5 with the same name works under those situations.
Yes, it does, but whether this makes statistical sense is debatable: you are then doing regression in a roundabout way. (Least-squares regression maximizes the correlation of y with a linear combination of the cols of X.)
Just for those who wondered: I resent the message to R-bugs, making it appear on R-devel for the 2nd time but with a PR#. (Resending - in my mailer at least - leaves the original author as sender, which I think is desirable. It also came out with a double R-devel signature, but that probably can't be helped). This is clearly a bug:
cancor(1:10,1:10)
Error in qr.qty(qx, qr.qy(qy, diag(1, nr, dy)))[1:dx, , drop = FALSE] : incorrect number of dimensions Probably a dimension getting dropped somewhere...
Nope. As someone who has suffered here before, I saw it is that pesky
mat.or.vec construction that someone in R likes to use. Function
qr.qr returns a vector when given an n x 1 y, by design. So
qr.qy(qy, diag(1, nr, dy))
qr.qty(qx, qr.qy(qy, diag(1, nr, dy)))
are vectors. So this is an R design decision.
To work around this in cancor, use
zz <- qr.qty(qx, qr.qy(qy, diag(1, nr, dy)))
z <- svd(as.matrix(zz)[1:dx, , drop=FALSE], dx, dy)
BTW, the help page for qr.qy says the value is
Value:
The QR decomposition of the matrix as computed by LIN-
PACK. The components in the returned value correspond
directly to the values returned by DQRDC.
which is nonsense for 8 of the 9 functions documented on that page.
I was using 0.63.2, in case anything has been altered since.
It may be too late to change this design decision (I know of quite a few
workarounds in other code) but it will come back to haunt users. At least
it could be documented!
Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
In the ``release-patch'' aka 0.63.3 version, the functions
qr.xxx *have* changed about 10 days ago.
NEWS has
o backsolve(), qr.solve... now return a vector when x (or y) is a vector.
In today's snapshot,
> library(mva)
> str(cancor(1:9,c(1:4,6:10)))
List of 5
$ cor : num 0.997
$ xcoef : num 0.129
$ ycoef : num 0.110
$ xcenter: num 5
$ ycenter: num 5.56
However,
I'm not sure if this addresses all issues (apart from docu)
that Prof Ripley has addressed.
Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._