(Euler-Maruyama_and_SDEs)=
:::{post} July 2016 :tags: time series :category: advanced, reference :author: @maedoc :::
This notebook is derived from a presentation prepared for the Theoretical Neuroscience Group, Institute of Systems Neuroscience at Aix-Marseile University.
Here's a scalar linear SDE in symbolic form
$ dX_t = \lambda X_t + \sigma^2 dW_t $
discretized with the Euler-Maruyama scheme.
We can simulate data from this process and then attempt to recover the parameters.
What is the inference we want to make? Since we've made a noisy observation of the generated time series, we need to estimate both $x(t)$ and $\lambda$.
We need to provide an SDE function that returns the drift and diffusion coefficients.
The probability model is comprised of a prior on the drift parameter lam, the diffusion coefficient s, the latent Euler-Maruyama process xh and the likelihood describing the noisy observations zh. We will assume that we know the observation noise.
Once the model is constructed, we perform inference, which here is via the NUTS algorithm as implemented in nutpie, which will be extremely fast.
Next, we plot some basic statistics on the samples from the posterior,
A model can fit the data precisely and still be wrong; we need to use posterior predictive checks to assess if, under our fit model, the data our likely.
In other words, we
Note that the initial conditions are also estimated, and that most of the observed data $z(t)$ lies within the 95% interval of the PPC.
Another approach is to look at draws from the sampling distribution of the data relative to the observed data. This too shows a good fit across the range of observations -- the posterior predictive mean almost perfectly tracks the data.
:::{bibliography} :filter: docname in docnames :::