You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update index.qmd with edge case for data-fitting (#631)
* Update index.qmd with edge case for data-fitting
This case came from attempting to adapt the code to fitting experimental data to an ODE model derived from chemical equations. It turns out that using the Normal distribution is recommended in the general case according to one of my supervisors.
* Update tutorials/bayesian-differential-equations/index.qmd
---------
Co-authored-by: Penelope Yong <[email protected]>
Copy file name to clipboardExpand all lines: tutorials/bayesian-differential-equations/index.qmd
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -82,6 +82,7 @@ To make the example more realistic, we generate data as random Poisson counts ba
82
82
Poisson-distributed data are common in ecology (for instance, counts of animals detected by a camera trap).
83
83
We'll assume that the rate $\lambda$, which parameterizes the Poisson distribution, is proportional to the underlying animal densities via a constant factor $q = 1.7$.
84
84
85
+
85
86
```{julia}
86
87
sol = solve(prob, Tsit5(); saveat=0.1)
87
88
q = 1.7
@@ -108,11 +109,12 @@ Practically, this helps us to illustrate the results without needing to run over
108
109
Note we also have to take special care with the ODE solver.
109
110
For certain parameter combinations, the numerical solver may predict animal densities that are just barely below zero.
110
111
This causes errors with the Poisson distribution, which needs a non-negative mean $\lambda$.
111
-
To avoid this happening, we tell the solver to aim for small abolute and relative errors (`abstol=1e-6, reltol=1e-6`).
112
+
To avoid this happening, we tell the solver to aim for small absolute and relative errors (`abstol=1e-6, reltol=1e-6`).
112
113
We also add a fudge factor `ϵ = 1e-5` to the predicted data.
113
114
Since `ϵ` is greater than the solver's tolerance, it should overcome any remaining numerical error, making sure all predicted values are positive.
114
115
At the same time, it is so small compared to the data that it should have a negligible effect on inference.
115
116
If this approach doesn't work, there are some more ideas to try [here](https://docs.sciml.ai/DiffEqDocs/stable/basics/faq/#My-ODE-goes-negative-but-should-stay-positive,-what-tools-can-help?).
117
+
In the case of continuous observations (e.g. data derived from modelling chemical reactions), it is sufficient to use a normal distribution with the mean as the data point and an appropriately chosen variance (which can itself also be a parameter with a prior distribution).
0 commit comments