Closed jbytecode closed 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.
@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 methodinv
throws error in the case of singularity. How about changing the method asols(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 usingols(X, y, inversefunction = penv)