I would like to use the brms
package (or STAN) to fit a Bayesian linear model, but am having trouble figuring out how to set the priors based on a conditional distribution. For example, lets say that I have an outcome y
and a one covariate x
generated as follows:
n <- 10
beta0 <- 5
beta1 <- 3.7
x <- 0:n
y <- beta0 + beta1 * x + rnorm(n)
dat <- data.frame(y,x)
Now, I can use the brm
command to fit a linear model as follows:
fit <- brm(y ~ ., data = dat)
Now, implicitly, there is a prior being fit for 2 parameters in this model, i.e., one for beta (the regression coefficient for x) and one for sigma (the associated error term). Now, what I would like to do is to specify the prior for sigma as an inverse gamma distribution (I have the parameter values) and I would like to specify beta|sigma (i.e., beta conditional on sigma) as a normal distribution (again I know the parameters). What I don't know how to do, of if brms is capable of handling this situation, is to specify a conditional distribution for beta. This is akin to setting the prior as p(beta, sigma) = p(beta|sigma)p(sigma).
Furthermore, if it helps, I would like the priors to be as follows:
sigma ~ Inverse Gamma(4,10)
beta0 ~ Normal(5, 1.2 * sigma)
beta1 ~ Normal(3, 2 * sigma)