# This file is automatically generated, you probably don't want to edit this
decisioncalculatorOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"decisioncalculatorOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
TP = 90,
TN = 80,
FP = 30,
FN = 20,
pp = FALSE,
pprob = 0.3,
fnote = FALSE,
ci = FALSE,
fagan = FALSE, ...) {
super$initialize(
package="ClinicoPath",
name="decisioncalculator",
requiresData=FALSE,
...)
private$..TP <- jmvcore::OptionNumber$new(
"TP",
TP,
default=90)
private$..TN <- jmvcore::OptionNumber$new(
"TN",
TN,
default=80)
private$..FP <- jmvcore::OptionNumber$new(
"FP",
FP,
default=30)
private$..FN <- jmvcore::OptionNumber$new(
"FN",
FN,
default=20)
private$..pp <- jmvcore::OptionBool$new(
"pp",
pp,
default=FALSE)
private$..pprob <- jmvcore::OptionNumber$new(
"pprob",
pprob,
default=0.3,
min=0.001,
max=0.999)
private$..fnote <- jmvcore::OptionBool$new(
"fnote",
fnote,
default=FALSE)
private$..ci <- jmvcore::OptionBool$new(
"ci",
ci,
default=FALSE)
private$..fagan <- jmvcore::OptionBool$new(
"fagan",
fagan,
default=FALSE)
self$.addOption(private$..TP)
self$.addOption(private$..TN)
self$.addOption(private$..FP)
self$.addOption(private$..FN)
self$.addOption(private$..pp)
self$.addOption(private$..pprob)
self$.addOption(private$..fnote)
self$.addOption(private$..ci)
self$.addOption(private$..fagan)
}),
active = list(
TP = function() private$..TP$value,
TN = function() private$..TN$value,
FP = function() private$..FP$value,
FN = function() private$..FN$value,
pp = function() private$..pp$value,
pprob = function() private$..pprob$value,
fnote = function() private$..fnote$value,
ci = function() private$..ci$value,
fagan = function() private$..fagan$value),
private = list(
..TP = NA,
..TN = NA,
..FP = NA,
..FN = NA,
..pp = NA,
..pprob = NA,
..fnote = NA,
..ci = NA,
..fagan = NA)
)
decisioncalculatorResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"decisioncalculatorResults",
inherit = jmvcore::Group,
active = list(
cTable = function() private$.items[["cTable"]],
nTable = function() private$.items[["nTable"]],
ratioTable = function() private$.items[["ratioTable"]],
epirTable_ratio = function() private$.items[["epirTable_ratio"]],
epirTable_number = function() private$.items[["epirTable_number"]],
plot1 = function() private$.items[["plot1"]]),
private = list(),
public=list(
initialize=function(options) {
super$initialize(
options=options,
name="",
title="Medical Decision Calculator",
refs=list(
"DiagnosticTests",
"sensspecwiki",
"ClinicoPathJamoviModule"))
self$add(jmvcore::Table$new(
options=options,
name="cTable",
title="",
rows=0,
columns=list(
list(
`name`="newtest",
`title`="",
`type`="text"),
list(
`name`="GP",
`title`="Gold Positive",
`type`="number"),
list(
`name`="GN",
`title`="Gold Negative",
`type`="number"),
list(
`name`="Total",
`title`="Total",
`type`="number"))))
self$add(jmvcore::Table$new(
options=options,
name="nTable",
title="",
swapRowsColumns=TRUE,
rows=1,
columns=list(
list(
`name`="tablename",
`title`="",
`type`="text"),
list(
`name`="TotalPop",
`title`="Total",
`type`="number"),
list(
`name`="DiseaseP",
`title`="Diseased",
`type`="number"),
list(
`name`="DiseaseN",
`title`="Healthy",
`type`="number"),
list(
`name`="TestP",
`title`="Positive Tests",
`type`="number"),
list(
`name`="TestN",
`title`="Negative Tests",
`type`="number"),
list(
`name`="TestT",
`title`="True Test",
`type`="number"),
list(
`name`="TestW",
`title`="Wrong Test",
`type`="number")),
clearWith=list(
"pp",
"pprob")))
self$add(jmvcore::Table$new(
options=options,
name="ratioTable",
title="",
swapRowsColumns=TRUE,
rows=1,
columns=list(
list(
`name`="tablename",
`title`="",
`type`="text"),
list(
`name`="Sens",
`title`="Sensitivity",
`type`="number",
`format`="pc"),
list(
`name`="Spec",
`title`="Specificity",
`type`="number",
`format`="pc"),
list(
`name`="AccurT",
`title`="Accuracy",
`type`="number",
`format`="pc"),
list(
`name`="PrevalenceD",
`title`="Prevalence",
`type`="number",
`format`="pc"),
list(
`name`="PPV",
`title`="Positive Predictive Value",
`type`="number",
`format`="pc"),
list(
`name`="NPV",
`title`="Negative Predictive Value",
`type`="number",
`format`="pc"),
list(
`name`="PostTestProbDisease",
`title`="Post-test Disease Probability",
`type`="number",
`format`="pc"),
list(
`name`="PostTestProbHealthy",
`title`="Post-test Health Probability",
`type`="number",
`format`="pc"),
list(
`name`="LRP",
`title`="Positive Likelihood Ratio",
`type`="number"),
list(
`name`="LRN",
`title`="Negative Likelihood Ratio",
`type`="number")),
clearWith=list(
"pp",
"pprob")))
self$add(jmvcore::Table$new(
options=options,
name="epirTable_ratio",
title="",
visible="(ci)",
rows=0,
columns=list(
list(
`name`="statsnames",
`title`="Decision Statistics",
`type`="text"),
list(
`name`="est",
`title`="Estimate",
`type`="number",
`format`="pc"),
list(
`name`="lower",
`title`="Lower",
`superTitle`="95% Confidence Interval",
`type`="number",
`format`="pc"),
list(
`name`="upper",
`title`="Upper",
`superTitle`="95% Confidence Interval",
`type`="number",
`format`="pc")),
clearWith=list(
"pp",
"pprob"),
refs=list(
"epiR",
"sensspecwiki")))
self$add(jmvcore::Table$new(
options=options,
name="epirTable_number",
title="",
visible="(ci)",
rows=0,
columns=list(
list(
`name`="statsnames",
`title`="Decision Statistics",
`type`="text"),
list(
`name`="est",
`title`="Estimate",
`type`="number"),
list(
`name`="lower",
`title`="Lower",
`superTitle`="95% Confidence Interval",
`type`="number"),
list(
`name`="upper",
`title`="Upper",
`superTitle`="95% Confidence Interval",
`type`="number")),
clearWith=list(
"pp",
"pprob"),
refs=list(
"epiR",
"sensspecwiki")))
self$add(jmvcore::Image$new(
options=options,
name="plot1",
title="Fagan nomogram",
width=600,
height=450,
renderFun=".plot1",
requiresData=TRUE,
visible="(fagan)",
clearWith=list(
"pp",
"pprob",
"fagan"),
refs=list(
"Fagan",
"Fagan2",
"sensspecwiki")))}))
decisioncalculatorBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"decisioncalculatorBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = "ClinicoPath",
name = "decisioncalculator",
version = c(1,0,0),
options = options,
results = decisioncalculatorResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = FALSE,
requiresMissings = FALSE,
weightsSupport = 'na')
}))
#' Medical Decision Calculator
#'
#' Function for Medical Decision Calculator.
#'
#' @examples
#' \donttest{
#' # example will be added
#'}
#' @param TP .
#' @param TN .
#' @param FP .
#' @param FN .
#' @param pp .
#' @param pprob Prior probability (disease prevalence in the community).
#' Requires a value between 0.001 and 0.999, default 0.300.
#' @param fnote .
#' @param ci .
#' @param fagan .
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$cTable} \tab \tab \tab \tab \tab a table \cr
#' \code{results$nTable} \tab \tab \tab \tab \tab a table \cr
#' \code{results$ratioTable} \tab \tab \tab \tab \tab a table \cr
#' \code{results$epirTable_ratio} \tab \tab \tab \tab \tab a table \cr
#' \code{results$epirTable_number} \tab \tab \tab \tab \tab a table \cr
#' \code{results$plot1} \tab \tab \tab \tab \tab an image \cr
#' }
#'
#' Tables can be converted to data frames with \code{asDF} or \code{\link{as.data.frame}}. For example:
#'
#' \code{results$cTable$asDF}
#'
#' \code{as.data.frame(results$cTable)}
#'
#' @export
decisioncalculator <- function(
TP = 90,
TN = 80,
FP = 30,
FN = 20,
pp = FALSE,
pprob = 0.3,
fnote = FALSE,
ci = FALSE,
fagan = FALSE) {
if ( ! requireNamespace("jmvcore", quietly=TRUE))
stop("decisioncalculator requires jmvcore to be installed (restart may be required)")
options <- decisioncalculatorOptions$new(
TP = TP,
TN = TN,
FP = FP,
FN = FN,
pp = pp,
pprob = pprob,
fnote = fnote,
ci = ci,
fagan = fagan)
analysis <- decisioncalculatorClass$new(
options = options,
data = data)
analysis$run()
analysis$results
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.