View source: R/score_profile.R
ggplot.score_profile | R Documentation |
score_profile
object.ggplot method for class ‘score_profile’
## S3 method for class 'score_profile' ggplot(x, i.var = NULL, n.type = "boxplot", f.type = "percent", statistic = "mean", geom = "point", legend.position = NULL, col = NULL, size = NULL, nrows = NULL, ncols = NULL, xlab = NULL, ...)
x |
An object of class |
i.var |
A numeric vector of indices of the variables to plot. The variables should be indexed in the same order that they appear in the initial inspect_balance formula. The default is to plot all variables. |
n.type |
The type of plot for numeric variables. Boxplots are generated
by default. For alternative summary statistics, use |
f.type |
The type of plot for categorical variables. 100 percent stacked
columns are generated by default. The alternative option is |
statistic |
Functions that operate on a vector and produce a single
value, as |
geom |
The geometric object to display the data. Argument is passed to
|
legend.position |
The position of legends |
col |
Color of |
size |
Size of |
nrows |
Number of rows for plots. |
ncols |
Number of columns for plots. |
xlab |
Title for the x. |
... |
Additional arguments passed to |
Leo Guelman leo.guelman@rbc.com
set.seed(123) N <- 10000 eps <- rnorm(N) age <- round(rnorm(N, 50, 10)) income <- rnorm(N, 60000, 10000) + 200 * age gender <- gl(2, N/2, labels = c("F", "M")) insurance <- gl(4, N/4, labels = c("HOME", "AUTO", "LIFE", "HEALTH")) z <- 1e-01 + 0.1 * age - 1e-04 * income + 0.3 * (gender == "F") + eps pr <- 1 / (1 + exp( -z)) purchase <- rbinom(N, 1, pr) df <- data.frame(purchase, age, income, gender, insurance) ### Fit glm pred <- fitted(glm(purchase ~ age + income + gender, data = df, family = "binomial")) profileForm <- pred ~ age + income + gender + insurance prof1 <- score_profile(profileForm, data = df) prof1 ggplot(prof1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.