README.md

OddsPlotty - the package for visualising odds ratios after conducting hard core statistics / ML

R-CMD-check CRAN status Launch binder Downloads

A package to create odds plots after running a GLM

Markdown Monster icon

Package Installation

The package can be installed by using the following command : devtools::install_github("StatsGary/OddsPlotty", dependencies=TRUE) directly from GitHub. If Devtools is not loaded on to your machine - then this can be done by using install.packages("devtools") or using the package installation UI in R Studio.

The main way to install is to get the package from CRAN, as follows:

install.packages("OddsPlotty") # if not already installed

Loading Package into R Project

To load the package into the library you can achieve this as hereunder:

library(OddsPlotty)

What does this do?

This package allows the user to generate multiple odds ratio plots. These are the outcome of fitting a logistic regression model and will show how the odds work. The vignette explains how to train a model and then use the odds plot package.

Using the package

The following shows how to take the results of a predictive model trained in CARET and produce the Odds Plots via OddsPlotty:

# Pass in the trained model from CARET and expose the finalModel list element from CARET
plotty <- OddsPlotty::odds_plot(glm_model$finalModel, 
                      title = "Odds Plot with ggthemes economist",
                      subtitle = "Showing odds of cancer based on various factors",
                      point_col = "#00f2ff",
                      error_bar_colour = "black",
                      point_size = .5,
                      error_bar_width = .8,
                      h_line_color = "red") 

plot <- plotty$odds_plot #Returns the plot element from the list
plot <- plot + ggthemes::theme_economist() + theme(legend.position = "NULL")

# Add odds ratios to labels by calling the data list element
# The round function is used to return 2 decimal place values
plot + geom_text(label=round(plotty$odds_plot$data$OR, digits=2), 
                             hjust=0.1, vjust=1)



This returns:

To get the tibble from the list, simply use the plotty variable, or whatever you call it, to return the odds ratios and the confidence intervals:

plotty$odds_data

Find out more...

To find out more, please use the Vignette associated with this package for the full and correct usage.

More packages

In the coming months I aim to produce all my packages I have been previously squirreling away on to Github, so please look out for those.

Created and owned by Gary Hutson.



StatsGary/OddsPlotty documentation built on July 4, 2024, 2:50 a.m.