prob_var_plot: LOESS Plot for Binary Variable

Description Usage Arguments Details Value Examples

Description

prob_var_plot creates a ggplot2 plot with a Bernoulli LOESS for binary versus continuous variable. This should be useful as a way to determine the relationship between a continuous variable and a binary variable.

Usage

1
prob_var_plot(data, x_var, y_var, window_width, method = "bayes")

Arguments

data

The dataframe containing the binary and continuous variable

x_var

The name of the continuous variable (as a string)

y_var

The name of the binary response variable (as a string)

window_width

Width of the window to use for approximating p.

method

The method to be used to find confidence intervals for binomial variables. See documentation for binom.confint for options.

Details

It returns a ggplot2 plot, so one could easily add other elements to the plot, such as titles, axes labels, and other themes.

Value

A ggplot2 plot.

Examples

1
2
3
4
5
6
x <- rnorm(100, 0, 2)
y <- rbinom(100, 1, invlogit(x))
test_data <- data.frame(x, y)
p <- prob_var_plot(test_data, "x", "y", 2)
p
p + labs(title="Empirical probability versus Gaussian variable")

wjones127/thesis documentation built on May 4, 2019, 7:34 a.m.