View source: R/PredictorResponseFunctions.R
PredictorResponseBivarLevels | R Documentation |
Function to plot the h
function of a particular variable at different levels (quantiles) of a second variable
PredictorResponseBivarLevels( pred.resp.df, Z = NULL, qs = c(0.25, 0.5, 0.75), both_pairs = TRUE, z.names = NULL )
pred.resp.df |
object obtained from running the function |
Z |
an |
qs |
vector of quantiles at which to fix the second variable |
both_pairs |
flag indicating whether, if |
z.names |
optional vector of names for the columns of |
For guided examples, go to https://jenfb.github.io/bkmr/overview.html
a long data frame with the name of the first predictor, the name of the second predictor, the value of the first predictor, the quantile at which the second predictor is fixed, the posterior mean estimate, and the posterior standard deviation of the estimated exposure response function
## 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) ## Obtain predicted value on new grid of points for each pair of predictors ## Using only a 10-by-10 point grid to make example run quickly pred.resp.bivar <- PredictorResponseBivar(fit = fitkm, min.plot.dist = 1, ngrid = 10) pred.resp.bivar.levels <- PredictorResponseBivarLevels(pred.resp.df = pred.resp.bivar, Z = Z, qs = c(0.1, 0.5, 0.9))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.