When testing a piece of software I am working on that uses Amelia I came across an error where R suddenly terminates. After some investigation it turns out that chol() throws a std::runtime_error when the matrix it tries to decompose is singular.
I have attached a file which causes the problem when running Amelia with the command
I have also forked the repository to https://github.com/jonlachmann/Amelia where a fix is applied. Please let me know if you want me to create a pull request or if you find a better solution. My solution is quite simple, I have added try/catch blocks around the chol() calls, and on failure I let C++ return R_Nilvalue. This is then handled in R the same way as was already present when Amelia even before calling the C++ function was able to determine that the matrix was singular.
When testing a piece of software I am working on that uses Amelia I came across an error where R suddenly terminates. After some investigation it turns out that chol() throws a std::runtime_error when the matrix it tries to decompose is singular.
I have attached a file which causes the problem when running Amelia with the command
I have also forked the repository to https://github.com/jonlachmann/Amelia where a fix is applied. Please let me know if you want me to create a pull request or if you find a better solution. My solution is quite simple, I have added try/catch blocks around the chol() calls, and on failure I let C++ return R_Nilvalue. This is then handled in R the same way as was already present when Amelia even before calling the C++ function was able to determine that the matrix was singular.
ameliacrash.RData.zip