[Rcpp-devel] Detecting Singular Matrices in RcppArmadillo

Dirk Eddelbuettel edd at debian.org
Fri Jan 28 18:30:57 CET 2022


On 28 January 2022 at 09:16, Neal Fultz wrote:
| There's an R object that has the machine precision, which could be a
| reasonable threshold.
| 
| .Machine$double.eps
| 
| I believe there is a similar constant in the C++ standard library.
| 
| You might also try checking the condition of the matrix instead of the
| determinant, but you might take a performance hit. EG:
| https://www.quora.com/Why-is-a-condition-number-more-useful-than-a-determinant-for-spotting-problems-with-the-solution-to-ax-b

Exactly -- here is an old SO answer of mine featuring the condition
number and kappa (its inverse):

https://stackoverflow.com/questions/3042117/screening-multicollinearity-in-a-regression-model/3042262#3042262

I don't have an implementation of either 'from C++ / Armadillo basics' handy
but it is likely not hard, and possibly a nice exercise.

Dirk

-- 
https://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list