Why does GLM.jl fail to fit my logistic regression model but scikit learn and R has no issues? I think I found the reason

xiaodai
Sat, 24 Aug 2024 09:45:23 +0000
Modelling & Simulations

I have been trying to use GLM.jl to fit some logistic regression models and the fit failed. I don’t remember the exact error message but it was something about singularity.

That annoyed me for a couple of years but I never figured why because using RCall.jl was straight-forward enough and I just use it to fit the logistic regression.

Recently, I decided to look into the scikit-learn implementation and it occurred to me why that is the case!

The GLM.jl implementation using Julia’s powerful numerical abilities implemented the EM algorithms where as scikit just invoked a numerical solver that doesn’t use EM.

The EM must have some technical condition where the fit will fail while scikit-learn and R’s implementation will just treat it like any other numerical problem and try to find the best coefficients!

Admittedly the R’s coefficients for the problem I tried to solve contained some NA coefficients which I needed to discard but I actually prefer it to GLM.jl’s approach.

In Julia, is there an implementation of GLM that uses a solver like they do in R? Can’t seem to find one but I guess it’s easy to structure the problem as an optimisation problem and invoke a solver.

6 posts - 4 participants