mcmc: GammaModel::mcmc

Description Usage Arguments Details Value References Examples

View source: R/functions.R

Description

Generates a single Markov Chain Monte Carlo (MCMC) chain of Gamma distribution parameter samples, using the Metropolis-Hastings algorithm.

Usage

1
2
	mcmc(counts, class.ages = NULL, N = 30000, burn = 2000, thin = 5, prop = 0.4, plot.chain = TRUE)
	

Arguments

counts

A one-row data frame comprising integer counts, with column names in capital letters. Formatting requirements detailed in checkCountsFormat.

class.ages

An optional one-row data frame specifying the starting age of each age-class. Age-classes as column names.

N

An optional integer specifying how many samples in the chain.

burn

An optional integer specifying how many initial samples in the chain should be discarded for burn-in.

thin

An optional integer specifying the proportion of samples to discard. I.e. 5 = every 5th sample in the chain is retained.

prop

An optional numerical value controlling the average jump size in the proposal function.

plot.chain

An optional logical value indicating if the chain should be plotted after completion.

Details

Prints progress every 1000th sample, and the final acceptance rate. For an efficient chain this should be around 0.3 to 0.6. If the rate is too low, efficiency can be improved by lowering the value of the prop argument.

The chain can be inspected to ensure good mixing using the default plot.chain = TRUE.

Value

Data frame of two columns, giving the Gamma parameters ('shape' and 'mean') sampled from the chain, after burn-in and thinning.

References

Hastings, W.K., 1970. Monte Carlo sampling methods using Markov chains and their applications, Biometrika 57, 97-109.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
    # Sampling from the joint likelihood distribution for TRA1
    # using the default Payne class ages.
    data(Neolithic)
    counts <- Neolithic['TRA1',]
    pars <- mcmc(counts)

    # plot the final samples
    par(mfrow = c(1, 1)  )
    plot(pars,  xlab = 'shape',  ylab = 'mean' )

	

UCL/GammaModel documentation built on June 25, 2020, 5:38 a.m.