-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
Create native Dirichlet multinomial family #1729
base: master
Are you sure you want to change the base?
Create native Dirichlet multinomial family #1729
Conversation
Thank you! This PR looks good overall, I think. Why are not confident about posterior_epred? You should be able to test it by comparing its output against the known(?) mean of the dirichlet_mulinomial distribution. I currently don't have time to check this detail myself. |
Thanks @paul-buerkner for taking a look at the PR - much appreciated. I've now checked I also had a quick scan of the checks above in case the failed checks were related to the dirichlet_multinomial family - I don't think they are. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have now checked the PR once again in a bit more detail and found a few more minor things to adjust before the PR is ready to be merged.
# @param eta the linear predictor (of length or ncol ncat) | ||
# @param phi the dispersion parameter | ||
# @param log return values on the log scale? | ||
ddirichletmultinomial <- function(x, eta, phi, log = FALSE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this accept the same kinds of inputs as brms::dmultinomial (just with an additional phi?). E.g. is the right dimensionality for x and eta taken care of?
eta <- get_Mu(prep, i = i) | ||
eta <- insert_refcat(eta, refcat = prep$refcat) | ||
phi <- get_dpar(prep, "phi", i = i) | ||
cats <- seq_len(prep$data$ncat) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the variables cats and alpha seem redundant here. Leftovers from previous versions?
eta <- insert_refcat(slice_col(eta, i), refcat = prep$refcat) | ||
dcategorical(cats, eta = eta) * trials[i] | ||
} | ||
# dirichlet part included in mu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this comment
@@ -587,6 +587,21 @@ posterior_epred_multinomial <- function(prep) { | |||
out | |||
} | |||
|
|||
posterior_epred_dirichlet_multinomial <- function(prep) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is now the same as the one for multinomial (right?), perhaps it makes sense to just call it directly with a comment saying why this is valid?
Following discussion in #1728, I've had a go at creating a native Dirichlet multinomial family.
I've attempted to update the documentation of
brmsfamily
, and added some tests too.I'm not confident that the
posterior_epred.R
function is correct, and probably should not have included it.Hopefully this is helpful - please let me know if you need anything more from me. And thanks again @paul-buerkner for all your help with this!