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

--info include information parameter transforms #1461

Open
andrewfowlie opened this issue Oct 30, 2024 · 4 comments · May be fixed by #1462
Open

--info include information parameter transforms #1461

andrewfowlie opened this issue Oct 30, 2024 · 4 comments · May be fixed by #1462
Labels
feature New feature or request

Comments

@andrewfowlie
Copy link

Could the stanc --info command include information about constraints? At the moment, e.g.,

parameters {
  real<lower=0, upper=1> theta;
}

and

parameters {
  real theta;
}

both result in identical output,

{
  "inputs": {},
  "parameters": { "theta": { "type": "real", "dimensions": 0 } },
  "transformed parameters": {},
  "generated quantities": {},
  "functions": [],
  "distributions": [],
  "included_files": []
}

that doesn't mention the constraints. It would be great if the one with constraints gave something like,

{
  "inputs": {},
  "parameters": { "theta": { "type": "real", "dimensions": 0, "lower": 0, "upper": 1 } },
  "transformed parameters": {},
  "generated quantities": {},
  "functions": [],
  "distributions": [],
  "included_files": []
}

Ideally, this would work everywhere (i.e., in all the blocks), and cover the shift and scale modifiers as well.

@andrewfowlie andrewfowlie added the feature New feature or request label Oct 30, 2024
@WardBrian
Copy link
Member

I believe we could include transform information (e.g. this, but also something like "this is a simplex"). Note that the actual bound may not be a simple number, so in general the output may not be that useful. E.g,

parameters {
  real a;
  real <lower=exp(a) - 3> b;
}

The output would now have to contain something like "lower": "exp(a) - 3", so you can't assume you just get a number there

@andrewfowlie
Copy link
Author

That’s very true. I suppose it’s also true of the dimension.

I would find this very useful - I want to be able to infer programmatically (statically, not at runtime) whether we’re operating on a constrained space or not.

@WardBrian WardBrian changed the title --info include information about lower and upper --info include information parameter transforms Oct 30, 2024
@WardBrian WardBrian linked a pull request Oct 30, 2024 that will close this issue
3 tasks
@bob-carpenter
Copy link
Contributor

I suppose it’s also true of the dimension.

For dimension, it has to be static data. So we can resolve the sizes as soon as the data is fixed. The bounds can't be resolved until we have parameter draws.

@WardBrian
Copy link
Member

#904 asked about the dimension information. It was never implemented.

It does seem like it is probably reasonable to know that a variable has a lower bound, even if the exact lower bound is some expression you can't resolve on the outside.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants