as.mcmc.list.bkmrfit.list {bkmrhat} | R Documentation |
Converts a kmrfit.list
(from the bkmrhat package) into
an mcmc.list
object from the coda
package.The
coda
package enables many different types of MCMC diagnostics,
including geweke.diag
, traceplot
and
effectiveSize
. Posterior summarization is also available,
such as HPDinterval
and summary.mcmc
.
Using multiple chains is necessary for certain MCMC diagnostics, such as
gelman.diag
, and gelman.plot
.
## S3 method for class 'list.bkmrfit.list' as.mcmc(x, ...)
x |
object of type kmrfit.list (from bkmrhat package) |
... |
arguments to |
An mcmc.list
object
# following example from https://jenfb.github.io/bkmr/overview.html set.seed(111) library(coda) dat <- bkmr::SimData(n = 50, M = 4) y <- dat$y Z <- dat$Z X <- dat$X set.seed(111) Sys.setenv(R_FUTURE_SUPPORTSMULTICORE_UNSTABLE="quiet") future::plan(strategy = future::multiprocess, workers=2) # run 2 parallel Markov chains (more usually better) fitkm.list <- kmbayes_parallel(nchains=2, y = y, Z = Z, X = X, iter = 1000, verbose = FALSE, varsel = FALSE) mcmcobj = as.mcmc.list(fitkm.list) summary(mcmcobj) # Gelman/Rubin diagnostics won't work on certain objects, # like delta parameters (when using variable selection), # so the rstan version of this will work better (does not give errors) try(gelman.diag(mcmcobj)) # lots of functions in the coda package to use plot(mcmcobj) # both of these will also fail with delta functions (when using variable selection) try(gelman.plot(mcmcobj)) try(geweke.plot(mcmcobj)) closeAllConnections()