I have a bayesian lognormal model as follows (brms package):
m = brm(y ~ 1, data = df, family = lognormal)
Model was run with default priors.
This is model's posterior samples on lognormal scale
posterior_samples(m)
Is exponentiated b_Intercept the median or geometric mean of y variable?
I have seen that some websites say that this is a geometric mean, some refer to this as a median. Or if this is something different, could you please provide a formula for calculating geometric mean or median from this posterior?
posterior_samples(m) %>%
mutate(transformed = exp(b_Intercept)) %>%
posterior_summary() %>% as.data.frame()
Crude median, mean and geometric mean of Y for comparison
Crude geometric mean was calculated as follows: exp(mean(log(df$y)))
Data used
set.seed(0)
pi <- 0
mu_log <- 2
sigma_log <- 0.99
N = 1000
y = (1 - rbinom(N, 1, prob = pi)) * rlnorm(N, mu_log, sigma_log)
df = data.frame(y=y)