particleFilterSVmodel: Bootstrap particle filter for state estimate in a simple...

Description Usage Arguments Value Note Author(s) References Examples

View source: R/stateEstimation.R

Description

Estimates the filtered state and the log-likelihood for a stochastic volatility model of the form x_t = μ + φ ( x_{t-1} - μ ) + σ_v v_t and y_t = \exp(x_t/2) e_t, where v_t and e_t denote independent standard Gaussian random variables, i.e. N(0,1).

Usage

1
particleFilterSVmodel(y, theta, noParticles)

Arguments

y

Observations from the model for t=1,...,T.

theta

The parameters θ=\{μ,φ,σ_v\}. The mean of the log-volatility process is denoted μ. The persistence of the log-volatility process is denoted φ. The standard deviation of the log-volatility process is denoted σ_v.

noParticles

The number of particles to use in the filter.

Value

The function returns a list with the elements:

Note

See Section 5 in the reference for more details.

Author(s)

Johan Dahlin uni@johandahlin.com

References

Dahlin, J. & Schon, T. B. "Getting Started with Particle Metropolis-Hastings for Inference in Nonlinear Dynamical Models." Journal of Statistical Software, Code Snippets, 88(2): 1–41, 2019.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
  # Get the data from Quandl
  library("Quandl")
  d <- Quandl("NASDAQOMX/OMXS30", start_date="2012-01-02",
              end_date="2014-01-02", type="zoo")
  y <- as.numeric(100 * diff(log(d$"Index Value")))

  # Estimate the filtered state using a particle filter
  theta <- c(-0.10, 0.97, 0.15)
  pfOutput <- particleFilterSVmodel(y, theta, noParticles=100)

  # Plot the estimate and the true state
  par(mfrow=c(2, 1))
  plot(y, type="l", xlab="time", ylab="log-returns", bty="n",
    col="#1B9E77")
  plot(pfOutput$xHatFiltered, type="l", xlab="time",
    ylab="estimate of log-volatility", bty="n", col="#D95F02")

## End(Not run)

pmhtutorial documentation built on May 2, 2019, 3:25 a.m.