# This file is automatically generated, you probably don't want to edit this
decisioncombineOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"decisioncombineOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
gold = NULL,
goldPositive = NULL,
test1 = NULL,
test1Positive = NULL,
test2 = NULL,
test2Positive = NULL,
test3 = NULL,
test3Positive = NULL,
combRule = "any",
pp = FALSE,
pprob = 0.3,
od = FALSE,
fnote = FALSE,
ci = FALSE,
fagan = FALSE,
showIndividual = TRUE, ...) {
super$initialize(
package="ClinicoPath",
name="decisioncombine",
requiresData=TRUE,
...)
private$..gold <- jmvcore::OptionVariable$new(
"gold",
gold,
suggested=list(
"nominal"),
permitted=list(
"factor"))
private$..goldPositive <- jmvcore::OptionLevel$new(
"goldPositive",
goldPositive,
variable="(gold)")
private$..test1 <- jmvcore::OptionVariable$new(
"test1",
test1,
suggested=list(
"nominal"),
permitted=list(
"factor"))
private$..test1Positive <- jmvcore::OptionLevel$new(
"test1Positive",
test1Positive,
variable="(test1)")
private$..test2 <- jmvcore::OptionVariable$new(
"test2",
test2,
suggested=list(
"nominal"),
permitted=list(
"factor"))
private$..test2Positive <- jmvcore::OptionLevel$new(
"test2Positive",
test2Positive,
variable="(test2)")
private$..test3 <- jmvcore::OptionVariable$new(
"test3",
test3,
suggested=list(
"nominal"),
permitted=list(
"factor"))
private$..test3Positive <- jmvcore::OptionLevel$new(
"test3Positive",
test3Positive,
variable="(test3)")
private$..combRule <- jmvcore::OptionList$new(
"combRule",
combRule,
options=list(
"any",
"all",
"majority"),
default="any")
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$..od <- jmvcore::OptionBool$new(
"od",
od,
default=FALSE)
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)
private$..showIndividual <- jmvcore::OptionBool$new(
"showIndividual",
showIndividual,
default=TRUE)
self$.addOption(private$..gold)
self$.addOption(private$..goldPositive)
self$.addOption(private$..test1)
self$.addOption(private$..test1Positive)
self$.addOption(private$..test2)
self$.addOption(private$..test2Positive)
self$.addOption(private$..test3)
self$.addOption(private$..test3Positive)
self$.addOption(private$..combRule)
self$.addOption(private$..pp)
self$.addOption(private$..pprob)
self$.addOption(private$..od)
self$.addOption(private$..fnote)
self$.addOption(private$..ci)
self$.addOption(private$..fagan)
self$.addOption(private$..showIndividual)
}),
active = list(
gold = function() private$..gold$value,
goldPositive = function() private$..goldPositive$value,
test1 = function() private$..test1$value,
test1Positive = function() private$..test1Positive$value,
test2 = function() private$..test2$value,
test2Positive = function() private$..test2Positive$value,
test3 = function() private$..test3$value,
test3Positive = function() private$..test3Positive$value,
combRule = function() private$..combRule$value,
pp = function() private$..pp$value,
pprob = function() private$..pprob$value,
od = function() private$..od$value,
fnote = function() private$..fnote$value,
ci = function() private$..ci$value,
fagan = function() private$..fagan$value,
showIndividual = function() private$..showIndividual$value),
private = list(
..gold = NA,
..goldPositive = NA,
..test1 = NA,
..test1Positive = NA,
..test2 = NA,
..test2Positive = NA,
..test3 = NA,
..test3Positive = NA,
..combRule = NA,
..pp = NA,
..pprob = NA,
..od = NA,
..fnote = NA,
..ci = NA,
..fagan = NA,
..showIndividual = NA)
)
decisioncombineResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"decisioncombineResults",
inherit = jmvcore::Group,
active = list(
text1 = function() private$.items[["text1"]],
text2 = function() private$.items[["text2"]],
cTable = function() private$.items[["cTable"]],
indTable1 = function() private$.items[["indTable1"]],
indTable2 = function() private$.items[["indTable2"]],
indTable3 = function() private$.items[["indTable3"]],
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="Combine Medical Decision Tests",
refs=list(
"DiagnosticTests",
"ClinicoPathJamoviModule"))
self$add(jmvcore::Preformatted$new(
options=options,
name="text1",
title="Original Data",
visible="(od)"))
self$add(jmvcore::Html$new(
options=options,
name="text2",
title="Original Data",
visible="(od)"))
self$add(jmvcore::Table$new(
options=options,
name="cTable",
title="Recoded Data for Combined Test",
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="indTable1",
title="Test 1 Results",
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="indTable2",
title="Test 2 Results",
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="indTable3",
title="Test 3 Results",
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="epiR"))
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="epiR"))
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")))}))
decisioncombineBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"decisioncombineBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = "ClinicoPath",
name = "decisioncombine",
version = c(0,0,3),
options = options,
results = decisioncombineResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = FALSE,
requiresMissings = FALSE,
weightsSupport = 'auto')
}))
#' Combine Medical Decision Tests
#'
#' Function for combining multiple Medical Decision Tests and evaluating their
#' performance. Calculate sensitivity, specificity, positive predictive value,
#' negative predictive value for combined tests using different combination
#' rules.
#'
#'
#' @examples
#' \donttest{
#' # example will be added
#'}
#' @param data The data as a data frame.
#' @param gold .
#' @param goldPositive .
#' @param test1 .
#' @param test1Positive .
#' @param test2 .
#' @param test2Positive .
#' @param test3 .
#' @param test3Positive .
#' @param combRule Rule for combining test results. "any" means positive if
#' any test is positive (OR), "all" means positive only if all tests are
#' positive (AND), and "majority" means positive if more than half of tests
#' are positive.
#' @param pp .
#' @param pprob Prior probability (disease prevalence in the community).
#' Requires a value between 0.001 and 0.999, default 0.300.
#' @param od Boolean selection whether to show frequency tables. Default is
#' 'false'.
#' @param fnote .
#' @param ci .
#' @param fagan .
#' @param showIndividual .
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$text1} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$text2} \tab \tab \tab \tab \tab a html \cr
#' \code{results$cTable} \tab \tab \tab \tab \tab a table \cr
#' \code{results$indTable1} \tab \tab \tab \tab \tab a table \cr
#' \code{results$indTable2} \tab \tab \tab \tab \tab a table \cr
#' \code{results$indTable3} \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
decisioncombine <- function(
data,
gold,
goldPositive,
test1,
test1Positive,
test2,
test2Positive,
test3,
test3Positive,
combRule = "any",
pp = FALSE,
pprob = 0.3,
od = FALSE,
fnote = FALSE,
ci = FALSE,
fagan = FALSE,
showIndividual = TRUE) {
if ( ! requireNamespace("jmvcore", quietly=TRUE))
stop("decisioncombine requires jmvcore to be installed (restart may be required)")
if ( ! missing(gold)) gold <- jmvcore::resolveQuo(jmvcore::enquo(gold))
if ( ! missing(test1)) test1 <- jmvcore::resolveQuo(jmvcore::enquo(test1))
if ( ! missing(test2)) test2 <- jmvcore::resolveQuo(jmvcore::enquo(test2))
if ( ! missing(test3)) test3 <- jmvcore::resolveQuo(jmvcore::enquo(test3))
if (missing(data))
data <- jmvcore::marshalData(
parent.frame(),
`if`( ! missing(gold), gold, NULL),
`if`( ! missing(test1), test1, NULL),
`if`( ! missing(test2), test2, NULL),
`if`( ! missing(test3), test3, NULL))
for (v in gold) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
for (v in test1) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
for (v in test2) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
for (v in test3) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
options <- decisioncombineOptions$new(
gold = gold,
goldPositive = goldPositive,
test1 = test1,
test1Positive = test1Positive,
test2 = test2,
test2Positive = test2Positive,
test3 = test3,
test3Positive = test3Positive,
combRule = combRule,
pp = pp,
pprob = pprob,
od = od,
fnote = fnote,
ci = ci,
fagan = fagan,
showIndividual = showIndividual)
analysis <- decisioncombineClass$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.