Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

ENH: Optimize GLM Hessian calculation for canonical links#9753

Open
rikardo21-2bleA wants to merge 1 commit intostatsmodels:mainfrom
rikardo21-2bleA:enh/glm-canonical-optimization
Open

ENH: Optimize GLM Hessian calculation for canonical links#9753
rikardo21-2bleA wants to merge 1 commit intostatsmodels:mainfrom
rikardo21-2bleA:enh/glm-canonical-optimization

Conversation

@rikardo21-2bleA
Copy link

Description

This PR implements an optimization for the GLM Hessian calculation (Observed Information Matrix).
When a canonical link is used, the Observed Information Matrix (OIM) coincides with the Expected Information Matrix (EIM) / Fisher Information.
Mathematically, the curvature term involving$(y - \mu)$ vanishes. This PR detects canonical links and skips this unnecessary computation.

Closes#4269

Changes

  1. Family Logic: Addedis_canonical_link property toFamily class and_canonical_link_class to subclasses (Binomial, Poisson, Gaussian, etc.).
    • Note: I usedtype(link) is ... instead ofisinstance intentionally to strictly match the canonical link implementation and avoid inheritance issues.
  2. GLM Optimization: Updatedhessian_factor ingeneralized_linear_model.py. Ifis_canonical_link is True, it setsobserved=False, forcing the use of the EIM formula ($-X^T W X$), which is faster and numerically equivalent.
  3. Documentation: Added detailed NumPy-style docstrings with mathematical justification inhessian_factor.
  4. Testing: Addedstatsmodels/genmod/tests/test_glm_canonical.py with 11 tests covering all major families to ensure numerical equivalence between the optimized path and the original path.

Verification

  • Ran new tests:pytest statsmodels/genmod/tests/test_glm_canonical.py (11 passed).
  • Verified code formatting (flake8).
  • Docstrings added with LaTeX math support.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

ENH/REF GLM simplify computation if is_canonical

1 participant

@rikardo21-2bleA

[8]ページ先頭

©2009-2026 Movatter.jp