Skip to contents

Compute a log likelihood based on a dynamical model, either from particle filter (created with dust_filter_create) or a deterministic model (created with dust_unfilter_create).

Usage

dust_likelihood_run(
  obj,
  pars,
  initial = NULL,
  save_history = FALSE,
  adjoint = NULL,
  index_group = NULL
)

Arguments

obj

A dust_filter object, created by dust_filter_create or a dust_unfilter object created by dust_unfilter_create

pars

Optional parameters to compute the likelihood with. If not provided, parameters are not updated

initial

Optional initial conditions, as a matrix (state x particle) or 3d array (state x particle x group). If not provided, the system initial conditions are used.

save_history

Logical, indicating if the simulation history should be saved while the simulation runs; this has a small overhead in runtime and in memory. History (particle trajectories) will be saved at each time for which you have data. If obj was constructed using a non-NULL index_state parameter, the history is restricted to these states.

adjoint

Optional logical, indicating if we should enable adjoint history saving. This is enabled by default if your model has an adjoint, but can be disabled or enabled even when your model does not support adjoints! But if you don't actually have an adjoint you will not be able to compute gradients. This has no effect for stochastic models.

index_group

An optional vector of group indices to run the calculation for. You can use this to run a subset of possible groups, once obj is initialised (this argument must be NULL on the first call).

Value

A vector of likelihood values, with as many elements as there are groups.