Description
Interface to the 'C++' Library 'Pf'.
Description
Builds and runs 'c++' code for classes that encapsulate state space model, particle filtering algorithm pairs. Algorithms include the Bootstrap Filter from Gordon et al. (1993) <doi:10.1049/ip-f-2.1993.0015>, the generic SISR filter, the Auxiliary Particle Filter from Pitt et al (1999) <doi:10.2307/2670179>, and a variety of Rao-Blackwellized particle filters inspired by Andrieu et al. (2002) <doi:10.1111/1467-9868.00363>. For more details on the 'c++' library 'pf', see Brown (2020) <doi:10.21105/joss.02599>.
README.md
pfR
pfR is the R interface to the c++ particle filtering library pf.
Have a new model you want to quickly write a particle filter for? Quickly generate 99% of the code, fill in your model/algorithm details, and then compile.
Step 1: Download
Either clone this repository, or type the following into R:
devtools::install_github("tbrown122387/pfr")
Step 2: Auto-generate code
Pick your particle filter, generate most of the required c++ code, then fill in the rest. For example,
library(pfr)
createPFCPPTemplates("svol_leverage", "BSWC", fileDir = "~/Desktop/")
Saves three files to your desktop: svol_leverage_bswc.h
, svol_leverage_bswc.cpp
, and svol_leverage_bswc_export.cpp
. After you're finished filling in the details, they should look like this, this, and this, respectively.
Step 3: Compile and Load
Compile the c++ code with
svol_lev <- buildModelFuncs("~/Desktop", "svol_leverage")
Step 4: Run
Call your model's functions with
svol_lev$svol_leverage_bswc_approx_LL(rnorm(100), c(.9, 0.0, 1.0, -.2))
svol_lev$svol_leverage_bswc_approx_filt(rnorm(100), c(.9, 0.0, 1.0, -.2))