Closed athowes closed 3 months ago
In terms of keeping things atomic my preference is helper functions outside of the prediction function
newdata
enforced as as_latent_individual
or similardata
. Maybe different to case
I do think we need to have newdata
enforced as_latent_individual
.
The question for me is say that we provide functionality to generate predictions for all strata, then what values to set for the other columns of newdata
?
For example, say we have a model like 1 + sex
on mu
and sigma
. Then to make predictions we still need a newdata
with columns:
delay_central
sex
obs_t
pwindow_upr
swindow_upr
This is a little bit confusing to me. Is there some version of these predictions which is agnostic / integrates out / ... these other variables? Say I want to know about the expected delay distribution for a particular sex. Is there a version of that which isn't a function of the observation time?
This is a useful blog post: https://www.andrewheiss.com/blog/2021/11/10/ame-bayes-re-guide/#posterior-predictions
Nice that is useful. It looks like if we can plug into emmeans
we can get most of the functionality a user might want much more simply.
NA
in newdata
and runnewdata
and check no change in outputexpand.grid
on all covariates... how to extract covariates. Go into brms
model and extract things in the formulaNA
out the covariates as well. Overall prediction?If we do this with emmeans
I am not sure we need to supply any helpers like this because it doesn't much of this for us
I've almost finished writing a first helper function for the new strata. I might suggest we complete adding this function, then create a new issue for interacting with emmeans
. We can compare outputs from any potential emmeans
implementation with this helper function.
Edit: the emmeans
function is pretty good:
> emmeans::emmeans(fit_sex, specs = "sex")
sex emmean lower.HPD upper.HPD
0 2.02 1.95 2.08
1 1.30 1.19 1.43
Limitations:
mu
parameter -- also need prediction of sigma
fac.reduce
("a function that combines the rows of a matrix into a single vector)
Hence:
emmeans
to get function to do what we wantOther:
I think for a first pass we can get a lot of functionality from emmeans and we should do so (i.e just point out to it in the FAQ). I agree its not that bayesian but I am surprised you can't get samples out.
Once we have that in place (which is quite good coverage). I think we should think again about these strata functions (or if you have some in place we can do that sooner rather than later).
Closed as not going to do (unless it's hard to get things working with other packages).
In #210 we added functionality to produce predictions (of the delay internal and natural scale parameters) via
brms::prepare_prediction
for any family.There is an argument
newdata
as follows:Following @seabbs who IMO correctly summarises where we should go:
Basically, here we need to now help users to specify common
newdata
options.Options as far as I see it are either:
predict_delay_samples
predict_delay_samples
then put the helper functions insidepredict_delay_samples
I probably favour 2. over 1. but could be convinced / not strong.