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.
The number of burn-in iterations in the PMH
algorithm. Must be smaller than
The number of iterations in the PMH algorithm. 100 iterations takes about a minute on a laptop to execute.
The number of particles to use when estimating the likelihood.
The initial guess of the parameters theta.
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 pilot run. Furthermore the model is reparameterised to enjoy better mixing properties by making the parameters unrestricted to a certain part of the real-line.
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.
See Section 6.3.2 in the reference for more details.
Johan Dahlin <uni (at) johandahlin.com.nospam>
Dahlin, J. & Sch<c3><b6>n, T. B. "Getting started with particle Metropolis-Hastings for inference in nonlinear dynamical models." pre-print, arXiv:1511.01707, 2017.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.