Description Usage Arguments Value Examples
This has been created to generate odds plots on the back of results from a generalised linear model.
1 2 3 4 5 6 7 8 9 10 11 12 |
x |
The trained caret GLM logistic regression model |
x_label |
The label name for the x_label |
y_label |
The label name for the y_label |
title |
Title for the Odds Plot |
subtitle |
Subtitle for the Odds Plot |
point_col |
Defaults to blues, but R colour codes can be passed |
error_bar_colour |
the colour of the error bar |
point_size |
the point size of the plot |
error_bar_width |
the width of the displayed error bar |
h_line_color |
the colour of the horizontal line |
A list of the odds returned from logistic regression and a plot showing the odds
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #We will use the cancer dataset to build a GLM model to predict cancer status
#this will detail whether the patient has a benign or malignant
library(mlbench)
library(caret)
library(tibble)
library(ggplot2)
library(OddsPlotty)
library(e1071)
library(ggthemes)
#Bring in the data
data("BreastCancer", package = "mlbench")
breast <- BreastCancer[complete.cases(BreastCancer), ]
breast <- breast[, -1]
head(breast, 10)
breast$Class <- factor(breast$Class)
for(i in 1:9) {
breast[, i] <- as.numeric(as.character(breast[, i]))
}
#Train GLM model
glm_model <- train(Class ~ ., data = breast, method = "glm", family = "binomial")
#Visualise the data with OddsPlotty
plotty <- OddsPlotty::odds_plot(glm_model$finalModel,title = "Odds Plot")
plotty$odds_plot
#Extract underlying odds ratios
plotty$odds_data
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.