Skip to content

ENH: Adding logc link - #8155

Merged
josef-pkt merged 3 commits into
statsmodels:mainfrom
gmcmacran:glmLogcRebase
Nov 26, 2022
Merged

josef-pkt merged 3 commits into
statsmodels:mainfrom
gmcmacran:glmLogcRebase

Conversation

@gmcmacran

@gmcmacran gmcmacran commented Feb 25, 2022 •

Copy link
Copy Markdown
Contributor
  • closes #xxxx
  • tests added / passed.
  • code/documentation is well formatted.
  • properly formatted commit message. See
    NumPy's guide.

This pull request adds the logc link the binomial generalized linear model.

Changes are
1 Define link's class.
2 Test link.
3 Add link to binomial family.
4 Add to doc.
5 Clip cauchy link for numerical approximation to be accurate. (Test failed before change.)

This PR is a rebase of #8153.

Details

Notes:

  • It is essential that you add a test when making code changes. Tests are not
    needed for doc changes.
  • When adding a new function, test values should usually be verified in another package (e.g., R/SAS/Stata).
  • When fixing a bug, you must add a test that would produce the bug in main and
    then show that it is fixed with the new code.
  • New code additions must be well formatted. Changes should pass flake8. If on Linux or OSX, you can
    verify you changes are well formatted by running
    git diff upstream/main -u -- "*.py" | flake8 --diff --isolated
    
    assuming flake8 is installed. This command is also available on Windows
    using the Windows System for Linux once flake8 is installed in the
    local Linux environment. While passing this test is not required, it is good practice and it help
    improve code quality in statsmodels.
  • Docstring additions must render correctly, including escapes and LaTeX.

@gmcmacran gmcmacran mentioned this pull request Feb 25, 2022
4 tasks
Comment thread statsmodels/genmod/families/links.py Resolved
Update links.py
@josef-pkt

Copy link
Copy Markdown
Member

compared to spss we are also still missing the odds-power link.

separate followup. (this PR is for adding the link)
logc has similar problems as log link when used with binomial. The linear predictor can have values only in a subset of the real line.
Not clear yet where we should handle domain violations, maybe an option in binomial family

Comment thread statsmodels/genmod/families/links.py Resolved
@josef-pkt

Copy link
Copy Markdown
Member

looks good, but I'm not sure what the best clipping should be for the link and link_inverse
clipping like logit link should be fine for the binomial use case

we can merge, after clipping p<1
but we need to see how well it works when used in GLM binomial when domain violations are possible.

@gmcmacran

Copy link
Copy Markdown
Contributor Author

looks good, but I'm not sure what the best clipping should be for the link and link_inverse
clipping like logit link should be fine for the binomial use case

we can merge, after clipping p<1
but we need to see how well it works when used in GLM binomial when domain violations are possible.

The p<1 issue is fixed. Let me know if this needs anything else to be merged in.

@josef-pkt

Copy link
Copy Markdown
Member

should be ready to merge
I look at it tomorrow, I got distracted by Poisson, Covid and skiing :)

@gmcmacran gmcmacran changed the title Adding logc link ENH: Adding logc link Apr 8, 2022
@josef-pkt josef-pkt mentioned this pull request Jun 22, 2022
16 of 20 tasks
@josef-pkt josef-pkt added this to the 0.14 milestone Aug 6, 2022
@josef-pkt
josef-pkt merged commit 89092d8 into statsmodels:main Nov 26, 2022
@josef-pkt

Copy link
Copy Markdown
Member

merged as is

I will try out an example later

@gmcmacran

Copy link
Copy Markdown
Contributor Author

Wonderful. Thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants