Skip to content

Commit fb4354b

Browse files
committed
fix user's guide to use new solver functions, fixes #712
1 parent 0a08e8a commit fb4354b

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

src/bibtex/all.bib

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,3 +1834,14 @@ @article{Vehtari+etal:2021:Rhat
18341834
volume=16,
18351835
pages={667--718}
18361836
}
1837+
1838+
@article{Timonen+etal:2023:ODE-PSIS,
1839+
title={An importance sampling approach for reliable and efficient inference in {Bayesian} ordinary differential equation models},
1840+
author={Timonen, Juho and Siccha, Nikolas and Bales, Ben and L{\"a}hdesm{\"a}ki, Harri and Vehtari, Aki},
1841+
journal={Stat},
1842+
year={2023},
1843+
volume = 12,
1844+
number = 1,
1845+
pages = {e614}
1846+
}
1847+

src/stan-users-guide/algebraic-equations.qmd

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ vector for parameters if the system does not involve data or parameters.
8484
Let's suppose $\theta = (3, 6)$. To call the algebraic solver, we need to
8585
provide an initial guess. This varies on a case-by-case basis, but in general
8686
a good guess will speed up the solver and, in pathological cases, even determine
87-
whether the solver converges or not. If the solver does not converge, the metropolis
87+
whether the solver converges or not. If the solver does not converge, the Metropolis
8888
proposal gets rejected and a warning message, stating no acceptable solution was
8989
found, is issued.
9090

@@ -107,7 +107,7 @@ transformed parameters {
107107
vector[2] theta = [3, 6]';
108108
vector[2] y;
109109
110-
y = algebra_solver_newton(system, y_guess, theta, x_r, x_i);
110+
y = solve_newton(system, y_guess, theta, x_r, x_i);
111111
}
112112
```
113113

@@ -137,24 +137,26 @@ For instance, it might make "physical sense" for a solution to be positive or ne
137137

138138
On the other hand, a system may not have a solution (for a given point in the parameter
139139
space). In that case, the solver will not converge to a solution. When the solver fails to
140-
do so, the current metropolis proposal gets rejected.
140+
do so, the current Metropolis proposal gets rejected.
141141

142142
## Control parameters for the algebraic solver {#algebra-control.section}
143143

144-
The call to the algebraic solver shown previously uses the default control settings. The solver
145-
allows three additional parameters, all of which must be supplied if any of them is
146-
supplied.
144+
The call to the algebraic solver shown previously uses the default control settings. The `_tol` variant of the solver function
145+
allows three additional parameters, all of which must be supplied.
147146

148147
```stan
149-
y = algebra_solver_newton(system, y_guess, theta, x_r, x_i,
150-
rel_tol, f_tol, max_steps);
148+
y = solve_newton_tol(system, y_guess, theta, x_r, x_i,
149+
scaling_step, f_tol, max_steps);
151150
```
152151

153-
The three control arguments are relative tolerance, function tolerance, and maximum
154-
number of steps. Both tolerances need to be satisfied. If one of them is not met, the
155-
metropolis proposal gets rejected with a warning message explaining which criterion
156-
was not satisfied. The default values for the control arguments are respectively
157-
`rel_tol = 1e-10` ($10^{-10}$), `f_tol = 1e-6` ($10^{-6}$), and `max_steps = 1e3` ($10^3$).
152+
For the Newton solver the three control arguments are scaling step, function tolerance, and maximum number of steps. For the Powell's hybrid method the three control arguments are relative tolerance, function tolerance, and maximum number of steps. If a Newton step is smaller than the scaling step tolerance, the code breaks, assuming the solver is no longer making significant progress. If set to 0, this constraint is ignored. For Powell's hybrid method the relative tolerance is the estimated relative error of the solver and serves to test if a satisfactory solution has been found. After convergence of the either solver, the proposed solution
153+
is plugged into the algebraic system and its norm is compared to the function tolerance. If the norm is below the function tolerance, the solution is deemed acceptable. If the solver solver reaches the maximum number of steps, it stops and returns an error message. If one of the criteria is not met, the
154+
Metropolis proposal gets rejected with a warning message explaining which criterion
155+
was not satisfied.
156+
157+
158+
The default values for the control arguments are respectively
159+
`scaling_step = 1e-3` ($10^{-3}$), `rel_tol = 1e-10` ($10^{-10}$), `f_tol = 1e-6` ($10^{-6}$), and `max_steps = 200` ($200$).
158160

159161
### Tolerance {-}
160162

@@ -172,12 +174,12 @@ Smaller relative tolerances produce more accurate solutions but require more com
172174
#### Sensitivity analysis {-}
173175

174176
The tolerances should be set low enough that setting them lower does not change the
175-
statistical properties of posterior samples generated by the Stan program.
177+
statistical properties of posterior samples generated by the Stan program. The sensitivity can be analysed using importance sampling without need to re-run MCMC with different tolerances as shown by @Timonen+etal:2023:ODE-PSIS.
176178

177179
### Maximum number of steps {-}
178180

179181
The maximum number of steps can be used to stop a runaway simulation. This can arise in
180182
MCMC when a bad jump is taken, particularly during warmup. If the limit is hit, the
181-
current metropolis proposal gets rejected. Users will see a warning message stating the
183+
current Metropolis proposal gets rejected. Users will see a warning message stating the
182184
maximum number of steps has been exceeded.
183185

0 commit comments

Comments
 (0)