Skip to content

Don't error on size-zero inputs to LKJ lpdf#3347

Open
andrjohns wants to merge 1 commit into
developfrom
lkj-dim-zero
Open

Don't error on size-zero inputs to LKJ lpdf#3347
andrjohns wants to merge 1 commit into
developfrom
lkj-dim-zero

Conversation

@andrjohns

@andrjohns andrjohns commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

The validation check order for inputs to lkj_corr_cholesky_lpdf changed since Stan 2.32, so that cholesky factors of size zero now error and reject instead of just returning 0. This breaks downstream applications which conditionally set the size to zero to remove it from the likelihood ( the rmdcev R package relies on this).

This PR updates the check_cholesky_factor to allow size-zero inputs

Tests

Additional test added for size-zero handling

Side Effects

N/A

Release notes

lkj_corr_cholesky_lpdf returns 0 instead of error with size-zero inputs

Checklist

  • Copyright holder: Andrew Johnson

    The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
    - Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
    - Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

  • the basic tests are passing

    • unit tests pass (to run, use: ./runTests.py test/unit)
    • header checks pass, (make test-headers)
    • dependencies checks pass, (make test-math-dependencies)
    • docs build, (make doxygen)
    • code passes the built in C++ standards checks (make cpplint)
  • the code is written in idiomatic C++ and changes are documented in the doxygen

  • the new changes are tested

@andrjohns

Copy link
Copy Markdown
Collaborator Author

Hmm looks like there's a bit of inconsistency between the tests and the code for some of the distributions

For example, the multi_student_t_cholesky_lpdf function has codepaths for size-zero location/df and size-zero cholesky factor, but the check_* functions error before those paths are reached and the tests expect errors for size-zero inputs

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant