Learn R Programming

ggdmc (version 0.2.6.2)

PickStuck: Which chains get stuck

Description

Calculate each chain separately for the mean (across many MCMC iterations) of posterior log-likelihood. If the difference of the means and the median (across chains) of the mean of posterior is greater than the cut, chains are considered stuck. The default value for cut is 10. unstick manually removes stuck chains from posterior samples.

Usage

PickStuck(
  x,
  hyper = FALSE,
  cut = 10,
  start = 1,
  end = NA,
  verbose = FALSE,
  digits = 2
)

Value

PickStuck gives an index vector; unstick gives a DMC sample.

Arguments

x

posterior samples

hyper

whether x are hierarhcial samples

cut

a criterion deciding if a chain is stuck.

start

start to evaluate from which iteration.

end

end at which iteration for evaeuation.

verbose

a boolean switch to print more information

digits

print how many digits. Default is 2

Examples

Run this code
model <- BuildModel(
p.map     = list(A = "1", B = "1", t0 = "1", mean_v = "M", sd_v = "1", st0 = "1"),
match.map = list(M = list(s1 = 1, s2 = 2)),
factors   = list(S = c("s1", "s2")),
constants = c(st0 = 0, sd_v = 1),
responses = c("r1", "r2"),
type      = "norm")
p.vector <- c(A = .75, B = .25, t0 = .2, mean_v.true = 2.5, mean_v.false = 1.5)

p.prior <- BuildPrior(
  dists = c("tnorm", "tnorm", "beta", "tnorm", "tnorm"),
  p1    = c(A = .3, B = .3, t0 = 1, mean_v.true = 1, mean_v.false = 0),
  p2    = c(1, 1,   1, 3, 3),
  lower = c(0,  0,  0, NA, NA),
  upper = c(NA,NA,  1, NA, NA))

if (FALSE) {
dat <- simulate(model, 30, ps = p.vector)
dmi <- BuildDMI(dat, model)
sam <- run(StartNewsamples(dmi, p.prior))
bad <- PickStuck(sam)
}

Run the code above in your browser using DataLab