Heya,
I am trying to fit a multivariate (multiple-outcome) hierarchical model in brms.
The data and most of the code was taken from:
I just created random binary data for y1, y2. Wish to test this model before using my data.
I am having a hard time figuring out how to set priors - apparently something is wrong with the correspondence between prior and variables. I have checked out get_priors(), however the error persists even when including all possible “class”, “coef” and “group” arguments.
ERROR:
The following priors do not correspond to any model parameter:
sd ~ normal(0, 1)
b_hatchdate ~ normal(0, 1.5)
b_good_food_share ~ normal(0, 1.5)
b_sexMale ~ normal(0, 1.5)
b_sexUNK ~ normal(0, 1.5)
sd_fosternest__good_food_share ~ exponential(1)
CODE:
priors <- c(
# Priors for fixed effects (intercept and slopes)
prior_string("normal(0, 1)", class = "Intercept"),
prior_string("normal(0, 1)", class = "sd"),
prior_string("normal(0, 1.5)", class = "b",coef="hatchdate"),#numeric
prior_string("normal(0, 1.5)", class = "b",coef="good_food_share"),#numeric
prior_string("normal(0, 1.5)", class = "b",coef="sexMale"),#factor
prior_string("normal(0, 1.5)", class = "b",coef="sexUNK"),#factor
# Priors for random effects (variance of random intercepts and slopes)
prior_string("exponential(1)", class = "sd", group = "fosternest"), # Random intercept
prior_string("exponential(1)", class = "sd", group = "fosternest", coef = "good_food_share"), # Random slope for good_food_share
# Prior for correlation between random intercept and random slope
prior_string("lkj(2)", class = "L", group = "fosternest")
)
model = brm(mvbind(y1,y2)~sex+hatchdate+good_food_share+(1+good_food_share|p|fosternest),
data = data,
family = bernoulli(link = "logit"),
prior = priors,
cores=getOption("mc.cores", 4),
iter=1000)
Checking out this paper by @paul.bruecker (https://arxiv.org/pdf/1905.09501)
something like this:
prior = set_prior("normal(0, 3)", class = "b") +
set_prior("normal(2, 3)", class = "b", coef = "item1")
should be possible.
Would really appreciate a pointer to solve this!
Thanks