# Hurdle Prior or Piecewise Function?

Hello,

I’m trying to use brms to fit a nonlinear model of the form

y \sim Lognormal(\mu , \sigma) \\ \mu = a - (b_1x)/(1 + b_2x^2)

The part of the model that I’m unsure how to specify is the idea that the parameter b_1 depends on x, such that when x is below a certain threshold value, b_1 = 0, (and thus \mu = a), and above the threshold b_1 is some positive value. Additionally, there is some grouping in my data, so both the threshold location and the value of b_1 above the threshold vary among groups (as a random effect).

It seems to me that the distribution of b_1 across all groups should follow something like a hurdle-lognormal distribution. Is there a way to specify this as a prior for a parameter or a random effect?

Alternatively, maybe it could be a piecewise function where below the threshold x = t_{[i]} the it’s just \mu = a and above it’s the full function. Can anyone provide insight on the best way to specify this model, and how it can be coded in brms?

If b1 is always zero below a certain threshold, then I would think a piecewise function is the way to go:

if (x < t) {
mu = a;
} else {
mu = a - (b1 * x) / (1 + b2 * x^2);
}


If it has some probability of being zero or not below a certain threshold, then I think you need a hurdle model.

However, as you probably noted from my use of Stan’s native code, I do not have any knowledge of how to specify a piecewise model in brms.