inferfmetrop {HKprocess} | R Documentation |
Posterior distribution of the φ parameter of the AR(1) process, using a Metropolis algorithm.
Description
The function inferfmetrop is used to create a sample from the posterior distribution of φ. The function uses the eq.10 in Tyralis and Koutsoyiannis (2014) and a Metropolis algorithm to make inference on φ.
Usage
inferfmetrop(data, theta.init = 0.7, burnin = 500, mcmc = 20000, thin = 1,
tune = 1, verbose = 0, seed = NA)
Arguments
data |
time series data |
theta.init |
Starting values for the sampling. Must be of the appropriate
dimension. It must also be the case that |
burnin |
The number of burn-in iterations for the sampler. |
mcmc |
The number of MCMC iterations after burnin. |
thin |
The thinning interval used in the simulation. The number of MCMC iterations must be divisible by this value. |
tune |
The tuning parameter for the Metropolis sampling. Can be either a
positive scalar or a |
verbose |
A switch which determines whether or not the progress of the
sampler is printed to the screen. If |
seed |
The seed for the random number generator. If NA, the Mersenne
Twister generator is used with default seed 12345; if an integer is passed it is
used to seed the Mersenne twister. The user can also pass a list of length two
to use the L'Ecuyer random number generator, which is suitable for parallel
computation. The first element of the list is the L'Ecuyer seed, which is a
vector of length six or NA (if NA a default seed of |
Value
An mcmc object that contains the posterior sample. This object can be summarized by functions provided by the coda package.
Note
The Metropolis algorithm uses the function MCMCmetrop1R from the package MCMCpack (Martin et al. 2011).
Author(s)
Hristos Tyralis
References
Martin AD, Quinn KM, Park JH (2011) MCMCpack: Markov chain Monte Carlo in R. Journal of Statistical Software 42(9):1–21. doi:10.18637/jss.v042.i09.
Tyralis H, Koutsoyiannis D (2014) A Bayesian statistical model for deriving the predictive distribution of hydroclimatic variables. Climate Dynamics 42(11-12):2867–2883. doi:10.1007/s00382-013-1804-y.
Examples
# Posterior distribution of the phi parameter of the AR(1) process for the Nile
# time series.
samp.sim <- inferfmetrop(Nile, theta.init = 0.7, burnin = 500, mcmc = 500,
thin = 1, tune = 1, seed = 12345)
hist(samp.sim, breaks = 20, main = expression(paste("Histogram of ",phi)),
xlab = expression(phi))