corr_matrix of size 0 fails
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.8k
- Forks
- 388
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 15
Description
Summary:
Defining a size 0 correlation matrix leads to std::bad_alloc in rstan. This is related to #2588, where it is suggested that corr_matrix and related types should be able to work for size 0. #2588 was closed, but I think the "allow size 0" issue was never addressed.
Reproducible Steps:
This zip file contains an R file and stan file (run with rstan), illustrating the issue: corrmat.zip
Current Output:
std::bad_alloc if the corr_matrix size is 0.
Expected Output:
Optimally, this model would still sample when the corr_matrix size is 0.
Current Version:
I am using rstan 2.21.2 with R 4.0.2. I also reproduced with CmdStan 2.24.0, which reported:
Exception initializing step size.
Posterior is improper. Please check your model.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the R and Stan files in corrmat.zip with rstan or CmdStan to reproduce the zero-sized corr_matrix failure. Trace how corr_matrix handles a size of 0 and verify the model can initialize and sample successfully without std::bad_alloc or an improper-posterior error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, r
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100