Still struggling with this. First, we have the following model
library(brms)
fit <- brm(time | cens(censored) ~ age + sex + (1+age||patient), data = kidney, chains=4, iter = 2000, family = "exponential")
Let’s focus on the population effect of sex
for the moment:
fixef(fit, summary = TRUE)
which gives
Estimate Est.Error Q2.5 Q97.5
Intercept 3.827167116 0.63288949 2.6049586 5.09145851
age -0.003162866 0.01220938 -0.0268914 0.02037655
sexfemale 1.453764900 0.42597116 0.6152186 2.30179523
If I interpret the above results correctly, the following two rows in the result above
Estimate Est.Error Q2.5 Q97.5
Intercept 3.827167116 0.63288949 2.6049586 5.09145851
sexfemale 1.453764900 0.42597116 0.6152186 2.30179523
correspond to the male
effect and the difference between female
and male
, respectively, while age
is controlled at 0 (intercept). However, I couldn’t reconcile the above result with what predict
renders:
fitted(fit, newdata = data.frame(age = 0, sex = c('female', 'male'), patient = "new"), re_formula = NA, allow_new_levels = TRUE)
Estimate Est.Error Q2.5 Q97.5
[1,] 228.28978 140.74064 69.64470 577.8507
[2,] 56.33436 40.93747 13.53066 162.6269
What am I missing?
Also, if I want to predict the population effect while sex
is controlled at the average between the two levels, how would I set it up in predict
. The following does not seem to work:
fitted(fit, newdata = data.frame(age = 0, sex = 'xx', patient = "new"), re_formula = NA, allow_new_levels = TRUE)