Please also provide the following information in addition to your question:
- Operating System: win10
- brms Version: 2.11.1
I have Bernoulli data where the probability p = exp(-lambda). I am implementing it as a generalized nonlinear model. I want to place a beta(p;0.5,0.5) prior on p, which is equivalent to placing a beta(p=exp(-lambda);0.5,0.5)*exp(-lambda) prior on lambda. As such, I am trying to use the prior_string function to create the custom prior. This is my first time trying this out. Right now I use the following prior string code:
brm_priors <- prior_string("target += beta_lpdf(exp(-b_theta) | 0.5, 0.5) - b_theta", check = F)
When I do this I get the following error:
Error: Priors on population-level coefficients are required in non-linear models, but none were found for parameter ‘theta’. See help(set_prior) for more details.
So I turned checking on:
brm_priors <- prior_string("target += beta_lpdf(exp(-b_theta) | 0.5, 0.5) - b_theta", check = T)
and got the following error:
Error: The following priors do not correspond to any model parameter:
b ~ target += beta_lpdf(exp(-b_theta) | 0.5, 0.5) - b_theta
Function ‘get_prior’ might be helpful to you.
Previously I had placed an exponential(1) prior on b_theta, so I feel confident I am using the correct parameter. Previously, my stancode looked like:
target += exponential_lpdf(b_theta | 1) - 59 * exponential_lccdf(0 | 1);
Any advice on how to use the custom prior and the a generalized nonlinear model without generating a warning or error?
Here’s the brms code:
brm.out <- brm(bf(y ~ exp(-theta), theta ~ 1, nl = T),
prior = brm_priors,
family = bernoulli("identity"),
chains = 2, cores = 2,
iter = 2000, warmup = 1000, thin = 1,
data = dat)
Edit: fixed formatting and added brm model code.
Edit2: fixed a copy paste error. That’s what I get for making this post the last thing I do before leaving work on a Friday.