PickStuck: Which chains get stuck

Description Usage Arguments Value Examples

View source: R/analysis.R

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

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

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

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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))

## Not run: 
dat <- simulate(model, 30, ps = p.vector)
dmi <- BuildDMI(dat, model)
sam <- run(StartNewsamples(dmi, p.prior))
bad <- PickStuck(sam)

## End(Not run)

ggdmc documentation built on May 2, 2019, 9:59 a.m.