Skip to content

Commit

Permalink
Drop collinear X columns in null model only if it has any (cholpred g…
Browse files Browse the repository at this point in the history
…ives very large rank otherwise)
  • Loading branch information
AsafManela committed Nov 29, 2022
1 parent 48ffd9f commit fa4b60e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
[compat]
DSP = "0.7"
Distributions = "0.25"
GLM = "1.5"
GLM = "1.8"
MLBase = "0.9"
Reexport = "1"
StatsBase = "0.33"
Expand Down
7 changes: 6 additions & 1 deletion src/Lasso.jl
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,13 @@ function build_model(X::AbstractMatrix{T}, y::FPVector, d::UnivariateDistributio
wts::Union{FPVector,Nothing}, offset::Vector, α::Real, nλ::Int,
ω::Union{Vector, Nothing}, intercept::Bool, irls_tol::Real, dofit::Bool) where T
# Fit to find null deviance
X0 = nullX(X, intercept, ω)

# Drop collinear X columns only if it has any (cholpred gives very large rank otherwise)
dropcollinear = size(X0,2) > 0

# Maybe we should reuse this GlmResp object?
nullmodel = fit(GeneralizedLinearModel, nullX(X, intercept, ω), y, d, l;
nullmodel = fit(GeneralizedLinearModel, X0, y, d, l; dropcollinear=dropcollinear,
wts=wts, offset=offset, rtol=irls_tol, dofit=dofit)
nulldev = deviance(nullmodel)
nullb0 = intercept ? coef(nullmodel)[1] : zero(T)
Expand Down

0 comments on commit fa4b60e

Please sign in to comment.