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

Issue #338: Add double dispatch for epidist_family #365

Merged
merged 20 commits into from
Oct 7, 2024

Conversation

athowes
Copy link
Collaborator

@athowes athowes commented Oct 2, 2024

Description

This draft PR will close #338. It refactors the structure of epidist_family:

  • Add epidist_family_model S3 to dispatch on the "model specific parts" of the family
  • Add .add_dpar_info helper to put the dpar information other than mu there conveniently for use in epidist_family_model
  • Add epidist_family_reparam to perform the only family specific hard coded part: reparam to line up brms and Stan
  • Refactor epidist_family to call these nicer modular functions
  • Remains to add tests

We have added a new issue to decide how to export functions in future (including those introduced by this PR): #79

Checklist

  • My PR is based on a package issue and I have explicitly linked it.
  • I have included the target issue or issues in the PR title in the for Issue(s) issue-numbers: PR title
  • I have read the contribution guidelines.
  • I have tested my changes locally.
  • I have added or updated unit tests where necessary.
  • I have updated the documentation if required.
  • My code follows the established coding standards.
  • I have added a news item linked to this PR.
  • I have reviewed CI checks for this PR and addressed them as far as I am able.

@athowes
Copy link
Collaborator Author

athowes commented Oct 2, 2024

Oops, looks like I branched off the transparency issue rather than main. Maybe this can be fixed anyway if that branch is merged. Edit: yes that worked fine.

@athowes athowes force-pushed the epidist-family-dispatch branch from 18d7d41 to 8ca944a Compare October 3, 2024 09:26
inst/scratch.R Outdated Show resolved Hide resolved
@athowes athowes marked this pull request as ready for review October 4, 2024 11:35
@athowes athowes requested a review from seabbs October 4, 2024 11:51
R/family.R Show resolved Hide resolved
R/latent_individual.R Outdated Show resolved Hide resolved
Copy link
Contributor

@seabbs seabbs left a comment

Choose a reason for hiding this comment

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

This looks great. One question about when we add custom info to family

@athowes
Copy link
Collaborator Author

athowes commented Oct 4, 2024

It's a real bug! And the integration test with gamma caught it! Nice stuff.

> family_gamma1 <- epidist_family(prep_obs, family = stats::Gamma)
> family_gamma2 <- epidist_family(prep_obs, family = stats::Gamma(link = "log"))
> family_gamma1$reparam
[1] "mu"    "shape"
> family_gamma2$reparam
[1] "mu"    "shape"
> family_gamma1$family
[1] "custom"
> family_gamma2$family
[1] "custom"

(Bug is that it's not doing the reparam right. Edit: should be fixed)

@athowes
Copy link
Collaborator Author

athowes commented Oct 4, 2024

I think this is in a good place, I expect CI to hopefully pass this time. Then it remains to improve the documentation and tests a bit and iron out the discussion points above.

@seabbs
Copy link
Contributor

seabbs commented Oct 7, 2024

Needs a redoc and work on the gamma method for reparam to pass checks

@athowes athowes requested a review from seabbs October 7, 2024 10:00
@seabbs seabbs force-pushed the epidist-family-dispatch branch from cfff3df to a0fad1f Compare October 7, 2024 11:49
R/latent_individual.R Outdated Show resolved Hide resolved
Copy link
Contributor

@seabbs seabbs left a comment

Choose a reason for hiding this comment

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

This looks really great. One outstanding question about when to validate data

tests/testthat/test-utils.R Outdated Show resolved Hide resolved
@seabbs seabbs self-requested a review October 7, 2024 12:38
@seabbs seabbs enabled auto-merge (squash) October 7, 2024 12:38
@seabbs seabbs disabled auto-merge October 7, 2024 13:09
@seabbs seabbs merged commit 94812c2 into main Oct 7, 2024
7 checks passed
@seabbs seabbs deleted the epidist-family-dispatch branch October 7, 2024 13:10
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.

Refactor epidist_family to use double dispatch
2 participants