I am modelling the variance among individuals for a trait by sex, across a large number of categories. It is very similar to this example:
library(brms)
library(palmerpenguins)
penguin <- brm(
bf(
body_mass_g ~ 0 + sex + (0 + sex | i | year),
sigma ~ 0 + sex + (0 + sex | i | year)
),
family = 'lognormal', data = penguins, cores = 4
)
(This model doesn’t fit well, but my actual model fits fine.)
Both the mean and the standard deviation depend on sex, and they can vary across the categories (years in this case). In my real data, the mean and sigma
are strongly related, and this correlation is captured by the | i |
term.
Now, I want to use this model to get posterior prediction for sigma
, for a previously unseen category. However, I want this prediction to be conditional on the mean, since this strongly effects the expectation for sigma
. But, when I run this code, the mean-variance relationship is not taken into account, since the result is the same if I include the mean or not:
posterior_predict(
penguin,
newdata = data.frame(sex = 'male', year = 2024, body_mass_g = 1e20),
allow_new_levels = TRUE,
dpar = 'sigma'
) |> posterior_summary()
The mean-variance correlation is basically zero here, but my actual model it is very clearly not using the response variable, which I think does make sense generally. But this leaves my question:
Is it possible to make use of the mean when predicting sigma?