jbytecode / LinRegOutliers

Direct and robust methods for outlier detection in linear regression
MIT License
44 stars 6 forks source link

Singularity #19

Closed jbytecode closed 4 years ago

jbytecode commented 4 years ago

@tantei3 we have

ols(X::Array{Float64,2}, y::Array{Float64,1})::OLS = OLS(X, y, inv(X' * X) * X' * y)

in /src/ols.jl and the method inv throws error in the case of singularity. How about changing the method as

ols(X::Array{Float64,2}, y::Array{Float64,1}; inversefunction = inv)::OLS = OLS(X, y, inversefunction(X' * X) * X' * y)

so some methods can call it using pinv from package LinearAlgebra using

ols(X, y, inversefunction = penv)

tantei3 commented 4 years ago

I think least squares solution is defined in terms of pseudo-inverse Ax = b then x = pinv(A)*b should be giving the coefficients. I think pinv should be used exclusively, and I don't see any reason to use normal inv function because the behaviour of inv and pinv are supposed to be same when inverse exists.