SingVarRiskSummaries {bkmr}R Documentation

Single Variable Risk Summaries

Description

Compute summaries of the risks associated with a change in a single variable in Z from a single level (quantile) to a second level (quantile), for the other variables in Z fixed to a specific level (quantile)

Usage

SingVarRiskSummaries(
  fit,
  y = NULL,
  Z = NULL,
  X = NULL,
  which.z = 1:ncol(Z),
  qs.diff = c(0.25, 0.75),
  q.fixed = c(0.25, 0.5, 0.75),
  method = "approx",
  sel = NULL,
  z.names = colnames(Z),
  ...
)

Arguments

fit

An object containing the results returned by a the kmbayes function

y

a vector of outcome data of length n.

Z

an n-by-M matrix of predictor variables to be included in the h function. Each row represents an observation and each column represents an predictor.

X

an n-by-K matrix of covariate data where each row represents an observation and each column represents a covariate. Should not contain an intercept column.

which.z

vector indicating which variables (columns of Z) for which the summary should be computed

qs.diff

vector indicating the two quantiles q_1 and q_2 at which to compute h(z_{q2}) - h(z_{q1})

q.fixed

vector of quantiles at which to fix the remaining predictors in Z

method

method for obtaining posterior summaries at a vector of new points. Options are "approx" and "exact"; defaults to "approx", which is faster particularly for large datasets; see details

sel

logical expression indicating samples to keep; defaults to keeping the second half of all samples

z.names

optional vector of names for the columns of z

...

other arguments to pass on to the prediction function

Details

For guided examples and additional information, go to https://jenfb.github.io/bkmr/overview.html

Value

a data frame containing the (posterior mean) estimate and posterior standard deviation of the single-predictor risk measures

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)

risks.singvar <- SingVarRiskSummaries(fit = fitkm, method = "exact")

[Package bkmr version 0.2.2 Index]