Set and verify multiple priors

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

  • Operating System: MacOS 10.14.5
  • brms Version: 2.7.0

I have a complex multivariate hierarchical model with very few data (2 points per cluster). So I need to define very strong priors to let the model be fitted robustly (and in reasonable time). But since the model is complex there are a lot of priors to set.

Is there a way to set many at once?

And then, is there a way to check the prior setting before fitting the model? get_prior only let you see default priors and to use prior_summary you need to fit the model first (-> hours).

Here’s my model for example:

> get_prior(bf(N.prest ~ Mesi + (Mesi|Context), family = poisson()) + bf(Attesa ~ log(N.prest) + scale(Mesi) + (log(N.prest) + scale(Mesi)|Context), sigma ~ log(N.prest) + scale(Mesi) + (log(N.prest) + scale(Mesi)|Context), family = lognormal()), data = TdA, set_prior('normal(0, 2.5)', class = 'sd', group = 'Context'))
Setting 'rescor' to FALSE by default for this model
                 prior     class       coef   group   resp  dpar nlpar bound
1                              b                                            
2               lkj(1)       cor                                            
3                            cor            Context                         
4                      Intercept                                            
5                              b                    Attesa                  
6                              b logN.prest         Attesa                  
7                              b  scaleMesi         Attesa                  
8  student_t(3, 3, 10) Intercept                    Attesa                  
9  student_t(3, 0, 10)        sd                    Attesa                  
10                            sd            Context Attesa                  
11                            sd  Intercept Context Attesa                  
12                            sd logN.prest Context Attesa                  
13                            sd  scaleMesi Context Attesa                  
14                             b                    Attesa sigma            
15                             b logN.prest         Attesa sigma            
16                             b  scaleMesi         Attesa sigma            
17 student_t(3, 0, 10) Intercept                    Attesa sigma            
18 student_t(3, 0, 10)        sd                    Attesa sigma            
19                            sd            Context Attesa sigma            
20                            sd  Intercept Context Attesa sigma            
21                            sd logN.prest Context Attesa sigma            
22                            sd  scaleMesi Context Attesa sigma            
23                             b                    Nprest                  
24                             b       Mesi         Nprest                  
25 student_t(3, 4, 10) Intercept                    Nprest                  
26 student_t(3, 0, 10)        sd                    Nprest                  
27                            sd            Context Nprest                  
28                            sd  Intercept Context Nprest                  
29                            sd       Mesi Context Nprest     

For example, I would like to be able to set a prior for all Context sd at once, for all coef, resp and dpar.

The structure of the priors in brms is hierachical. That is, higher level priors will apply to coefficients on a lower level if they have no own priors specified. This is discussed in ?set_prior and also in a few threads here on discourse. To see the implications of the priors, you have to specify them, fit the model using sample_prior = "only" and then plot the prior predictions via pp_check. I know that setting priors is hard. It is hard for all of us especially when the model is complex and we try to specify independent priors on the coefficients. We should properly rather be specifying joint priors over multiple parameters. This is why we are actively working on finding better (joint) priors and making it easier to use them in software.

Ok, thank you!

For some reason on the model I’m (very hard) to train, specifying the prior of the Context sd prior manually, albeit using the same distribution as on the general SD parameter, gave me more a robust fitting in terms of divergent observations and effective samples size. So I thought that priors have to be put on each parameter one by one.