Extract posterior inclusion probabilities (PIPs) from BKMR model fit
Source:R/CalcPIPs.R
ExtractPIPs.Rd
Extract posterior inclusion probabilities (PIPs) from Bayesian Kernel Machine Regression (BKMR) model fit
Arguments
- fit
An object containing the results returned by a the
kmbayes
function- sel
logical expression indicating samples to keep; defaults to keeping the second half of all samples
- z.names
optional argument providing the names of the variables included in the
h
function.
Value
a data frame with the variable-specific PIPs for BKMR fit with component-wise variable selection, and with the group-specific and conditional (within-group) PIPs for BKMR fit with hierarchical variable selection.
Details
For guided examples, go to https://jenfb.github.io/bkmr/overview.html
Examples
## First generate dataset
set.seed(111)
dat <- SimData(n = 50, M = 4)
y <- dat$y
Z <- dat$Z
X <- dat$X
## Fit model with component-wise variable selection
## Using only 100 iterations to make example run quickly
## Typically should use a large number of iterations for inference
set.seed(111)
fitkm <- kmbayes(y = y, Z = Z, X = X, iter = 100, verbose = FALSE, varsel = TRUE)
#> Iteration: 10 (10% completed; 0.00505 secs elapsed)
#> Iteration: 20 (20% completed; 0.01022 secs elapsed)
#> Iteration: 30 (30% completed; 0.01576 secs elapsed)
#> Iteration: 40 (40% completed; 0.02146 secs elapsed)
#> Iteration: 50 (50% completed; 0.02673 secs elapsed)
#> Iteration: 60 (60% completed; 0.03172 secs elapsed)
#> Iteration: 70 (70% completed; 0.03673 secs elapsed)
#> Iteration: 80 (80% completed; 0.04177 secs elapsed)
#> Iteration: 90 (90% completed; 0.04729 secs elapsed)
#> Iteration: 100 (100% completed; 0.05301 secs elapsed)
ExtractPIPs(fitkm)
#> variable PIP
#> 1 z1 1.00
#> 2 z2 1.00
#> 3 z3 0.00
#> 4 z4 0.28