View source: R/get_optim_roc.R
get_optim_roc | R Documentation |
This function takes the dataframe output of the sens_spec_roc()
function and finds the optimal threshold
of sensitivity and specificity by minimizing the distance to the top left corner of the Receiver Operating Characteristic (ROC) curve
get_optim_roc(roc)
roc |
a dataframe produced by the |
vector containing optimal thresholds of sensitivity and specificity
Shirlee Wohl, John Giles, and Justin Lessler
Other mutrate_functions:
gen_dists()
,
sens_spec_calc()
,
sens_spec_roc()
# ebola-like pathogen
R <- 1.5
mut_rate <- 1
# use simulated generation distributions
data(genDistSim)
mean_gens_pdf <- as.numeric(genDistSim[genDistSim$R == R, -(1:2)])
# get theoretical genetic distance dist based on mutation rate and generation parameters
dists <- as.data.frame(gen_dists(mut_rate = mut_rate,
mean_gens_pdf = mean_gens_pdf,
max_link_gens = 1))
# reshape dataframe for plotting
dists <- reshape2::melt(dists,
id.vars = 'dist',
variable.name = 'status',
value.name = 'prob')
# get sensitivity and specificity using the same paramters
roc_calc <- sens_spec_roc(cutoff = 1:(max(dists$dist)-1),
mut_rate = mut_rate,
mean_gens_pdf = mean_gens_pdf)
# get the optimal value for the ROC plot
optim_point <- get_optim_roc(roc_calc)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.