Skip to content
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

Annotation comment #55

Open
spinkney opened this issue Feb 21, 2025 · 3 comments
Open

Annotation comment #55

spinkney opened this issue Feb 21, 2025 · 3 comments

Comments

@spinkney
Copy link
Contributor

If we had annotations described in design doc 33 I believe it is a nice solution to allowing users to pick a parameterization of a constraint (if we had it). For example, we can have multiple cholesky factor corr parameterizations with the default that we find to work best in most cases. However a user could select a different one from the default (again, assuming we have it written in Stan-math) as

model {
 cholesky_factor_corr[N] L; // use default no annotation necessary
 @param(stick_breaking) cholesky_factor_corr[N] L2; // this annotation tells the compiler to use the stick breaking parameterization that Stan currently uses 
}

@WardBrian

@WardBrian
Copy link
Member

In the past we've talked about re-using <> for this, so your example would instead look like

model {
 cholesky_factor_corr[N] L; // use default no annotation necessary
 cholesky_factor_corr<transform=stick_breaking>[N] L2; // use the stick breaking parameterization that Stan currently uses 
}

I have a slight preference towards this more explicit style (especially since annotations are intended to be "ignore-able", but either would be implementable and it's definitely worth thinking about.

This was originally proposed by @syclik a few years ago when we were discussing how allowing compositions of lower/upper bounds and offset/multiplier exposes implementation details about which transforms are used, and he suggested one solution of that is to just intentionally expose the implementation detail and let people switch them out

@spinkney
Copy link
Contributor Author

Cool, I just didn't know if we'd allow strings like that since all the other values users put in to <> are numbers

@spinkney
Copy link
Contributor Author

I was thinking that the default parameterization would run if the annotation wasn't found or the compiler was told to ignore

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

No branches or pull requests

2 participants