particle_deterministic_state: Deterministic particle state

particle_deterministic_stateR Documentation

Deterministic particle state

Description

Deterministic particle internal state. This object is not ordinarily constructed directly by users, but via the ⁠$run_begin⁠ method to particle_deterministic. It provides an advanced interface to the deterministic particle that allows partially running over part of the time trajectory.

This state object has a number of public fields that you can read but must not write (they are not read-only so you could write them, but don't).

Public fields

model

The dust model being simulated

history

The particle history, if created with save_history = TRUE.

restart_state

Full model state at a series of points in time, if the model was created with non-NULL save_restart. This is a 3d array as described in particle_filter

log_likelihood

The log-likelihood so far. This starts at 0 when initialised and accumulates value for each step taken.

current_time_index

The index of the last completed step.

Methods

Public methods


Method new()

Initialise the deterministic particle state. Ordinarily this should not be called by users, and so arguments are barely documented.

Usage
particle_deterministic_state$new(
  pars,
  generator,
  model,
  data,
  data_split,
  times,
  has_multiple_parameters,
  n_threads,
  initial,
  index,
  compare,
  constant_log_likelihood,
  save_history,
  save_restart,
  stochastic_schedule,
  ode_control
)
Arguments
pars

Parameters for a single phase

generator

A dust generator object

model

If the generator has previously been initialised

data

A particle_filter_data data object

data_split

The same data as data but split by step

times

A matrix of time step beginning and ends

has_multiple_parameters

Compute multiple likelihoods at once?

n_threads

The number of threads to use

initial

Initial condition function (or NULL)

index

Index function (or NULL)

compare

Compare function

constant_log_likelihood

Constant log likelihood function

save_history

Logical, indicating if we should save history

save_restart

Vector of time steps to save restart at

stochastic_schedule

Vector of times to perform stochastic updates

ode_control

Tuning control for stepper


Method run()

Run the deterministic particle to the end of the data. This is a convenience function around ⁠$step()⁠ which provides the correct value of time_index

Usage
particle_deterministic_state$run()

Method step()

Take a step with the deterministic particle. This moves the system forward one step within the data (which may correspond to more than one step with your model) and returns the likelihood so far.

Usage
particle_deterministic_state$step(time_index)
Arguments
time_index

The step index to move to. This is not the same as the model step, nor time, so be careful (it's the index within the data provided to the filter). It is an error to provide a value here that is lower than the current step index, or past the end of the data.


Method fork_multistage()

Create a new deterministic_particle_state object based on this one (same model, position in time within the data) but with new parameters, to support the "multistage particle filter".

Usage
particle_deterministic_state$fork_multistage(model, pars, transform_state)
Arguments
model

A model object

pars

New model parameters

transform_state

A function to transform the model state from the old to the new parameter set. See multistage_epoch() for details.


mrc-ide/mcstate documentation built on July 3, 2024, 1:34 p.m.