Hello,
I am trying to fit a GAMM in brms where I specify different priors. The model returns the following error :
Error: The following priors do not correspond to any model parameter:
sds_s(predator_id, bs ="re") ~ normal(0.60, 0.5)
Function 'get_prior' might be helpful to you.
The reason is I cannot find the proper name to write in the “coef=” argument of “set_prior()”. The variable I cannot specify is the random effect called “predator_id”.
Here is the name of the coefficients when I call “variables(fit)”, with "fit being my model :
[1] "b_Intercept" "b_Zgame_duration" "bs_sZcumul_xp_1"
[4] "sds_sZcumul_xp_1" "sds_spredator_id_1" "phi"
[7] "Intercept"
Here are my priors :
priors <- c(
# priors on fixed effects
set_prior("normal(0, 1)",
class = "b",
coef = "Zgame_duration"),
set_prior("normal(0, 2)",
class = "b",
coef = "sZcumul_xp_1"),
# prior on the intercept
set_prior("normal(0.05, 0.5)",
class = "Intercept"),
# priors on smooth terms
set_prior("cauchy(0, 2)",
class = "sds",
coef = "s(Zcumul_xp)"),
# prior on sds predator_id
set_prior("normal(0.60, 0.5)",
class = "sds",
coef = paste('s(predator_id, bs =', '"re")', sep = "")),
# priors on phi
set_prior("normal(2, 0.5)",
class = "phi")
)
When I run “prior_summary(fit)”, I get :
r$> prior_summary(mod1)
prior class coef group resp dpar nlpar lb ub
(flat) b
normal(0, 2) b sZcumul_xp_1
normal(0, 1) b Zgame_duration
normal(0, 2) Intercept
normal(2, 0.5) phi 0
student_t(3, 0, 2.5) sds 0
student_t(3, 0, 2.5) sds s(predator_id, bs = "re") 0
normal(0, 1) sds s(Zcumul_xp) 0
source
default
user
user
user
user
default
(vectorized)
user
I thus assumed that the name I should write in the “coef” argument of “set_prior()” would be “s(predator_id, bs = “re”)”, but it does not work. I tried many different combinations with no success. Could someone please help me specify the prior for this random effect?
Here is the model formula :
model_formula <- brmsformula(
hunting_success | vint(4) ~
s(Zcumul_xp) +
s(predator_id, bs = "re") +
Zgame_duration
)
Thank you very much for your help!