[R] quadratic form
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Thu Nov 3 17:30:08 CET 2005
Peter Dalgaard <p.dalgaard at biostat.ku.dk> writes:
> Alvarez Pedro <palvarez7777 at yahoo.es> writes:
>
> > On page 22 of the R-introduction guide it's written:
> >
> > the quadratic form x^{'} A^{-1} x which is used in
> > multivariate computations, should be computed by
> > something like x%*%solve(A,x), rather than computing
> > the inverse of A.
> >
> > Why isn't it good to compute t(x) %*% solve(A) %*% x?
>
> It's just a waste of CPU time. For k x k matrices, solution of Ax=b is
> of computational complexity O(k^2) whereas inversion of A is O(k^3).
> This is obviously more important for k=1000 than for k=5.
Erm, Thomas Lumley points out that solution of Ax=b is also of order
k^3 ingeneral (R uses a QR decomposition). So it's just the multiplier
that differs. The savings should still be on the order of k^3 though.
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list