JuliaStats / Lasso.jl

Lasso/Elastic Net linear and generalized linear models
Other
143 stars 31 forks source link

Bug: Bounds error thrown for small regularization parameters #61

Open hkraemer opened 3 years ago

hkraemer commented 3 years ago

Hey people,

maybe this is related to #54 , but LassoPath seems to struggle for small λ's, in particular for λ=0 (least squares solution). Here is a MWE:

using Lasso
using StatsBase
using Random

##

Random.seed!(1234)
# time series length
N = 5
# create a random time series of length N
s = rand(N)

# create a Data Matrix
Θ = ones(N,15)
Θ[1:50] .= 0
shuffle!(Θ)

# λ 1e-1 works
Lf = fit(LassoPath, Θ, s; standardize = false, intercept = false, λ=[1e-1])

# λ 1e-2 fails
Lf = fit(LassoPath, Θ, s; standardize = false, intercept = false, λ=[1e-2])

# ERROR: BoundsError: attempt to access 10×15 Array{Float64,2} at index [11, 12]

In Matlab's lasso this is no problem and λ=0 yields the least squares solution.

What am I missing here? Any help is appreciated,

Cheers