I’m fitting a multivariate model in brms and I wanted to do a prior predictive check. But, I’m running into issues with setting priors.
Here is a toy example:
library(brms)
data("BTdata", package = "MCMCglmm")
fit0 <- brm(
mvbind(tarsus, back) ~ sex + hatchdate + (1|p|fosternest) + (1|q|dam),
data = BTdata, chains = 2, cores = 2, sample_prior = "only"
)
Setting 'rescor' to TRUE by default for this model
Error: Sampling from priors is not possible as some parameters have no proper priors. Error occured for parameter 'b_tarsus'
Ok so I put sample_prior to “no” and fit a model and then do prior_summary(fit0)
to get:
> prior_summary(fit0)
prior class coef group resp dpar nlpar bound
1 b back
2 b hatchdate back
3 b sexMale back
4 b sexUNK back
5 b tarsus
6 b hatchdate tarsus
7 b sexMale tarsus
8 b sexUNK tarsus
9 student_t(3, 0, 10) Intercept back
10 student_t(3, 0, 10) Intercept tarsus
11 lkj_corr_cholesky(1) L
12 L dam
13 L fosternest
14 lkj_corr_cholesky(1) Lrescor
15 student_t(3, 0, 10) sd back
16 student_t(3, 0, 10) sd tarsus
17 sd dam back
18 sd Intercept dam back
19 sd dam tarsus
20 sd Intercept dam tarsus
21 sd fosternest back
22 sd Intercept fosternest back
23 sd fosternest tarsus
24 sd Intercept fosternest tarsus
25 student_t(3, 0, 10) sigma back
26 student_t(3, 0, 10) sigma tarsus
Ok so the b
terms don’t have priors so I attempt to set them:
fit1 <- brm(
mvbind(tarsus, back) ~ sex + hatchdate + (1|p|fosternest) + (1|q|dam),
data = BTdata, chains = 2, cores = 2, ,
prior = set_prior("normal(0, 5)", class = "b", coef = "",
resp = c("tarsus", "back")), sample_prior = "no")
prior_summary(fit1)
However now I’m still getting the error and when I check priors this time:
> prior_summary(fit1)
prior class coef group resp dpar nlpar bound
1 normal(0, 5) b back
2 b hatchdate back
3 b sexMale back
4 b sexUNK back
5 normal(0, 5) b tarsus
6 b hatchdate tarsus
7 b sexMale tarsus
8 b sexUNK tarsus
9 Intercept back
10 Intercept tarsus
11 lkj_corr_cholesky(1) L
12 L dam
13 L fosternest
14 lkj_corr_cholesky(1) Lrescor
15 student_t(3, 0, 10) sd back
16 student_t(3, 0, 10) sd tarsus
17 sd dam back
18 sd Intercept dam back
19 sd dam tarsus
20 sd Intercept dam tarsus
21 sd fosternest back
22 sd Intercept fosternest back
23 sd fosternest tarsus
24 sd Intercept fosternest tarsus
25 student_t(3, 0, 10) sigma back
26 student_t(3, 0, 10) sigma tarsus
I see it has not set priors for all the coefficients for the outcomes. I tried to do this but can’t figure it out. Also, now for some reason the priors for the Intercepts have dissappeared.
Where am I going wrong here?