Re: [R] Help on making code faster-would C help ?

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 21 Jul 2006 - 01:05:43 EST

Without details it is hard to say, but if you do the WLS via lm.wfit, probably not. If you are using lm() and taking the overhead 10000 times, that is the first thing to avoid.

As an example of this sort of thing, look at the C code for lqs{MASS} which does thousands of regressions quite quickly.

On Thu, 20 Jul 2006, Benn Fine wrote:

> Using R on windows....
>
> I have the following code
>
> for(i in 1:10000) {
>
> draw some random weights
>
> perfom a weighted least squares regression
>
> some simple addition and multiplication
> }
>
> The code works fine but is slow.
>
> I have mingw installed and can dyn.load, although I am
> more used to doing this on Unix than Windows.
>
> Would it make sense to re-write the whole thing in
> C ? I am vectorizing the random draws-the speed
> culprit is looping and the matrix manipulations.
>
> My guess is to use the matrix routines from gls-does
> this sound feasible ?
>
> Thanks!
>
> ______________________________________________
> R-help@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
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@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
and provide commented, minimal, self-contained, reproducible code.
Received on Fri Jul 21 01:10:06 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 21 Jul 2006 - 02:20:14 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.