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

Make likelihood() an S3 generic #244

Open
jamesmbaazam opened this issue May 9, 2024 · 1 comment
Open

Make likelihood() an S3 generic #244

jamesmbaazam opened this issue May 9, 2024 · 1 comment

Comments

@jamesmbaazam
Copy link
Member

The broader question is whether it would not be clearer to define S3 methods for numeric, epichains and epichains_summary where

likelihood.epichains <- function(chains, ...) {
  likelihood(summary(chains, ...))
}

likelihood.epichains_summary <- function(chains, stat_max = Inf, ...) {
  stat_max_from_sim <- attr(chains, "stat_max")
  if (missing(stat_max)) {
    stat_max <- stat_max_from_sim
  } else if (stat_max != stat_max_from_sim) {
    warning(`stat_max` is different from the one used in the simulations given in `chains`")
  }
  likelihood(as.numeric(chains, stat_max, ...))
}

and the current likelihood() becomes likelihood.numeric()

Originally posted by @sbfnk in #213 (comment)

@jamesmbaazam
Copy link
Member Author

This blog post by Hugo is relevant to this issue: https://epiverse-trace.github.io/posts/s3-generic/.

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

No branches or pull requests

1 participant