Setting priors in multivariate model

Please also provide the following information in addition to your question:

  • Operating System: macOS 10.12.6
  • brms Version: 2.1.0

I’m trying to set a prior in the following model:

m<-brm(cbind(DV1, DV2)~IV1+IV2+IV3+IV4+IV5+IV6, data = data, family="gaussian", prior = prior, warmup = 1000, iter = 2000, chains = 20)

using this code:

prior<-c(set_prior("cauchy(0, 2.5)",class = "b", coef = "", resp = "DV1"),set_prior("cauchy(0, 10)", class = "Intercept", coef = "", resp = "DV2"))

However I am getting this error message:

Setting 'rescor' to TRUE by default for this combination of families
Error: The following priors do not correspond to any model parameter: 
b_DV1 ~ cauchy(0, 2.5)
Intercept_DV1 ~ cauchy(0, 10)
b_DV2 ~ cauchy(0, 2.5)
Intercept_DV2 ~ cauchy(0, 10)

This seems to suggest that I am setting priors on predictors named DV1 and DV2, however, what I am trying to do is set a prior across all b’s and intercepts when the response variable is DV1 and DV2.

Can you point out where I’m going wrong?

Thanks!

1 Like

Update:

Simply setting the priors like this…

prior<-c(set_prior("cauchy(0, 2.5)",class = "b", coef = ""),set_prior("cauchy(0, 10)", class = "Intercept", coef = ""))

…worked. Is there any reason this wouldn’t be okay, assuming I want all coefficients and intercepts to have the same prior?

Both ways of setting priors work for me. Which version of brms are you using?

Ah, I see it (brms 2.1.0). I suggest updating to the latest CRAN or github version (2.3.1+).

Hi,

I have the same problem when I set my priors for a multivariate model in brms (v2.10.0).

here my code

library(data.table)
library(brms)

df_syndrome <- fread("https://ndownloader.figshare.com/files/7676887") # Load data

df_syndrome[ , sc_exploration := scale(exploration)]
df_syndrome[ , sc_boldness    := scale(boldness)]
df_syndrome[ , sc_assay_rep   := scale(assay_rep, scale = FALSE)]
df_syndrome[ , sc_body_size   := scale(body_size)]

bf_exploration    <- bf(sc_exploration ~ 1 + sc_assay_rep + sc_body_size + (1|p|ID)) + gaussian()
bf_boldness       <- bf(sc_boldness    ~ 1 + sc_assay_rep + sc_body_size + (1|p|ID)) + gaussian()

priors <- c(
  set_prior("normal(0, 1)", class = "Intercept"),
  set_prior("normal(0, 1)", class = "b"),
  set_prior("cauchy(0, 1)", class = "sd"),
  set_prior("cauchy(0, 1)", class = "sigma")
)

brms_fit <- brm(bf_exploration + bf_boldness + set_rescor(FALSE),
                
                data     = as.data.frame(df_syndrome),
                prior    = priors)

And here is the error that I get:

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

I don’t have the error when I run only one model such as:

brms_fit <- brm(bf_exploration,
                
                data     = as.data.frame(df_syndrome),
                prior    = priors)
1 Like

I am sorry for the late response. The reason is that there are intentionally no global priors for sd and sigma classes and the ones for b and Intercept are deprecated. I recommend setting priors on a response per response basis, which you can also do in a vectorized manner via

set_prior(<prior>, ..., resp = c(<resp1>, <resp2>, ...))
3 Likes

Great, thanks!