Allow structured format for unconstrained parameters
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 160
- Forks
- 69
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 15
Description
The current approach to providing unconstrained parameters as arguments (as inherited from rstan) requires that they are passed as a single numeric vector with all unconstrained parameter values concatenated.
After some API discussions with @n-kall, it was pointed out that this approach can easily lead to errors if any transformations or custom constructions of unconstrained parameters are performed - as users might accidentally provide parameter values in the wrong order.
Instead, we could allow unconstrained parameters to be passed as a named list like we do for constrained parameters, but with handling/checking for the different number of unconstrained values (e.g., for simplexes).
As a concrete example, for a model with parameters:
parameters {
real x;
simplex[4] y;
}
The unconstrained parameters would need to be passed as a four-element numeric vector:
unconstrained_vector <- c(1.2, 0.6, 1.6, -1.2)
This clearly allows for the easy mistake of accidentally providing the value of x as the last, rather than the first element (especially if the model is being iterated/revised).
I'm proposing we could accept the unconstrained parameters in the format:
unconstrained_list <- list(x = 1.2, y = c(0.6, 1.6, -1.2))
And then handle the ordering internally when mapping to a single vector of values.
Thoughts?
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 locating the current API entry point for unconstrained parameter vectors and the corresponding handling for constrained parameters. Review how parameter ordering and dimensions are determined, then define tests for named unconstrained inputs, including scalar and simplex values, and for invalid names or lengths. Done means named inputs are checked and mapped deterministically without breaking vector inputs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100