mcmc {gk}R Documentation

Markov chain Monte Carlo inference

Description

Markov chain Monte Carlo (MCMC) inference for the g-and-k or g-and-h distribution

Usage

mcmc(
  x,
  N,
  model = c("gk", "generalised_gh", "tukey_gh", "gh"),
  logB = FALSE,
  get_log_prior = improper_uniform_log_density,
  theta0,
  Sigma0,
  t0 = 100,
  epsilon = 1e-06,
  silent = FALSE,
  plotEvery = 100
)

Arguments

x

Vector of observations.

N

Number of MCMC steps to perform.

model

Which model to check: "gk", "generalised_gh" or "tukey_gh". For backwards compatibility, "gh" acts the same as "generalised_gh".

logB

When true, the second parameter is log(B) rather than B.

get_log_prior

A function with one argument (corresponding to a vector of 4 parameters e.g. A,B,g,k) returning the log prior density. This should ensure the parameters are valid - i.e. return -Inf for invalid parameters - as the mcmc code will not check this.

theta0

Vector of initial value for 4 parameters.

Sigma0

MCMC proposal covariance matrix

t0

Tuning parameter (number of initial iterations without adaptation).

epsilon

Tuning parameter (weight given to identity matrix in covariance calculation).

silent

When FALSE (the default) a progress bar and intermediate results plots are shown.

plotEvery

How often to plot the results if silent==FALSE.

Details

mcmc performs Markov chain Monte Carlo inference for iid data from a g-and-k or g-and-h distribution, using the adaptive Metropolis algorithm of Haario et al (2001).

Value

Matrix whose rows are MCMC states: the initial state theta0 and N subsequent states.

References

D. Prangle gk: An R package for the g-and-k and generalised g-and-h distributions, 2017. H. Haario, E. Saksman, and J. Tamminen. An adaptive Metropolis algorithm. Bernoulli, 2001.

Examples

set.seed(1)
x = rgk(10, A=3, B=1, g=2, k=0.5) ##An unusually small dataset for fast execution of this example
out = mcmc(x, N=1000, theta0=c(mean(x),sd(x),0,0), Sigma0=0.1*diag(4))

[Package gk version 0.6.0 Index]