pfLineartBS: Particle Filter Example

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/pfLineartBS.R

Description

The pfLineartBS function provides a simple example for RcppSMC. It is based on the first example in SMCTC and the discussion in Section 5.1 of Johansen (2009). A simple 'vehicle tracking' problem of 100 observations is solved with 1000 particles.

The pfLineartBSOnlinePlot function provides a simple default ‘online’ plotting function that is invoked during the estimation process.

The simLineart function simulates data from the model.

Usage

1
2
3
  pfLineartBS(data, particles=1000, plot=FALSE, onlinePlot) 
  pfLineartBSOnlinePlot(xm, ym)
  simLineart(len)

Arguments

data

A two-column matrix or dataframe containing x and y values. The default data set from Johansen (2009) is used as the default if no data is supplied.

particles

An integer specifying the number of particles.

plot

A boolean variable describing whether plot should illustrate the estimated path along with the data.

onlinePlot

A user-supplied callback function which is called with the x and y position vectors during each iteration of the algorithm; see pfExOnlinePlot for a simple example.

xm

Vector with x position.

ym

Vector with y position.

len

Length of sequence to simulate

Details

The pfLineartBS function provides a simple example for RcppSMC. The model is linear with t-distributed innovations. It is based on the pf example in the SMCTC library, and discussed in the Section 5.1 of his corresponding paper (Johansen, 2009). simLineart simulates from the model.

Using the simple pfExOnlinePlot function illustrates how callbacks into R, for example for plotting, can be made during the operation of SMC algorithm.

Value

The pfLineartBS function returns a data.frame containing as many rows as in the input data, and four columns corresponding to the estimated x and y coordinates as well as the estimated velocity in these two directions.

The simLineart function returns a list containing the vector of states and the associated vector of observations.

Author(s)

Adam M. Johansen and Dirk Eddelbuettel

References

A. M. Johansen. SMCTC: Sequential Monte Carlo in C++. Journal of Statistical Software, 30(6):1-41, April 2009. http://www.jstatsoft.org/v30/i06/paper

See Also

The SMCTC paper and code at http://www.jstatsoft.org/v30/i06/paper.

Examples

1
2
3
  res <- pfLineartBS(plot=TRUE)
  if (interactive()) ## if not running R CMD check etc
     res <- pfLineartBS(onlinePlot=pfLineartBSOnlinePlot)

Example output



RcppSMC documentation built on May 2, 2019, 6:45 p.m.

Related to pfLineartBS in RcppSMC...