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.
pfLineartBS(data, particles=1000, plot=FALSE, onlinePlot)
pfLineartBSOnlinePlot(xm, ym)
simLineart(len)
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.
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.
An integer specifying the number of particles.
A boolean variable describing whether plot should illustrate the estimated path along with the data.
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.
Vector with x position.
Vector with y position.
Length of sequence to simulate
Adam M. Johansen and Dirk Eddelbuettel
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.
A. M. Johansen. SMCTC: Sequential Monte Carlo in C++. Journal of Statistical Software, 30(6):1-41, April 2009, tools:::Rd_expr_doi("10.18637/jss.v030.i06").
The SMCTC paper and code at tools:::Rd_expr_doi("10.18637/jss.v030.i06").
res <- pfLineartBS(plot=TRUE)
if (interactive()) ## if not running R CMD check etc
res <- pfLineartBS(onlinePlot=pfLineartBSOnlinePlot)
Run the code above in your browser using DataLab