particleFilter: Run a particle filter for fitmodel object

View source: R/smc.r

particleFilterR Documentation

Run a particle filter for fitmodel object

Description

The particle filter returns an estimate of the marginal log-likelihood L = p(y(t_{1:T})|\theta) as well as the set of filtered trajectories and their respective weights at the last observation time \omega(t_T)=p(y(t_T)|\theta).

Usage

particleFilter(fitmodel, theta, initState, data, nParticles, progress = FALSE)

Arguments

fitmodel

a fitmodel object

theta

named numeric vector. Values of the parameters. Names should match fitmodel$thetaNames.

initState

named numeric vector. Initial values of the state variables. Names should match fitmodel$stateNames.

data

data frame. Observation times and observed data. The time column must be named "time" and the observation column must be named "obs".

nParticles

number of particles

progress

if TRUE progression of the filter is displayed in the console.

Value

A list of 3 elements:

  • dPointObs the marginal log-likelihood of the theta.

  • traj a list of size nParticles with all filtered trajectories.

  • trajWeight a vector of size nParticles with the normalised weight of the filtered trajectories.

Note

An unbiased state sample x(t_{0:T}) ~ p(X(t_{0:T})|\theta,y(t_{0:T})) can be obtained by sampling the set of trajectories traj with probability trajWeight.

See Also

plotSMC


sbfnk/fitR documentation built on July 18, 2023, 3:28 p.m.