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

Share:

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

1
2
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 A.D., Quinn K.M., Park J.H. (2011) MCMCpack: Markov chain Monte Carlo in R, Journal of Statistical Software 42(9), 1–21. http://www.jstatsoft.org/v42/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. http://dx.doi.org/10.1007/s00382-013-1804-y.

Examples

1
2
3
4
5
6
# 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")