Output of `optimizing` does not return the number of used iterations or reason why the optimization was terminated
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 1.1k
- Forks
- 266
- Avg merge
- 2h 56m
- Merged PRs (30d)
- 1
Description
It would be great if the output of optimizing contained the number of iterations the optimizer ran. This could be then to check whether the optimization terminated because of hitting the maximum number of iterations. Even better solution would be to get the actual reason for the termination from the output, which is currently only available in the print when verbose = TRUE, but I understand that this is likely more difficult due to the way rstan works.
Example
library(rstan)
m <- stan_model(
model_code = "
transformed data {
vector[2] y = [5, 10.2]';
}
parameters {
real x;
}
model {
y ~ normal(x, 1);
}")
f <- optimizing(m, iter = 2, verbose = TRUE)
str(f)
Chain 1: Initial log joint probability = -38.2441
Chain 1: Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
Chain 1: 1 -26.9098 1.12221 8.97772 0.1 0.001 4
Chain 1: Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
Chain 1: 2 -6.76 4.48886 7.10543e-15 1 1 5
Chain 1: Optimization terminated normally:
Chain 1: Convergence detected: gradient norm is below tolerance
str(f)
List of 4
$ par : Named num 7.6
..- attr(*, "names")= chr "x"
$ value : num -6.76
$ return_code: int 0
$ theta_tilde: num [1, 1] 7.6
..- attr(*, "dimnames")=List of 2
.. ..$ : NULL
.. ..$ : chr "x"
RStan Version:
2.32.6
R Version:
4.3.0
Operating System:
Windows 10
Contributor guide
No contributing guide indexed for this repository
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 at the optimizing() entry point and compare its returned list with the verbose termination output shown in the example. Done means the result exposes the optimizer's iteration count and, if feasible, the termination reason, with behavior represented in the existing optimizing() tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100