Skip to content
Prev 5517 / 10988 Next

[Rcpp-devel] [rcpp-devel] Rcpp Gallery Example fastLm vs R native lm

On 21 March 2013 at 10:55, Hadley Wickham wrote:
| > Should I expect the results to match? Why do fastLmProto and fastLm produce
| > a single fitted parameter (I would expect two)? Why are they different? Am I
| > doing something wrong here, or just being na?ve in my assumptions?
| 
| Hint:
| 
| > coef(lm(y1 ~ x1 - 1, data = anscombe))
|        x1
| 0.7968032

Also the Gallery article may not be the most exhaustive reference -- are you
aware that the packages

    RcppArmadillo

    RcppEigen

    RcppGSL

all carry fastLm implementations with and with formula interface?  Some of
these also have timing benchmark examples.

Another hint:  If you care about speed, do NOT use the formula interface.

I have factored out the Arma version (from RcppArmadillo/src/fastLm.cpp and
the related R file) a few times.

Hope this help,  Dirk