Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override defaults for link functions #320

Merged
merged 12 commits into from
Nov 28, 2023
Merged

Override defaults for link functions #320

merged 12 commits into from
Nov 28, 2023

Conversation

digicosmos86
Copy link
Collaborator

Updates in this PR:

  • Added hssm.Link that represents more generalized link functions.
  • Added a override_default_link method to hssm.Param class
  • Updated hssm.HSSM class so the override_default_link method is called on each Param before each Param is finalized
  • Added a default parameter to hssm.HSSM to control which override strategy to use
  • Updated tests to reflect these changes

@digicosmos86 digicosmos86 linked an issue Nov 14, 2023 that may be closed by this pull request
Copy link
Collaborator

@AlexanderFengler AlexanderFengler left a comment

Choose a reason for hiding this comment

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

General comment:

  • we should probably rename the default argument towards prior_settings or something like that.

Otherwise looks good, apart from the pytensor operations for the link functions.

src/hssm/distribution_utils/dist.py Outdated Show resolved Hide resolved

self.bounds = bounds

def _make_generalized_sigmoid_simple(self, a, b):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you want to use pytensor operations here no?
At least the linkinv_backend should be pytensor, the others are prob ok.
The example I gave had all pytensor? I think so. (So all pytensor should work either way, since I tested that)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually bambi uses numpy functions, so I just want to make it consistent with other link functions in bambi. https://github.com/bambinos/bambi/blob/main/bambi/families/link.py

Copy link
Collaborator

Choose a reason for hiding this comment

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

kind of confusing because in the docs for Link it says:
'''
linkinv_backend : function
Same than linkinv but must be something that works with PyMC backend (i.e. it must
work with PyTensor tensors). Does not need to be specified when name is a known
name.
'''

Copy link
Collaborator

Choose a reason for hiding this comment

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

do numpy --> pt happen automatically?
because without pt it's not going to be differentiable...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wouldn't worry too much about this. I basically copied the docs from Bambi, and numpy should be compatible with pytensor. Also, we are not touching linkinv_backend here. Actually none of the bambi-defined link functions uses link_backend

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

do numpy --> pt happen automatically? because without pt it's not going to be differentiable...

I think there's some interpretability between numpy and pytensor. Otherwise none of the bambi link functions would work

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok!

src/hssm/plotting/__init__.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@AlexanderFengler AlexanderFengler left a comment

Choose a reason for hiding this comment

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

I think all conversations are resolved?
Approved.

@digicosmos86 digicosmos86 merged commit de48984 into main Nov 28, 2023
4 checks passed
@digicosmos86 digicosmos86 deleted the add-hssm-link branch November 28, 2023 15:31
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.

Add generalized logit link
2 participants