Merge Transformed Parameters and Model Blocks
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.8k
- Forks
- 388
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 15
Description
Summary:
The point of this feature request is to merge the transformed parameters and model blocks, as the added complexity of having them be separate entities seems unnecessary.
Description:
The idea will be to make the following changes to the language:
- Make global variables in model block be in scope in
generated quantitiesblock, as would be the case fortransformed parameters; - Write them to your sample, as you would for
transformed parameters; - At this point, there is not more distinction between the
transformed parametersandmodelblocks except thattargetis in scope inmodelbut nottransformed parameters, so we might as well merge the two blocks.
Observe that the current behaviour can be reproduced by using a local scope, to ensure that variables do not get written to the sample or are in scope in generated quantities.
Reproducible Steps:
Run
model {
real x = 1;
}
generated quantities {
print(x);
}
Current Output:
This throws an error as x is not in scope in generated quantities. Nor does it get written to the sample.
This is confusing.
Expected Output:
No error. A program that prints 1 in the generated quantities phase and writes 1 to the sample.
Additional Information:
People I have spoken to have been confused about the distinction between transformed parameters and model and have been confused that model level global vars are not in scope in the generated quantities block.
The scoping mechanism should moreover control whether a variable ends up in the sample.
Current Version:
v2.18.0
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
The issue provides no implementation files or tests to begin with. Start by reviewing Stan's current transformed parameters and model scoping and sample-output behavior, using the supplied model/generated quantities example as the acceptance case. Done means model-block variables are available in generated quantities, written to the sample, and the two blocks are merged without removing model access to target.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100