Brms predict() issue when using a stan function in a non-linear model fit

I’m trying to fit a simple two piece function to some count data.

brmsformula(y ~  0 - (46 - fmax(x0, x)) * (y0/(46 - x0)),
       x0 ~ 1,
       y0 ~ -1 + male)

I’m able to fit this formula, but when I try to use brms’s predict() function, I get the error

Error in fmax(x0, x) : could not find function "fmax"
 Most likely this is because you used a Stan function in the non-linear model formula that is not defined in R. If this is a user-defined function, please run 'expose_functions(., vectorize = TRUE)' on your fitted model and try again.

While I understand the issue, I can’t seem to find a solution.
For example, if I define fmax <- function(x,y) max(x,y) within my R session the error goes away, but the output from predict() consists solely of 0s.

Is there a work around for this?

  • Operating System: Ubuntu 22.04
  • brms Version: 2.18.0