Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

kmbayes_combine

Combine multiple BKMR chains


Description

Combine multiple chains comprising BKMR fits at different starting values.

Usage

kmbayes_combine(fitkm.list, burnin = 0, reorder = TRUE)

comb_bkmrfits(fitkm.list, burnin = 0, reorder = TRUE)

Arguments

fitkm.list

output from kmbayes_parallel

burnin

add in custom burnin (number of burnin iterations per chain)

reorder

ensures that the first half of the combined chain contains only the first half of each individual chain - this allows unaltered use of standard functions from bkmr package, which automatically trims the first half of the iterations. This can be used for posterior summaries, but certain diagnostics may not work well (autocorrelation, effective sample size) so the diagnostics should be done on the individual chains #' @param ... arguments to as.mcmc.bkmrfit

Details

Chains are not combined fully sequentially

Value

a bkmrplusfit object, which inherits from bkmrfit (from the kmbayes function) with multiple chains combined into a single object and additional parameters given by chain and iters, which index the specific chains and iterations for each posterior sample in the bkmrplusfit object

Examples

# following example from https://jenfb.github.io/bkmr/overview.html
set.seed(111)
library(bkmr)
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 4 parallel Markov chains (low iterations used for illustration)
fitkm.list <- kmbayes_parallel(nchains=2, y = y, Z = Z, X = X, iter = 500,
  verbose = FALSE, varsel = TRUE)
bigkm = kmbayes_combine(fitkm.list)
ests = ExtractEsts(bigkm)
ExtractPIPs(bigkm)
pred.resp.univar <- PredictorResponseUnivar(fit = bigkm)
risks.overall <- OverallRiskSummaries(fit = bigkm, y = y, Z = Z, X = X,
  qs = seq(0.25, 0.75, by = 0.05), q.fixed = 0.5, method = "exact")

# additional objects that are not in a standard bkmrfit object:
summary(bigkm$iters)
table(bigkm$chain)


closeAllConnections()

bkmrhat

Parallel Chain Tools for Bayesian Kernel Machine Regression

v1.0.2
GPL (>= 3)
Authors
Alexander Keil [aut, cre]
Initial release
2021-02-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.