barp_partial_dependence: barp_partial_dependence

barp_partial_dependenceR Documentation

barp_partial_dependence

Description

This function calculates the partial dependence for selected covariates based on a BARP object. The user can specify up to three covariates, resulting in a three-way interaction.

Usage

barp_partial_dependence(
  barp.obj,
  vars = NULL,
  prop_data = 0.1,
  credible_interval = c(0.025, 0.975),
  setSeed = NULL
)

Arguments

vars

The variable names or column indices of interest. #' @param vars The variable names or column indices of interest. If a character vector, values at which to evaluate partial dependences based on quantiles c(0.05,seq(.1,.9,by = .1),.95).

prop_data

The percentage of the original data to use for estimation. Larger values are more time consuming.

credible_interval

The credible interval for the estimates.

setSeed

Seed to control random number generation.

barp

A barp object.

...

Additional arguments to be passed to bartMachine.

Value

Returns an object of class "barpd", containing a list of the following components:

summary

A data.frame listing the mean and upper and lower bounds of the predicted outcome at each level of the covariate(s).

raw

A data.frame where each row is a posterior draw and each column is a level for the covariate(s).

See Also

barp which generates the prerequisite barp object.

Examples

data("gaymar")
barp.obj <- barp(y = "supp_gaymar",
             x = c("pvote","religcon","age","educ","gXr","stateid","region"),
             dat = svy,
             census = census06,
             geo.unit = "stateid",
             proportion = "n")
bpd <- barp_partial_dependence(barp = barp.obj,
                               vars = list(region = 1:4,educ = 1:4),
                               prop_data = .2,
                               credible_interval = c(0.025,0.975),
                               setSeed = 1021)

jbisbee1/BARP documentation built on Jan. 5, 2023, 9:15 a.m.