x = somevector
X = hcat(ones(length(x)), x, x.^2)
inv(X'* X)
Result: SingularException(3)
somevector may be a random vector with multiple zeros but more than 2 non-zero & non-equal elements are ensured to make X to be full rank.
When I replicate this in R, it would give a similar error message, which can be resolved by tweaking the tolerance for inverse function to a smaller number. However, I am not sure if that’s where the problem is, and if it is, what’s the corresponding solution in Julia?
Any help would be much appreciated. Thanks.