Displaying 1 result from an estimated 1 matches for "bybuiltin".
Did you mean:
builtin
2009 Mar 25
3
very fast OLS regression?
...ator whose input contains a
regression, I do care about speed.
What is the recommended fastest way to get regression coefficients in
R? (Is Gentlemen's weighted-least-squares algorithm implemented in a
low-level C form somewhere? that one was always lightning fast for
me.)
regards,
/ivo
bybuiltin = function( y, x ) coef(lm( y ~ x -1 ));
byhand = function( y, x ) {
xy<-t(x)%*%y;
xxi<- solve(t(x)%*%x)
b<-as.vector(xxi%*%xy)
## I will need these later, too:
## res<-y-as.vector(x%*%b)
## soa[i]<-b[2]
## sigmas[i]<-sd(res)
b;
}
MC=500;
N=10000;
set.seed(0...