tnt
tnt

Reputation: 1459

setting priors in brms for categorical variables

I'm a bmrs neophyte and I'm trying to set priors for a model that includes one continuous variable (mass) and two categorical variables (site and sex). Based on past research, I have some information that I'd like to add to the priors for the categorical variables:

  1. values of y are going to be more variable for site A compared to sites B & C.
  2. values of y are going to be higher and more variable for sex F compared to sex M.

However, when I use get_prior to see what my options are for specifying priors, it's unclear to me how I'd translate the information I have to specifying priors. Example:

library(brms)
library(tidyverse)    
set.seed(42)
df <- tibble(y    = rnorm(100),
             mass = rnorm(100),
             site = sample(LETTERS[1:3], 100, replace = TRUE),
             sex  = sample(c("F", "M"), 100, replace = TRUE))

get_prior(y ~ mass + site + sex + (1 + mass | site : sex), data = df)
                  prior     class      coef    group resp dpar nlpar lb ub       source
                 (flat)         b                                               default
                 (flat)         b      mass                                (vectorized)
                 (flat)         b      sexM                                (vectorized)
                 (flat)         b     siteB                                (vectorized)
                 (flat)         b     siteC                                (vectorized)
                 lkj(1)       cor                                               default
                 lkj(1)       cor           site:sex                       (vectorized)
 student_t(3, 0.2, 2.5) Intercept                                               default
   student_t(3, 0, 2.5)        sd                                     0         default
   student_t(3, 0, 2.5)        sd           site:sex                  0    (vectorized)
   student_t(3, 0, 2.5)        sd Intercept site:sex                  0    (vectorized)
   student_t(3, 0, 2.5)        sd      mass site:sex                  0    (vectorized)
   student_t(3, 0, 2.5)     sigma                                     0         default

Based on my knowledge of the system, I'd like to set priors as follows, but that doesn't match up with what is available in the get_prior table:

priorList <- c(prior(normal(0, 1), class = Intercept),      
               prior(normal(0, 1), class = b, coef = mass), 
               # 1. values for A are more variable than B and C
               prior(normal(0, 2), class = b, coef = siteA),
               prior(normal(0, 1), class = b, coef = siteB),
               prior(normal(0, 1), class = b, coef = siteC),
               # 2. values for F are higher and more variable than M
               prior(normal(2, 5), class = b, coef = sexF),    
               prior(normal(0, 1), class = b, coef = sexM))

I also don't know how to reflect this knowledge in the priors for class = sd and whether these should also be normal or student_t priors.

Upvotes: 0

Views: 113

Answers (0)

Related Questions