Skip to content

Commit fa4b60e

Browse files
committed
Drop collinear X columns in null model only if it has any (cholpred gives very large rank otherwise)
1 parent 48ffd9f commit fa4b60e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
1717
[compat]
1818
DSP = "0.7"
1919
Distributions = "0.25"
20-
GLM = "1.5"
20+
GLM = "1.8"
2121
MLBase = "0.9"
2222
Reexport = "1"
2323
StatsBase = "0.33"

src/Lasso.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,13 @@ function build_model(X::AbstractMatrix{T}, y::FPVector, d::UnivariateDistributio
330330
wts::Union{FPVector,Nothing}, offset::Vector, α::Real, nλ::Int,
331331
ω::Union{Vector, Nothing}, intercept::Bool, irls_tol::Real, dofit::Bool) where T
332332
# Fit to find null deviance
333+
X0 = nullX(X, intercept, ω)
334+
335+
# Drop collinear X columns only if it has any (cholpred gives very large rank otherwise)
336+
dropcollinear = size(X0,2) > 0
337+
333338
# Maybe we should reuse this GlmResp object?
334-
nullmodel = fit(GeneralizedLinearModel, nullX(X, intercept, ω), y, d, l;
339+
nullmodel = fit(GeneralizedLinearModel, X0, y, d, l; dropcollinear=dropcollinear,
335340
wts=wts, offset=offset, rtol=irls_tol, dofit=dofit)
336341
nulldev = deviance(nullmodel)
337342
nullb0 = intercept ? coef(nullmodel)[1] : zero(T)

0 commit comments

Comments
 (0)