Skip to content

Adding ordered beta regression support to brms#1852

Open
saudiwin wants to merge 13 commits intopaul-buerkner:masterfrom
saudiwin:feature/ordbeta-family
Open

Adding ordered beta regression support to brms#1852
saudiwin wants to merge 13 commits intopaul-buerkner:masterfrom
saudiwin:feature/ordbeta-family

Conversation

@saudiwin
Copy link
Copy Markdown

Hi Paul -

As you might be aware, for some time I've had the ordbetareg package that defines the ordered beta model as a custom distribution for brms. I decided to finally try to implement it directly in brms as the ordbeta() family and I believe I have succeeded. The trick is that the ordered beta distribution is a mixed discrete-continuous distribution (like the ZOIB), but it uses ordered cutpoints like an ordinal model. Defining the ordered cutpoints directly as a distributional parameter proved to be very difficult due to brms having special functions for the cumulative family--most of which are not necessary as the ordered beta model only uses two cutpoints & defining effects over the cutpoints aren't the main point.

For these reasons, in the implementation in this PR I define the cutpoints implicitly as two distributional parameters--xi and kappa--that are then passed to the likelihood function. I chose these two because xi is unbounded by default and kappa is strictly positive--I can then define an implicit cutpoint vector by [xi, xi + kappa].

This approach seems to work well & does not involve any additional changes to the code base. I have included two test scripts, ordbeta_example.R and ordbeta_example_zoi_kappa.R that show parameter recovery & convergence. Auxiliary functions also seem to work fine.

The only thing that is missing is that in my original model I use an induced dirichlet prior for the cutpoints (a la Betancourt), which is cool although it's not necessary & would require some kind of explicit definition of the cutpoints (though perhaps that could be calculated within the likelihood). In any case, I think this parameterization would meet most user needs.

I understand this parameterization is a bit unusual, and I'm happy to make any changes or additions. Thanks for considering this PR! A specific summary of changes is below.

Implementation Details

New Files

  • inst/chunks/fun_ordbeta.stan: Stan functions implementing the ordered beta log-PDF with three overloaded versions (scalar, vector/scalar phi, fully vectorized)

Modified Files

File Changes
R/distributions.R Added dordbeta(), pordbeta(), qordbeta(), rordbeta() distribution functions
R/families.R Added ordbeta() family constructor with documentation
R/family-lists.R Defined family specification (dpars, links, bounds, priors)
R/log_lik.R Added log_lik_ordbeta() for LOO/WAIC computation
R/posterior_epred.R Added posterior_epred_ordbeta() for expected predictions
R/posterior_predict.R Added posterior_predict_ordbeta() for posterior predictive samples
R/stan-likelihood.R Added ordbeta to likelihood generation
R/stan-response.R Minor adjustment for response handling
NAMESPACE Exported new functions

saudiwin and others added 12 commits January 21, 2026 17:07
This commit adds native support for ordered beta regression as
described in Kubinec (2023). The ordbeta family models [0,1]
responses with exact 0s and 1s as a mixture distribution with:
- Degenerate distribution at 0
- Beta distribution for (0,1) values
- Degenerate distribution at 1

The cutpoint parameters (cutzero, cutone) control the probability
of each component, while mu and phi parameterize the beta component.

Changes:
- Add .family_ordbeta() to R/family-lists.R
- Add ordbeta() wrapper function to R/families.R
- Create inst/chunks/fun_ordbeta.stan with vectorized Stan functions
- Add posterior_epred_ordbeta() to R/posterior_epred.R
- Add posterior_predict_ordbeta() to R/posterior_predict.R
- Add log_lik_ordbeta() to R/log_lik.R
- Add stan_log_lik_ordbeta() to R/stan-likelihood.R
- Add distribution functions (dordbeta, pordbeta, qordbeta, rordbeta)
- Add unit tests for all new functions
- Update NAMESPACE with exports
- Update documentation with references

Reference:
Kubinec R (2023). Ordered Beta Regression: A Parsimonious,
Well-Fitting Model for Continuous Data with Lower and Upper Bounds.
Political Analysis, 31(4), 519-536. doi:10.1017/pan.2022.20

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace cutzero/cutone dpars with ordinal threshold (thres) system
- Add 'ordinal' and 'ordered_thres' specials to ordbeta family
- Implement link-specific Stan functions (ordbeta_logit_lpdf, etc.)
- Support multiple link functions: logit, probit, cloglog, cauchit
- Add is_ordbeta() helper function
- Update posterior_epred, posterior_predict, and log_lik to use thresholds
- Fix dordbeta() to handle vectorized evaluation for log_lik
- Skip generic ordinal lpmf generation for ordbeta (uses custom functions)
- Update all tests for new threshold-based parameterization

The thresholds are now estimated as ordered Intercept parameters,
consistent with other ordinal families in brms.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The joint_link special ensures that the link function is applied
inside the Stan likelihood function rather than being applied to
mu separately. This is necessary because ordbeta_*_lpdf expects
mu on the linear predictor scale.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@paul-buerkner
Copy link
Copy Markdown
Owner

Thank you for this PR! I will need a bit of time to review the PR but I have it on my list of the next release so it won't forgotten.

@saudiwin
Copy link
Copy Markdown
Author

saudiwin commented Jan 26, 2026 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants