Defining the observational scheme
To run the MCMC sampler we need to pass a setup
object that defines the statistical model. In this section we will show how to define a diffusion model using a pre-defined DiffusionSetup
. Nonetheless, be aware that the logic of the MCMC sampler is independent from the model specification, so it is possible to use the mcmc
routines from this package and run them on other statistical models. For more information about these types of extensions see Generic MCMC.
Defining the processes
To define the DiffusionSetup
we need to decide on the Target
diffusion, an Auxiliary
diffusion and the observation scheme. For instance, suppose that there are three observations:
obs = [...]
obs_times = [1.0, 2.0, 3.0]
Then we define the target
diffusion globally and the auxiliary
diffusion separately on each interval
P_target = TargetDiffusion(parameters)
P_auxiliary = [AuxiliaryDiffusion(parameters, o, t) for (o,t) in zip(obs, obs_times)]
To define the setup for partially observed diffusion it is enough to write:
model_setup = DiffusionSetup(P_target, P_auxiliary, PartObs()) # for first passage times use FPT()
BridgeSDEInference.DiffusionSetup
— TypeDiffusionSetup{ObsScheme} <: ModelSetup
Setup choices relevant to the path augmentation step to be passed to mcmc
function from mcmc.jl
.
Example:
DiffusionSetup(P, P̃)
DiffusionSetup(P, P̃, fptOrPartObs)
where P is the target process and P̃ is the linear approximation and possibly a vector of Booleans whether the observations are first passage times.
Observations
To set the observations, in addition to passing the observations and observation times it is necessary to pass the observational operators as well as covariance of the noise. Additionally, one can pass additional information about the first passage time scheme.
L = ...
Σ = ...
set_observations!(model_setup, [L for _ in obs], [Σ for _ in obs], obs, obs_time)
Missing docstring for set_observations!
. Check Documenter's build log for details.
Imputation grid
There are two objects that define the imputation grid. The time step dt
and the time transformation that transforms a regular time-grid with equidistantly distributed imputation points. The second defaults to a usual transformation employed in papers on the guided proposals. [TO DO add also space-time transformation from the original paper for the bridges]. It is enough to call
dt = ...
set_imputation_grid!(model_setup, dt)
BridgeSDEInference.set_imputation_grid!
— Functionset_imputation_grid!(setup::DiffusionSetup, dt,
time_transf=(t₀,T) -> ((x) -> t₀ + (x-t₀) * (2-(x-t₀)/(T-t₀))))
Define the imputation grid in setup
. dt
defines the granulatrity of the imputation grid and time_transf
defines a time transformation to use for transforming equidistant grid.
Prior over the starting point
There are two types of priors for the starting point, either a delta hit
at some specified value, corresponding to a known starting point and a Gaussian prior
BridgeSDEInference.KnownStartingPt
— TypeKnownStartingPt{T} <: StartingPtPrior
Indicates that the starting point is known and stores its value in y
BridgeSDEInference.GsnStartingPt
— TypeGsnStartingPt{T,S} <: StartingPtPrior
Indicates that the starting point is equipped with a Gaussian prior with mean μ
and covariance matrix Σ
. It also stores the most recently sampled white noise z
used to compute the starting point and a precision matrix Λ
:=Σ
⁻¹. μ₀
and Σ₀
are the mean and covariance of the white noise
GsnStartingPt(μ::T, Σ::S)
Base constructor. It initialises the mean μ
and covariance Σ
parameters and Λ
is set according to Λ
:=Σ
⁻¹
For instance, to set a known starting point it is enough to call:
set_x0_prior!(model_setup, KnownStartingPt(x0))
BridgeSDEInference.set_x0_prior!
— Functionset_x0_prior!(setup::DiffusionSetup, x0_prior, x0_guess=nothing)
Store the priors over the starting point into the object setup
.
Auxiliary parameters
There are two auxiliary parameters that can be set by the user. The first one is a thinning factor for saving the paths that are sampled by the MCMC sampler. The second specifies an adaptation scheme for tuning Guided proposals [TODO change the latter].
Missing docstring for set_auxiliary!
. Check Documenter's build log for details.
Initialisation of internal containers
Once all the setting functions above have been run (with the only exception set_auxiliary!
being optional), i.e.
setup = DiffusionSetup(...)
set_observations!(setup, ...)
set_imputation_grid(setup, ...)
set_x0_prior!(setup, ...)
then the following function should be run
BridgeSDEInference.initialise!
— Functioninitialise(::Type{K}, setup::DiffusionSetup; verbose=false,
change_pt=NoChangePt())
Initialise the internal containers of setup
. Check if all the necessary data has been passed to setup
Once run, the model setup is complete.