Coefficient specific priors for multivariate model

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

  • Operating System: Ubuntu 18.04
  • brms Version: 2.10.5 (from github)

Hello!

I am trying to simulate data from a Structural Equation Model, in order to estimate the number of data points necessary to estimate such a DAG.

However, I am struggling with the prior specification. I try to put priors on each coefficients to represent my current believes… I present there after a minimal reproducible exemple, which is a multivariate model of two variables sharing the same predictors.

Data : DAG_exemple.csv (4.3 KB)

form_DAG <- bf(MoussPV ~ Hum + Biom + Hum:Exclos + Biom:Exclos,
               family = Gamma(link = "log")) + 
  bf(SLA ~ Hum + Biom + Hum:Exclos + Biom:Exclos,
               family = Gamma(link = "log"))

priors_DAG <- c(
 ## MoussPV
  prior(normal(log(1.2), log(1.2)), coef = Biom, resp = MoussPV),
  prior(normal(log(1.2), log(1.2)), coef = Biom:ExclosTemoin, resp = MoussPV),
  prior(normal(log(1.2), log(1.2)), coef = Hum, resp = MoussPV),
  prior(normal(log(1.2), log(1.2)), coef = Hum:ExclosTemoin, resp = MoussPV),
  prior(normal(0.1,0.1), class = Intercept, resp = MoussPV),
  ## SLA
  prior(normal(log(1.2), log(1.2)), coef = Biom, resp = SLA),
  prior(normal(log(1.2), log(1.2)), coef = Biom:ExclosTemoin, resp = SLA),
  prior(normal(log(1.2), log(1.2)), coef = Hum, resp = SLA),
  prior(normal(log(1.2), log(1.2)), coef = Hum:ExclosTemoin, resp = SLA),
  prior(normal(0.1,0.1), class = Intercept, resp = SLA)
)

simu <- brm(formula = form_DAG, priors = priors_DAG,
            data = D, sample_prior = "only",
            iter = 10, chains = 3, cores = 3)

The following error message then appears.

Erreur : Sampling from priors is not possible as some parameters have no proper priors. Error occured for class 'b_MoussPV'.

Am I missing something obvious??

Thank you!
Lucas

1 Like

The argument to brm should be ‘prior’ not ‘priors’. Then it should run.

@paul.buerkner would it make sense to print a warning if priors is specified instead of prior? Seems like an easy mistake to make.

Seriously guys, I will become crazy I keep doing typo bloquing me for days -_-

Thank you very much for your answer, it works perfectly :)

To make me a better programmer, is there a workflow somewhere to avoid getting stuck on such crazy things?

I guess it’s related to how my brain works, I always create a “priors” objects, because there are usually many priors.