Skip to content

Package fails when response is zero vector. #51

@barankarakus

Description

@barankarakus

Running the following

`
using Lasso

X = [1 2; 3 4]
y = zeros(2)
fit(LassoPath, X, y)
`

leads to the error message

ERROR: coordinate descent failed to converge in 10000 iterations at λ = NaN

Having done some debugging, the problem is the following: when computing the λ values that make up the path, λmax is computed to be 0, resulting in λ being a vector of NaNs. The correct thing to output is that the null model is the only Lasso solution.

The easiest way to fix this is to have a check for λ being a vector of all NaNs right after line 490 in Lasso.jl. This is not a good solution, though, since we're relying on the fact that λmax = 0 implies λ is a vector of all NaNs; λ may be a vector of all NaNs due to another reason.

I think the best solution will be to modify build_model so that, in addition to the 4 values it currently returns, it also returns λmax. Then, we can have a check for λmax == 0 in line 491.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions