Simple reprex below.
library(rstanarm)
fruit = c(rep("apples", 20),
rep("oranges", 20),
rep("bananas", 20))
prices = c(rnorm(20, 1, .1),
rnorm(20, .9, .2),
rnorm(20, 2, .1))
df = data.frame(fruit = fruit,
prices = prices)
model <- stan_glm(prices ~ fruit, data = df)
new_data = data.frame(fruit = rep("bananas", 10))
samples <- posterior_predict(model, newdata = new_data)
mean(samples)
I happen to have inside information that (a) the price of bananas is going to fall precipitously from $2 to 50 cents and (b) the price of apples is going to increase from $1 to $2. I’d like to embed this information in my prior. My question is- how do I specify the prior for a single level of a factor?
Many thanks.