Setting priors on sd for multinomial multilevel model

I’ve hit a problem setting the standard deviations for a multilevel multinomial model.

My problem is something like

formula <- y | trials(total) ~ (1 + year || region\country)  + (-1 + covariate | region)
priors <- c( set_prior("normal(0,1)", class = "b"),
                          set_prior("normal(0,1)", class = "sd"))
code <- make_stancode( formula , data = analysis_data, prior=priorsl)

throws the error

rror: The following priors do not correspond to any model parameter: 
sd ~ normal(0,1)
Function 'get_prior' might be helpful to you.

The function get_prior does not help :p

If I try

priors <- c( set_prior("normal(0,1)", class = "b"),
                          set_prior("normal(0,1)", class = "sd", group = "region"))

I get the same error except it says that sd_region does not exist.

Any ideas?

(Edit: this is brms version 2.10.0)

A hacky but working solution is the following:

ind_sd <- which(priors_complex_model$group == "" & priors_complex_model$class == "sd")
priors_complex_model$prior[ind_sd] <- "normal(0,1)"

Ok. I understnand it now. I needed to do something like

set_prior("normal(0,1)", class = "sd", dpar = "mu<category>")

Yeah, sorry for that. The fact that the same works with class = "b" is merely a convenience feature that is not trivial to implement for SDs as the hierechical structure of the prior specification makes handling of default priors more complicated. I brms 3.0 I plan a little restructering of the brms prior system and then we hopefully have a good solution.

P.S. get_prior would have helped :-p

2 Likes