Closed venpopov closed 7 months ago
Just to remind ourselves of the discussion we had today: We will implement this by writing a summary.bmmfit
method to avoid changing any information in the fit object and keep it compatible with most of the brms post-processing.
Yes, just as an example of why we really want to do this. I had never run the mixture3p model when there is setsize 1 (or I don't remember looking at the summary, maybe we did for the tutorial). I just did for testing. We did anticipate it and fixed the thetant to be a constant for setsize1, but if I didn't know why, I would be quite confused by this output:
Before we dive into doing this, mayb discuss what we would like the summary to actually show.
For example, here's the summary from an example sdm model
For this particular model it actually mostly fine. I'd prefer to have it show
So my proposal for all models is:
Also, we can give an option summary_backend = 'bmm' or 'brms', with 'bmm' default, but people can use the brms option if they want to.
Just a few notes about how brms produces the summary. Assume fit
is the variable containing the model fit
when you type fit
into the console, it:
function (x, digits = 2, ...)
{
print(summary(x, ...), digits = digits, ...)
}
this then calls summary.brmsfit(), which produces a list (e.g. see str(summary(fit))
) with class 'brmsummary`
since the function above has one more print inside it, it calls print.brmssummary, which determines how the information from the summary object is displayed.
summary.bmmfit <- function(object, priors = FALSE, prob = 0.95, robust = FALSE, mc_se = FALSE, ..., backend = 'bmm') {
# add some check about possible backends (bmm and brms only)
# get summary object from brms, since it contains a lot of necessary information:
out <- NextMethod('summary')
# stop and give brms summary if user wants brms summary
if (backend == 'brms') {
return(out)
}
# out is just a list - at this point we can modify it any way we want. In a upcoming PR I have also saved the bmm model and bmm_formula objects in the output, so we can access them for info
# here add, remove or change any parts of the summary list
# assign bmmsummary class to handle the printing
class(out) <- 'bmmsummary'
out
}
and then a custom print.bmmsummary method (modifying the base code from brms:::print.brmssummary)
I think this will be the simplest approach
Agreed! If you want you can have a look at it. I took the more complicated road and actually looked into writing a whole summary.bmmfit function.
But I think given that we import brms your suggestion will work easiest.
I did not make much progress so far. So, if you want to feel free to have a look into this. I will get to this earliest by Tuesday or Wednesday next week.
Ok, then if you don't mind I will give it ago :)
Just fyi, I'm starting to work on this, so I will use the same branch
Currently the brms model returns a summary that include the internal terms such as constant mu, kappa2, etc
We can remove that with a bit of preprocessing - brms does the same internally for its own models.