inferHmetrop: Posterior distribution of the H parameter of the HKp, using a...

View source: R/inferHmetrop.R

inferHmetropR Documentation

Posterior distribution of the H parameter of the HKp, using a Metropolis algorithm.

Description

The function inferfmetrop is used to create a sample from the posterior distribution of H. The function uses the eq.10 in Tyralis and Koutsoyiannis (2014) and a Metropolis algorithm to make inference on H.

Usage

inferHmetrop(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 fun(theta.init, ...) is greater than -Inf.

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 k-vector, where k is the length of theta.

verbose

A switch which determines whether or not the progress of the sampler is printed to the screen. If verbose is greater than 0 the iteration number, the theta vector, the function value, and the Metropolis acceptance rate are sent to the screen every verboseth iteration.

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 rep(12345,6) is used). The second element of list is a positive substream number. See the MCMCpack specification for more details.

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 H parameter of the HKp for the Nile time series.

samp.sim <- inferHmetrop(Nile, theta.init = 0.7, burnin = 500, mcmc = 500,
    thin = 1, tune = 1, seed = 12345)

hist(samp.sim, breaks = 20, main = "Histogram of H", xlab = "H")

HKprocess documentation built on Oct. 27, 2022, 1:06 a.m.