calc.RL.0 {mixstock} | R Documentation

## Use Raftery and Lewis diagnostics to calculate MCMC chain lengths

### Description

Uses `coda::raftery.diag` (the Raftery and Lewis diagnostic) to estimate minimum chain lengths for an MCMC estimate for mixed stock analysis. Runs R&L iteratively until the criteria are satisfied.

### Usage

    calc.RL.0(data, startfval, pilot=500, maxit=15, verbose=FALSE,
    rseed=1001, debug=FALSE)
    calc.mult.RL(data,n=50,debug=FALSE,verbose=FALSE)
    RL.max(r)

### Arguments

`data` | a `mixstock.data` object, or any list with `sourcesamp` and `mixsamp` entries containing source and mixed stock data
`startfval` | starting value of contribution frequencies for the chain, as in `gibbs` or `gibbsC`: NULL=random start, 0=equal contributions from all sources, (1..R-1)=95% contribution from one source, with the rest splitting the remainder equally
`pilot` | Chain length to start with (length of "pilot" run)
`maxit` | Max. number of iterations of the Raftery and Lewis procedure
`verbose` | Produce lots of output?
`rseed` | Random-number seed
`debug` | produce debugging output?
`n` | number of different random-number seed chains to try
`r` | the results of a Raftery and Lewis diagnostic test

### Details

`calc.RL.00` starts by running a Gibbs-sampler chain with the length given by `pilot`, then repeatedly lengthens the chain until the length is greater than that suggested as the total by the Raftery and Lewis diagnostic. (The next suggested step in the procedure is to run multiple chains of this length and see whether they pass the Gelman and Rubin diagnostic.) `calc.mult.RL` runs the Raftery and Lewis calculation multiple times, starting each chain from a large contribution from each source in turn, to see if some starting configurations are slower to converge or if there is a lot of variation among chains with different random number seeds. `RL.max` picks the expected maximum chain length given a set of diagnostics; `RL.burn` returns the predicted burn-in required.

### Value

for `calc.RL.00`:

`current` | Results of the Raftery and Lewis test on the current iteration
`history` | History of the iterations:

for `calc.mult.RL`, a matrix giving the maximum expected chain length for each random-number seed/starting point combination

### Author(s)

Ben Bolker

### Examples

    data(bolten98)
    b98c <- markfreq.condense(as.mixstock.data(bolten98))

[Package mixstock version 0.9.2 Index]