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

Smith, Dale Dale.Smith at Fiserv.com
Thu Mar 21 16:44:04 CET 2013


I have a question about the fastLm example in the Gallery http://gallery.rcpp.org/articles/fast-linear-model-with-armadillo/. I put the code directly into my package (after renaming it fastLmProto so I don't mask the RcppArmadillo function by the same name). After building the package, I wanted to compare results:

 

> require(datasets)

> coef(lm(y1 ~ x1, data = anscombe))

(Intercept)          x1 

  3.0000909   0.5000909 

> coef(fastLmProto(anscombe$y1, as.matrix(anscombe$x1)))
          [,1]
[1,] 0.7968032
> coef(fastLm(anscombe$y1, as.matrix(anscombe$x1)))
[1] 1.208169

 

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?

 

I reviewed the RcppArmadillo documentation and the article http://dirk.eddelbuettel.com/papers/RcppArmadillo.pdf but could not find anything relevant.

 

Thanks,

Dale Smith, Ph.D.

Senior Financial Quantitative Analyst

Risk & Compliance

Fiserv

Office: 678-375-5315

www.fiserv.com <http://www.fiserv.com/> 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130321/345c8b45/attachment.html>


More information about the Rcpp-devel mailing list