plot.bpd: plot.bpd

View source: R/plot.bpd.R

plot.bpdR Documentation

plot.bpd

Description

This function plots the partial dependence results estimated returned by running barp_partial_dependence.

Usage

## S3 method for class 'bpd'
plot(
  bpd,
  var_names = NULL,
  var_labs = NULL,
  is_categorical = NULL,
  cols = c("#f2f0f7", "#cbc9e2", "#9e9ac8", "#6a51a3"),
  ...
)

Arguments

bpd

A barp_partial_dependence partial dependence object of class "bpd".

var_names

A vector of variable names. If NULL (the default), the variable names from the training data columns are used.

var_labs

A list of variable labels corresponding to the levels at which the partial dependence was calculated. If NULL (the default), the raw values are used.

is_categorical

A vector of logicals (T,F) corresponding to which variables are categorical and which are continuous.If NULL (the default), the function determines whether each variable is categorical or continuous based on the data class.

...

Additional arguments to be passed to plot.

See Also

barp_partial_dependence which is a prerequisite to plotting.

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 = c("age","educ"),
                               prop_data = .2,
                               levs = list(c(1:4),c(1:4),
                               credible_interval = c(0.025,0.975)))
plot(bpd,
     var_names = c("Age","Education"),
     var_labs = list(c("18-30","31-50","51-65","65+"),
                     c("LTHS","HS","Some Coll","Coll+")),
     is_categorical = c(T,T))

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