plot.bsPDP: Plot bootstrapped partial dependence plots

Description Usage Arguments Details Value References

View source: R/plot_bsPDP.R

Description

Plots objects of class bsPDP created by bootstrapping a predictive or causal model to show confidence bands for the average predicted partial dependence plot of a variable.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## S3 method for class 'bsPDP'
plot(
  bsPDP,
  test = FALSE,
  title = "Partial Dependence Plot",
  xlim = NULL,
  ylim = NULL,
  xtitle = NULL,
  ytitle = "Predicted Outcome",
  iqr = FALSE,
  hist = FALSE
)

Arguments

bsPDP

(required) a list created by a bsPDP function and contains the following elements:

  1. trainData: a data frame containing the original training sample.

  2. variable: the x-variable from trainData to predict and plot.

  3. pdpData: data frame containing the following variables: a. "variable": grid values of the x-variable; b. pdpHat: the average of the bootstrapped predictions at each grid value in the training sample; c. pdpSd: the standard errors of the bootstrapped predictions at each grid value in the training sample; d. pdpHat.test: the average of the bootstrapped predictions at each grid value in the test sample; e. pdpSd.test: the standard errors of the bootstrapped predictions at each grid in the test sample;

  4. testData: a data frame containing the test sample.

  5. outcome: the outcome class (for classification).

  6. trControl: the trainControl settings (for tuned caret methods).

  7. trainMethod: the method used in the caret functionl.

test

is a logical indicating whether to plot the pdp for the test data instead of the train data (default is FALSE).

title

is a string for the main title of the plot (the default is "Partial Dependence Plot").

xlim

is a vector combination equal to the minimum and maximum values of the x-axis (the default is the minimum and maximum values of the x-variable).

ylim

is a vector combination equal to the minimum and maximum values of the y-axis (the default is the minimum of pdpHat minus 3 times the maximum value of pdpSd and the maximum of pdpHat plus 3 times the maximum value of pdpSd).

xtitle

is a character string for the x-axis title (the default is the name of the x-variable)

ytitle

is a character string for the y-axis title (the default is "Predicted Outcome")

iqr

is a logical indicating whether to include lines at the IQR bounds of x (the default is FALSE)

hist

is a logical indicating whether to include a histogram of x (the default is FALSE)

Details

bsPDP and plot.bsPDP currently support the following methods:

lm for linear models

glm for generalized linear models

randomForest for random forests

caret for pramater tuning with machine-learning models (including tree ensembles and neural networks)

dbarts and BayesTree for Bayesian Additive Regression Trees (BART)

causaldrf for inverse probability-of-treatment weights estimators iptw_est and the Hirano-Imbens (2004) covariate balancing estimators hi_est.

Value

plot.bsPDP returns a ggplot that can bee manipulated according to ggplot syntax.

References

Yakusheva, Olga; Bang, James T; Bobay, Kathleen; Hughes, Ronda G; Costa, Linda; and Weiss, Marianne (2021, Forthcoming). Health Services Research.


bangecon/bsPDP documentation built on Dec. 19, 2021, 6:41 a.m.