-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow structured format for unconstrained parameters #730
Comments
Love it! |
Great idea! |
why is this needed in cmdstanr? |
The model methods functions exposed to R via c++ ( |
this proposal only goes halfway towards validating the inputs - it provides names for the variables, but not structure. in particular, matrix and multi-dim array objects are flattened into a vector and there is no way of checking that the flattened structure is serialized correctly - i.e., column-major. a meta-objection is that this feature is unecessary. the output from the |
The structure is the point of this proposal. Similar to how providing initial values or data requires a named list with structured inputs, this proposes allowing the same for unconstrained parameters
This is also one of the reasons why this proposal would be beneficial, as users currently have to perform this serialisation themselves. By handling this internally, and including validation checks, we can easily remove a source of user error.
We've already had a request for it. Additionally, it's a very simple implementation:
Imo, a trivial amount of work to improve user experience |
perhaps I misunderstood the proposal - what does the input for a matrix look like? also, no feature is a trivial amount of work - in order to avoid future maintenance headaches, it must be thoroughly documented and tested. |
The same as for data and initial values (either an R matrix or dataframe), we then handle the serialisation internally |
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:
The unconstrained parameters would need to be passed as a four-element numeric vector:
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:
And then handle the ordering internally when mapping to a single vector of values.
Thoughts?
The text was updated successfully, but these errors were encountered: