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

Fix bug with compute_p for partially observed OrderedLogistic and OrderedProbit variables #7349

Merged
merged 2 commits into from
Jun 5, 2024

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Jun 5, 2024

This fixes a bug when auto-imputation takes place, in which case the logic to retrieve p wasn't valid. This will also show p as an input of the underlying Categorical in the graphviz.

Description

This PR fixes a bug when setting compute_p=True for partially observed OrderedLogistic/Probit. The logic of retrieving p from the third input does not work in this case, because when there is imputation a different kind of variable is returned (the joined vector of imputed and observed variables)

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

📚 Documentation preview 📚: https://pymc--7349.org.readthedocs.build/en/7349/

This fixes a bug when auto-imputation takes place, in which case the logic to retrieve `p` wasn't valid. This will also show `p` as an input of the underlying Categorical in the graphviz.
@ricardoV94 ricardoV94 added the bug label Jun 5, 2024
This fixes a bug when auto-imputation takes place, in which case the logic to retrieve `p` wasn't valid. This will also show `p` as an input of the underlying Categorical in the graphviz.
if compute_p:
pm.Deterministic(f"{name}_probs", out_rv.owner.inputs[3], dims=kwargs.get("dims"))
p = pm.Deterministic(f"{name}_probs", p, dims=kwargs.get("dims"))
Copy link
Member Author

Choose a reason for hiding this comment

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

The changes have the nice side-effect that p will now be an arrow going into the underlying Categorical

Copy link
Contributor

@AlexAndorra AlexAndorra left a comment

Choose a reason for hiding this comment

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

Good catch @ricardoV94 !

@AlexAndorra AlexAndorra merged commit b6c890e into pymc-devs:main Jun 5, 2024
20 checks passed
@ricardoV94 ricardoV94 deleted the fix_ordered_dists branch June 5, 2024 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants