fastLm()
is much slower than lm()
.
Basically, I just call lm()
and fastLm()
with the same formula and data, but fa
The RcppArmadillo has a better example script in which different version are timed:
edd@max:~/git/rcpparmadillo/inst/examples(master)$ Rscript fastLm.r
test replications relative elapsed
4 fLmSEXP(X, y) 5000 1.000 0.174
2 fLmTwoCasts(X, y) 5000 1.017 0.177
3 fLmConstRef(X, y) 5000 1.029 0.179
1 fLmOneCast(X, y) 5000 1.069 0.186
6 fastLmPureDotCall(X, y) 5000 1.218 0.212
5 fastLmPure(X, y) 5000 1.908 0.332
8 lm.fit(X, y) 5000 2.207 0.384
7 fastLm(frm, data = trees) 5000 29.609 5.152
9 lm(frm, data = trees) 5000 36.977 6.434
edd@max:~/git/rcpparmadillo/inst/examples(master)$
The last two use a formula -- and this clearly shows that you do not want to use a formula if you are after speed as deparsing the formula takes a lot longer than actually running the regression. You could set something similar up for RcppEigen, the results will be similar.