Are there good ways for showing the influence of two different priors on results? Or a good way showing to a friend-frequentist that my priors do not influence the results.
I have two models. One with a weak prior.
library(tidyverse)
library(brms)
library(janitor)
n = 20
a = tibble(weight = rnorm(n, 80, 7), sex = rep("man"))
b = tibble(weight = rnorm(n, 60, 5), sex = rep("woman"))
df = rbind(a, b)
m_weak_prior = brm(weight ~ sex, data = df, sample_prior = "yes", prior = c(set_prior("normal(0, 20)", class = "b", coef = "sexwoman")))
post1 = m_weak_prior %>% posterior_samples() %>% clean_names()
post1 %>% ggplot()+
geom_density(aes(b_sexwoman), alpha = 0.3, fill = "darkblue")+
geom_density(aes(prior_b_sexwoman), alpha = 0.3, fill = "lightblue")+
ggtitle("posterior and prior")
And one with a stronger prior.
m_strong_prior = brm(weight ~ sex, data = df, sample_prior = "yes", prior = c(set_prior("normal(-40, 5)", class = "b", coef = "sexwoman")))
post2 = m_strong_prior %>% posterior_samples() %>% clean_names()
post2 %>% ggplot()+
geom_density(aes(b_sexwoman), alpha = 0.3, fill = "darkblue")+
geom_density(aes(prior_b_sexwoman), alpha = 0.3, fill = "lightblue")+
ggtitle("posterior and prior")
My possibly bad solution for showing the effect of the stronger prior on b coefficient for sex
I calculate the difference between the two modelās b coefficients and then pass it to posterior_summary() function
post1 = post1 %>% select(b_sexwoman) %>% rename(b_sexwoman1 = b_sexwoman) %>% mutate(id = row_number())
post2 = post2 %>% select(b_sexwoman) %>% rename(b_sexwoman2 = b_sexwoman) %>% mutate(id = row_number())
merge(post1, post2, by = "id") %>% mutate(influence = b_sexwoman2 - b_sexwoman1) %>% posterior_summary()
Estimate Est.Error Q2.5 Q97.5
id 2000.500000 1154.844867 100.975000 3900.02500
b_sexwoman1 -17.978276 1.528503 -20.929719 -14.97290
b_sexwoman2 -20.062139 1.562302 -23.276515 -17.10929
influence -2.083863 2.170942 -6.401877 2.04397
This shows that the results of the two models differ. Stronger prior makes women 2 kilograms lighter but the relevant CIās (for āinfluenceā) does not have a good interpretation?