I fitted a hurdle gamma model with an interaction term. Everything works well. I get the posterior epreds and the posterior predictions using the tidybase::add_predicted_draws
and tidybayes::add_epred_draws
functions. I can plot the data and everything looks perfect.
But I am struggling with calculating contrasts. My factor levels look like this:
F1 <- c("reference", "A", "B", "C", "D", "E", "F")
F2 <- c("W", "X", "Y", "Z")
expand.grid(F1 = F1, F2 = F2)
# F1 F2
# 1 reference W
# 2 A W
# 3 B W
# 4 C W
# 5 D W
# 6 E W
# 7 F W
# 8 reference X
# 9 A X
# 10 B X
# 11 C X
# 12 D X
# 13 E X
# 14 F X
# 15 reference Y
# 16 A Y
# 17 B Y
# 18 C Y
# 19 D Y
# 20 E Y
# 21 F Y
# 22 reference Z
# 23 A Z
# 24 B Z
# 25 C Z
# 26 D Z
# 27 E Z
# 28 F Z
This is my model:
m <- brm(bf(y ~ F1 * F2, hu ~ F1 * F2), family = "hurdle_gamma", data = d)
However, one complication is that the design is unbalanced, i.e. the number of observations for each factor combination varies. I would like to calculate the difference between reference:W
and A:W
, B:W
, C:W
,D:W
, E:W
, F:W
; then reference:X
and A:X
, B:X
, C:X
, D:X
, E:X
, F:X
; etc. until reference:Z
and A:Z
, B:Z
, C:Z
, D:Z
, E:Z
, F:Z
I was hoping someone can point me in the right direction. Thanks!