Setting up priors

I’m trying to set priors for my model in r, can someone help me how to go about this? I’m investigating effects of socio environmental factors on dog bites in some 17 villages

prior <-c(
 set_prior("normal(1020, 100)", class = "b", lb = 0, ub = 5200, coef = "Annual_precipitation"),
  set_prior("normal(21, 2)", class = "b", lb = 0, ub = 30, coef = "Average_altitude"),
  set_prior("normal(1290, 120)", class = "b", lb = 0, ub = 2000, coef = "Mean_annual_Temperature"),
  set_prior("normal(0.07, 0.007)", class = "b", lb = 0, ub = 0.5, coef = "forest_percentage"),
  set_prior("normal(0.15, 0.015)", class = "b", lb = 0, ub = 0.5, coef = "savannah_percentage"),
  set_prior("normal(29, 3)", class = "b", lb = 0, ub = 100, coef = "Urbanization_index"),
  set_prior("normal(36, 3)", class = "b", lb = 0, ub = 100, coef = "Poverty_percentage"),
  set_prior("normal(84, 8)", class = "b", lb = 0, ub = 100, coef = "Literacy"),
  set_prior("normal(74, 7)", class = "b", lb = 0, ub = 100, coef = "Sanitation"),
  set_prior("student_t(3, 23, 23.7)", class = "Intercept")

brmformula<-Incidence ~ Average_altitude + Mean_annual_Temperature+Annual_precipitation+
                          forest_percentage + savannah_percentage+Urbanization_index +Poverty_percentage+
                          Literacy + Sanitation
                          data = data,
                          family = poisson(),
                          prior= prior,
                          chains = 4, iter = 30000, warmup = 15000)

randomdata.csv (1.9 KB)

Hello, your question is quite general so I’m not sure exactly what you’re looking for here. Overall the code seems to be correct, so I think you’re looking for some advice about choosing priors. A couple of points based on what you’ve specified:

  • you’re specifying a generalized linear model so these coefficients are on the linear predictor scale. I’m not sure what response counts are expected in your system, but for example, the coefficient value 29 for
    “Urbanization_index” corresponds to e^{29} or about 3.9*10^{12}, presuming the log link function, which seems unreasonably large.
  • The exactness of many of the prior selections suggests to me that they’ve been selected based on descriptive statistics. In general I think it’s more reasonable to consider either weakly informative priors based on the design, or stronger prior information based on other studies or background knowledge.

I really appreciate your answer,what I was trying to do there was specify that urbanisation follows a normal distribution with a mean of 29, variance of 3 but I’m gonna refrain from setting priors because mine are gross approximations. What I’ll just do is set lower boundaries for some of the variables at 0. Thanks again

It can be a reasonable start to test your model without specifying any priors, but for any practical usage you’ll definitely want to set some. Here in the Poisson model you should be able to make a reasonable start just by understanding the expected value of your response variable.

Note that lower bounds at 0 for priors in this model correspond to the assumption that the value of the coefficient is definitely positive (>1 on the response scale); i.e. you have forced the direction of the effect before considering the data. I doubt that this would be reasonable for most situations.