Description Usage Arguments Details Value Examples
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.
1 | prob_var_plot(data, x_var, y_var, window_width, method = "bayes")
|
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. |
It returns a ggplot2 plot, so one could easily add other elements to the plot, such as titles, axes labels, and other themes.
A ggplot2 plot.
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.