Is there a way to remove the offset from the marginal_effects function (or fitted function)?
The following code does a simple regression with poisson family with log-rate of 0.5 + 2 * a + b, with a in {0, 1} and b some random offset:
library(brms)
library(tidyverse)
set.seed(180409)
icpt = 0.5
a = 2
n = 100
df = data_frame(a = rbinom(n, 1, 0.5))
df$b = exp(rnorm(n, mean = 1, sd = 0.5))
df$y = rpois(n, exp(icpt + a * df$a + log(df$b)))
df$a = factor(df$a)
if (!exists('fit')) {
fit = brm(bf(y ~ 1 + a + offset(log(b)), family=poisson(link='log')), df)
}
plot(marginal_effects(fit, scale='linear', method='fitted'))
Checking the fit shows the correct estimates:
Population-Level Effects:
Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
Intercept 0.51 0.06 0.39 0.62 1156 1.00
a1 2.01 0.06 1.90 2.14 1267 1.00
but I can't figure out how to plot the marginal_effects without an offset being reintroduced, which shows estimates at 1.7 and 3.7 instead of 0.5 and 2.5 [noting that log(mean(df$b)) is 1.2].