Group-level predictor to model group-varying intercept?

Hi,

What is the best way in brms() to add group-level predictors to explain group-level parameters? In my case the group-level parameter is the intercept which varies across year groups, say.

I am following the Gelman and Hill route and simply adding in a group-level predictor outside of the group-level code block. For example, adding in a predictor to explain the intercept which varies between year groups, by creating a group-predictor - meanCF - for the group-varying intercept. This predictor - by definition - only varies between year to year in my dataset:

y ~ X + meanCF + (1 | year)

reg_data <- data %>%
            group_by(year) %>%
            mutate(medianCF =  median(cashflow_rf),
                   meanCF = sum(cashflow)/sum(fixed_c_gross))

Is this the best approach?

Many thanks,

Looks good, to me.

2 Likes