sm.Logit and sm.GLM do not handle alpha the same way

Open
#9,427 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
data

Research direction

Start by comparing the fit_regularized paths for sm.GLM and sm.Logit using the Binomial example in the issue, focusing on how alpha is scaled relative to len(X). Reproduce the mismatch with the shown models and verify that equivalent alpha values produce the same results after the behavior is aligned.

Written by the indexing model from the issue text.

Description

To get same results when using

model = sm.GLM(y, X, family=sm.families.Binomial())
results = model.fit_regularized(alpha=alpha_glm, ...)

and

model = sm.Logit(y, X)
results = model.fit_regularized(alpha=alpha_logit)

one needs to set alpha_logit = alpha_glm * len(X) because scaling is not done the same way.

This should not be the case.

Dominant language
Python
Stars
11.6k
Forks
3.6k
Avg merge
7h 37m
Merged PRs (30d)
96

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from statsmodels/statsmodels

All issues in statsmodels/statsmodels

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.