#' Calculation of the cumulative probability
#'
#' This function calculates the cumulative probability for each point of the
#' given dataset.The probability assigned to a sample value is the estimate of
#' the proportion of times that value occurs in the population.
#'
#'
#' @param df Default dataset to use for calculation
#' @param good Name of column representing the good contracts
#' @param bad Name of column representing the bad contracts
#' @param Hypothesis The hypothesis for the data
#' @return
#'
CumulativeProbability <- function (df, good, bad, Hypothesis = "g > b") {
good <- enquo(good)
bad <- enquo(bad)
if (Hypothesis == "g < b") {
roc <- df %>%
mutate(
bad = 1 - cumsum(!!bad) / sum(!!bad),
good = 1 - cumsum(!!good) / sum(!!good)
) %>%
add_row(., bad = 1, good = 1, .before = 1) %>%
mutate(line = "ROC")
} else {
roc <- df %>%
mutate(
bad = cumsum(!!bad) / sum(!!bad),
good = cumsum(!!good) / sum(!!good)
) %>%
add_row(., bad = 0, good = 0, .before = 1) %>%
mutate(line = "ROC")
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.