Brms custom_family non-negative student-t

Hello,

I would like to create a custom likelihood distribution that just has a low bound of 0 for the student-t. It seems custom_family is the solution in brms, could you please help me on this? I am not sure how to use custom_family after reading the documentation. Thanks a lot.

Do you want the linear predictor to give the expectation of the truncated student t, or of the student t before truncation?

Thanks @jsocolar, my data are all non-negative values (possible to have 0), so I guess it should be the former “linear predictor to give the expectation of the truncated student t”?

An alternative might using the log link for the mu model by setting family = student(link = "log") for the built-in Student-t likelihood.

Thanks a lot @Solomon. Log link will convert the model output to log scale and then fit to data right? Then it is similar as lognormal()? I tried but the model did not converge.

Regarding how to write a custom family, here are a bunch of examples GitHub - sims1253/bayesfam and a blog post about writing a brms custom family Building a brms Custom Family for the Kumaraswamy Distribution | Maximilian Scholz
maybe that helps with the ergonomics :)

1 Like

Thank you very much @scholz these examples are helpful.

Well, kinda. Setting family = lognormal is a likelihood-based solution (which can be a great solution). I’m suggesting a link-function-based solution. The log link will put the parameters for the linear predictor on the log scale, thus ensuring the model only makes positive predictions back on the response scale.

But this is all just to help you avoid making your own custom likelihood. If your experience and theory indicate a custom likelihood is the way to go, by all means, have at it.

I think this is not quite correct. Using eg. a normal likelihood with a log link, the \mu parameter of the normal would always be positive, but could still result in negative predictions (though not negative expected predictions I suppose).

1 Like

Ooo, I think you’re right. Good catch!

1 Like

@zcai Curious, what are you looking for in the student-t distribution, as in, what properties would make it a good fit for your data? There are plenty lower bounded options in brms (gamma, weibull, exponential, frechet, lognormal) and some more in Bayesfam (beta-prime, gompertz, softplusnormal, lomax) of the top of my head. Do you have any additional info on the properties of your data to help narrow down the choice?

Thank you very much @scholz and @Solomon. My data just have the lowest value as 0, a non-bounded student-t could fit but I would like to add this lower bound. The problem with gamma and lognormal is that the highest density is not close to 0. I would like something to decay from 0. Expentential would work but it decays too fast and I would like a long tail from student-t.

If your lowest value is exactly zero, that might be the problem when working with likelihoods such as lognormal or gamma. Those exclude zero. You might need a hurdle model for exact zeros (link).

1 Like

I do not have much to add with regards to the rest of this interesting discussion.

But I want to chime in to say I entertained using a log t distribution a couple years ago, when a client wanted essentially a longer tailed lognormal for one of the priors (caveat: you are looking for a suitable likelihood instead). We chose a log t. But the model behaved very nonsensically upon prior predictive checking, and did not perform well with actual modeling (I know I know…why should we do this if PPC failed…we wanted to see impact after we discovered the source of the problem)

We tentatively traced the issue to the fact that the mean of the log t is positive infinity, regardless of DFs. No finite moments. This was unexpected, but then easily confirmed.

So I’m not surprised your model didn’t converge. Similarly, folks often have convergence issues using the half-Cauchy as well [though not always]. Actually having no moments for the likelihood may even sometimes be a bigger issue than having none for a prior.

1 Like

If you actually have zeros in your dataset, then as Solomon said you might need hurdle/zero-inflated likelihoods to properly model that, however brms should complain about using eg. a gamma with zeros in the data.
In case you have no zeros in your dataset, the lomax and frechet distributions have strong tails and how close to zero do you need the mass to be? You can push a gamma or weibull quite close. If you want to try your luck with the student-t, you could always try log(outcome)~1+..., transforming your outcome to the log scale and modeling it with a student-t for a quick look how that behaves.

1 Like