Skip to content

add support for Bernoulli distribution#51

Merged
hendersontrent merged 1 commit into
hendersontrent:mainfrom
rsenne:main
Nov 16, 2025
Merged

add support for Bernoulli distribution#51
hendersontrent merged 1 commit into
hendersontrent:mainfrom
rsenne:main

Conversation

@rsenne
Copy link
Copy Markdown
Contributor

@rsenne rsenne commented Oct 25, 2025

Adds support for a Bernoulli observation distribution. I can also extend this to the Binomial family as well, should be fairly easy.

I added a few numerical "hacks" to ensure things worked smoothly (e.g., the predicted probabilities not hitting exactly 0 or 1. I think we could likely use more elegant ways to do this. For example, I considered writing a one-line function that did something like:

InitializeMu(y::AbstractVector,  Family=Bernoulli)

and add other functions to just validate input etc. Let me know what else would be desired

@rsenne rsenne mentioned this pull request Nov 10, 2025
@hendersontrent hendersontrent merged commit d2af95f into hendersontrent:main Nov 16, 2025
Copy link
Copy Markdown
Contributor

@yahrMason yahrMason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good to me, thanks for taking this on. I just left one small comment on validating the mu parameter of the bernoulli distribution.

Comment thread src/PIRLS.jl
eta = mod.Fitted
mu = Link[:Inverse].(eta)
if Dist[:Name] == "Bernoulli"
mu = clamp.(mu, 1e-6, 1-1e-6)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use eps() and 1-eps() I believe instead of 1e-6.

@rsenne
Copy link
Copy Markdown
Contributor Author

rsenne commented Nov 23, 2025

Looks really good to me, thanks for taking this on. I just left one small comment on validating the mu parameter of the bernoulli distribution.

Thanks! This is a good idea. I can add this to my other pr #55? Maybe we can also add the InitializeMu() function I suggested as well? Thoughts?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants