example4_sv {pmhtutorial} | R Documentation |
Parameter estimation in a simple stochastic volatility model
Description
Minimal working example of parameter estimation in a stochastic volatility model using the particle Metropolis-Hastings algorithm with a bootstrap particle filter providing an unbiased estimator of the likelihood. The code estimates the parameter posterior for three parameters using real-world data.
Usage
example4_sv(noBurnInIterations = 2500, noIterations = 7500,
noParticles = 500, initialTheta = c(0, 0.9, 0.2),
syntheticData = FALSE)
Arguments
noBurnInIterations |
The number of burn-in iterations in the PMH
algorithm. Must be smaller than |
noIterations |
The number of iterations in the PMH algorithm. 100 iterations takes about a minute on a laptop to execute. |
noParticles |
The number of particles to use when estimating the likelihood. |
initialTheta |
The initial guess of the parameters theta. |
syntheticData |
If TRUE, data is not downloaded from the Internet. This is only used when running tests of the package. |
Details
The Particle Metropolis-Hastings (PMH) algorithm makes use of a Gaussian random walk as the proposal for the parameters. The data are scaled log-returns from the OMXS30 index during the period from January 2, 2012 to January 2, 2014.
This version of the code makes use of a proposal that is tuned using a run of
example3_sv
and therefore have better mixing
properties.
Value
The function returns the estimated marginal parameter posteriors for each parameter, the trace of the Markov chain and the resulting autocorrelation function. The data is also presented with an estimate of the log-volatility.
The function returns a list with the elements:
thhat: The estimate of the mean of the parameter posterior.
xhat: The estimate of the mean of the log-volatility posterior.
thhatSD: The estimate of the standard deviation of the parameter posterior.
xhatSD: The estimate of the standard deviation of the log-volatility posterior.
iact: The estimate of the integrated autocorrelation time for each parameter.
estCov: The estimate of the covariance of the parameter posterior.
Note
See Section 6.3.1 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
## Not run:
example4_sv(noBurnInIterations=200, noIterations=1000)
## End(Not run)