[R] quadratic form
Liaw, Andy
andy_liaw at merck.com
Thu Nov 3 18:27:46 CET 2005
If you meant QR vs. inverting X'X for linear regression, the motivation for
using QR is not speed, but numerical stability. There's no univerally good
least squares algorithm that would be uniformly better than anything else
for any kind of data.
Andy
> From: Jari Oksanen
>
>
> On 3 Nov 2005, at 17:25, Robin Hankin wrote:
>
> > Hi Alvarez
> >
> >
> > If you define
> >
> > quad.form.inv <- function (M, x)
> > {
> > drop(crossprod(x, solve(M, x)))
> > }
> >
> > then you will avoid an expensive call to %*% as well.
> >
> Is %*% really expensive in all platforms? I had a function
> that used QR
> decomposition instead of quadratic forms, but then I got a
> message from
> Canada suggesting that %*% would be faster. Indeed, it was in
> not-too-large data sets and in Mac (or powerpc). I run some
> tests with
> real applications, and found that my 800MHz iBook G4 run like
> a 2.5GHz
> Intel machine when %*% was used. This really was architecture
> dependent, since the performance boost was similar under OS X
> and Linux
> in the very same PowerPC. So it seems that %*% is very cheap if you
> have PowerPC, but it may be expensive in Intel. (I also run a test in
> Sun, and it was somewhere between Intel and PowerPC.)
>
> cheers, jari oksanen
> --
> Jari Oksanen, Oulu, Finland
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
More information about the R-help
mailing list