Adding ordered beta regression support to brms#1852
Open
saudiwin wants to merge 13 commits intopaul-buerkner:masterfrom
Open
Adding ordered beta regression support to brms#1852saudiwin wants to merge 13 commits intopaul-buerkner:masterfrom
saudiwin wants to merge 13 commits intopaul-buerkner:masterfrom
Conversation
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>
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. |
Author
|
Great, thanks!
All best -
Bob
… On Jan 26, 2026, at 8:18 AM, Paul-Christian Bürkner ***@***.***> wrote:
paul-buerkner
left a comment
(paul-buerkner/brms#1852)
<#1852 (comment)>
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.
—
Reply to this email directly, view it on GitHub <#1852 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACTVVOLSKZSO25R7OZ7YND34IYHZ3AVCNFSM6AAAAACSWC5VGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTOOJZGU3DMNJVGM>.
You are receiving this because you authored the thread.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inbrmsas theordbeta()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 tobrmshaving special functions for thecumulativefamily--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--
xiandkappa--that are then passed to the likelihood function. I chose these two becausexiis unbounded by default andkappais 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.Randordbeta_example_zoi_kappa.Rthat 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
R/distributions.Rdordbeta(),pordbeta(),qordbeta(),rordbeta()distribution functionsR/families.Rordbeta()family constructor with documentationR/family-lists.RR/log_lik.Rlog_lik_ordbeta()for LOO/WAIC computationR/posterior_epred.Rposterior_epred_ordbeta()for expected predictionsR/posterior_predict.Rposterior_predict_ordbeta()for posterior predictive samplesR/stan-likelihood.RR/stan-response.RNAMESPACE