Random scale random shape Gamma model brms

Hello everyone,

I would like to fit a hierarchical Gamma model for time-to-event data with random scale and random shape. Fitting the random scale model works well as follows:

fit5 <- brm(formula=AVALM | cens(CNSR) ~ 1 + (1|DIAG),
                   data = cancer, family=brmsfamily(family="Gamma",link="log"),
                   warmup = 1000,
                   iter = 2000, chains = 4, control = list(adapt_delta = 0.99),seed=2024)

However, when I try to additionally add a random scale as follows:

brmsForm3 <- bf(AVALM | cens(CNSR) ~ 1 + (1|DIAG), shape ~ 1 + (1|DIAG))

fit5 <- brm(formula=brmsForm3,
                   data = cancer, family=brmsfamily(family="Gamma",link="log"),
                   warmup = 1000,
                   iter = 2000, chains = 4, control = list(adapt_delta = 0.99),seed=2024)

I get the following error message:

Ill-typed arguments supplied to infix operator /. Available signatures:
(row_vector, matrix) => row_vector
(matrix, matrix) => matrix
(complex_row_vector, complex_matrix) => complex_row_vector
(complex_matrix, complex_matrix) => complex_ma

Following the same principle, I could already fit a Weibull and a log-normal model without any such issues. Does anyone have any idea why the Gamma model causes trouble?

Your help would be greatly appreciated.

Best wishes,

Katrin

2 Likes

Sorry nobody responded sooner. I don’t know why it’s only happening for the Gamma model, especially without seeing the actual Stan code generated by brms. Regardless, since brms is generating invalid Stan code resulting in parser errors, then I think this would be considered a bug in brms that you could report at

Dear Jonah,

thank you very much for coming back to me on this. The gamma models run through now without any issues; this was a problem within our programming environment and not related to brms.

Best wishes,

Katrin

1 Like

Thanks for following up and letting us know.