MyNixOS website logo
Description

Parallel Chain Tools for Bayesian Kernel Machine Regression.

Bayesian kernel machine regression (from the 'bkmr' package) is a Bayesian semi-parametric generalized linear model approach under identity and probit links. There are a number of functions in this package that extend Bayesian kernel machine regression fits to allow multiple-chain inference and diagnostics, which leverage functions from the 'future', 'rstan', and 'coda' packages. Reference: Bobb, J. F., Henn, B. C., Valeri, L., & Coull, B. A. (2018). Statistical software for analyzing the health effects of multiple concurrent exposures via Bayesian kernel machine regression. ; <doi:10.1186/s12940-018-0413-y>.

bkmrhat v1.1.2

Diagnostics and multi-chain tools with Bayesian kernel machine regression (bkmr)

Bayesian kernel machine regression (BKMR) is a semi-parametric approach to Bayesian GLMs. The bkmr package implements BKMR under identity and probit links, but does not implement standard Bayesian diagnostics or interface with R packages that can do these diagnostics, nor does it allow easy implementation of parallel chains, which is one of the easiest ways to speed up Markov chain Monte Carlo on modern computers. This package fixes those problems.

Note that this package functions best using the development verision of the bkmr package (instructions here)

Quick start

install

install.packages("devtools")
devtools::install_github("alexpkeil1/bkmrhat", build_vignettes = TRUE)

simulate data from a bkmr package function

set.seed(111)
library(coda)
library(bkmr)
library(bkmrhat)
dat <- bkmr::SimData(n = 50, M = 4)
y <- dat$y
Z <- dat$Z
X <- dat$X
set.seed(111)
	

fit BKMR model via four parallel MCMC chains (10,000 iterations total)

future::plan(strategy = future::multisession)
# run 4 parallel Markov chains
fitkm.list <- kmbayes_parallel(nchains=4, y = y, Z = Z, X = X, iter = 2500,
  verbose = FALSE, varsel = TRUE)

run diagnostics from rstan package

# rstan has a few excellent diagnostics (modern r-hat and effective sample size)
diagres = kmbayes_diag(fitkm.list)
# estimate of standard error (gives margin of error for reporting estimates)
diagres[,"se_mean"]

convert to coda package object for other diagnostics

mcmcobj = as.mcmc.list(fitkm.list)
# lots of functions in the coda package to use
# get info on rejection probabilities (from h() function in bkmr - won't be correct for discrete parameters like delta parameters)
  rejectionRate(mcmcobj)
# check trace plots for obvious issues between/within chains
  plot(mcmcobj)
# autocorrelation for efficiency issues
  acfplot(mcmcobj)
# posterior correlation for
  crosscorr(mcmcobj)
# Gelman/Rubin diagnostics for convergence (multivariate may fail when including delta functions from variable selection)
  try(gelman.diag(mcmcobj, multivariate = FALSE))  
# batch standard error: a different approach to estimating standard error
  batchSE(kmres)
# effective size, another way to assess whether enough samples have been made (I prefer the `rstan` implementations)
  effectiveSize(mcmcobj)
  try(geweke.diag(mcmcobj))
# posterior summary
  summary(mcmcobj)
# HPD intervals by chain
  HPDinterval(mcmcobj)
	  

combine chains and use bkmr native posterior functions

combobj = comb_bkmrfits(fitkm.list)
combobj$iter
summary(combobj) # rejection rates will be slightly off for multi-chain objects
# mean difference function from `bkmr` package (default burnin of half of total number of iterations)
  mdiff = OverallRiskSummaries(fit = combobj,
                                  qs = seq(.05, 0.95, by = 0.1),
                                  q.fixed = 0.5, method = "exact")
mdiff
Metadata

Version

1.1.3

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows