# This file is automatically generated, you probably don't want to edit this
multisurvivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"multisurvivalOptions",
inherit = jmvcore::Options,
public = list(
initialize = function(
elapsedtime = NULL,
tint = FALSE,
dxdate = NULL,
fudate = NULL,
timetypedata = "ymd",
timetypeoutput = "months",
uselandmark = FALSE,
landmark = 3,
outcome = NULL,
outcomeLevel = NULL,
dod = NULL,
dooc = NULL,
awd = NULL,
awod = NULL,
analysistype = "overall",
explanatory = NULL,
contexpl = NULL,
multievent = FALSE,
hr = FALSE,
sty = "t1",
ph_cox = FALSE,
km = FALSE,
endplot = 60,
byplot = 12,
ci95 = FALSE,
risktable = FALSE,
censored = FALSE,
medianline = "none",
pplot = TRUE,
cutp = "12, 36, 60",
calculateRiskScore = FALSE,
numRiskGroups = "four",
plotRiskGroups = FALSE,
ac = FALSE,
adjexplanatory = NULL,
ac_method = "average",
showNomogram = FALSE,
use_stratify = FALSE,
stratvar = NULL, ...) {
super$initialize(
package="jsurvival",
name="multisurvival",
requiresData=TRUE,
...)
private$..elapsedtime <- jmvcore::OptionVariable$new(
"elapsedtime",
elapsedtime,
suggested=list(
"continuous"),
permitted=list(
"numeric"))
private$..tint <- jmvcore::OptionBool$new(
"tint",
tint,
default=FALSE)
private$..dxdate <- jmvcore::OptionVariable$new(
"dxdate",
dxdate)
private$..fudate <- jmvcore::OptionVariable$new(
"fudate",
fudate)
private$..timetypedata <- jmvcore::OptionList$new(
"timetypedata",
timetypedata,
options=list(
"ymdhms",
"ymd",
"ydm",
"mdy",
"myd",
"dmy",
"dym"),
default="ymd")
private$..timetypeoutput <- jmvcore::OptionList$new(
"timetypeoutput",
timetypeoutput,
options=list(
"days",
"weeks",
"months",
"years"),
default="months")
private$..uselandmark <- jmvcore::OptionBool$new(
"uselandmark",
uselandmark,
default=FALSE)
private$..landmark <- jmvcore::OptionInteger$new(
"landmark",
landmark,
default=3)
private$..calculatedtime <- jmvcore::OptionOutput$new(
"calculatedtime")
private$..outcome <- jmvcore::OptionVariable$new(
"outcome",
outcome,
suggested=list(
"ordinal",
"nominal",
"continuous"),
permitted=list(
"factor",
"numeric"))
private$..outcomeLevel <- jmvcore::OptionLevel$new(
"outcomeLevel",
outcomeLevel,
variable="(outcome)")
private$..dod <- jmvcore::OptionLevel$new(
"dod",
dod,
variable="(outcome)",
allowNone=TRUE)
private$..dooc <- jmvcore::OptionLevel$new(
"dooc",
dooc,
variable="(outcome)",
allowNone=TRUE)
private$..awd <- jmvcore::OptionLevel$new(
"awd",
awd,
variable="(outcome)",
allowNone=TRUE)
private$..awod <- jmvcore::OptionLevel$new(
"awod",
awod,
variable="(outcome)",
allowNone=TRUE)
private$..analysistype <- jmvcore::OptionList$new(
"analysistype",
analysistype,
options=list(
"overall",
"cause",
"compete"),
default="overall")
private$..outcomeredefined <- jmvcore::OptionOutput$new(
"outcomeredefined")
private$..explanatory <- jmvcore::OptionVariables$new(
"explanatory",
explanatory,
suggested=list(
"ordinal",
"nominal"),
permitted=list(
"factor"))
private$..contexpl <- jmvcore::OptionVariables$new(
"contexpl",
contexpl,
suggested=list(
"continuous"),
permitted=list(
"numeric"))
private$..multievent <- jmvcore::OptionBool$new(
"multievent",
multievent,
default=FALSE)
private$..hr <- jmvcore::OptionBool$new(
"hr",
hr,
default=FALSE)
private$..sty <- jmvcore::OptionList$new(
"sty",
sty,
options=list(
"t1",
"t3"),
default="t1")
private$..ph_cox <- jmvcore::OptionBool$new(
"ph_cox",
ph_cox,
default=FALSE)
private$..km <- jmvcore::OptionBool$new(
"km",
km,
default=FALSE)
private$..endplot <- jmvcore::OptionInteger$new(
"endplot",
endplot,
default=60)
private$..byplot <- jmvcore::OptionInteger$new(
"byplot",
byplot,
default=12)
private$..ci95 <- jmvcore::OptionBool$new(
"ci95",
ci95,
default=FALSE)
private$..risktable <- jmvcore::OptionBool$new(
"risktable",
risktable,
default=FALSE)
private$..censored <- jmvcore::OptionBool$new(
"censored",
censored,
default=FALSE)
private$..medianline <- jmvcore::OptionList$new(
"medianline",
medianline,
options=list(
"none",
"h",
"v",
"hv"),
default="none")
private$..pplot <- jmvcore::OptionBool$new(
"pplot",
pplot,
default=TRUE)
private$..cutp <- jmvcore::OptionString$new(
"cutp",
cutp,
default="12, 36, 60")
private$..calculateRiskScore <- jmvcore::OptionBool$new(
"calculateRiskScore",
calculateRiskScore,
default=FALSE)
private$..numRiskGroups <- jmvcore::OptionList$new(
"numRiskGroups",
numRiskGroups,
options=list(
"two",
"three",
"four"),
default="four")
private$..plotRiskGroups <- jmvcore::OptionBool$new(
"plotRiskGroups",
plotRiskGroups,
default=FALSE)
private$..addRiskScore <- jmvcore::OptionOutput$new(
"addRiskScore")
private$..addRiskGroup <- jmvcore::OptionOutput$new(
"addRiskGroup")
private$..ac <- jmvcore::OptionBool$new(
"ac",
ac,
default=FALSE)
private$..adjexplanatory <- jmvcore::OptionVariable$new(
"adjexplanatory",
adjexplanatory,
suggested=list(
"ordinal",
"nominal"),
permitted=list(
"factor"))
private$..ac_method <- jmvcore::OptionList$new(
"ac_method",
ac_method,
options=list(
"average",
"conditional",
"single",
"marginal"),
default="average")
private$..showNomogram <- jmvcore::OptionBool$new(
"showNomogram",
showNomogram,
default=FALSE)
private$..use_stratify <- jmvcore::OptionBool$new(
"use_stratify",
use_stratify,
default=FALSE)
private$..stratvar <- jmvcore::OptionVariables$new(
"stratvar",
stratvar,
suggested=list(
"ordinal",
"nominal"),
permitted=list(
"factor"))
self$.addOption(private$..elapsedtime)
self$.addOption(private$..tint)
self$.addOption(private$..dxdate)
self$.addOption(private$..fudate)
self$.addOption(private$..timetypedata)
self$.addOption(private$..timetypeoutput)
self$.addOption(private$..uselandmark)
self$.addOption(private$..landmark)
self$.addOption(private$..calculatedtime)
self$.addOption(private$..outcome)
self$.addOption(private$..outcomeLevel)
self$.addOption(private$..dod)
self$.addOption(private$..dooc)
self$.addOption(private$..awd)
self$.addOption(private$..awod)
self$.addOption(private$..analysistype)
self$.addOption(private$..outcomeredefined)
self$.addOption(private$..explanatory)
self$.addOption(private$..contexpl)
self$.addOption(private$..multievent)
self$.addOption(private$..hr)
self$.addOption(private$..sty)
self$.addOption(private$..ph_cox)
self$.addOption(private$..km)
self$.addOption(private$..endplot)
self$.addOption(private$..byplot)
self$.addOption(private$..ci95)
self$.addOption(private$..risktable)
self$.addOption(private$..censored)
self$.addOption(private$..medianline)
self$.addOption(private$..pplot)
self$.addOption(private$..cutp)
self$.addOption(private$..calculateRiskScore)
self$.addOption(private$..numRiskGroups)
self$.addOption(private$..plotRiskGroups)
self$.addOption(private$..addRiskScore)
self$.addOption(private$..addRiskGroup)
self$.addOption(private$..ac)
self$.addOption(private$..adjexplanatory)
self$.addOption(private$..ac_method)
self$.addOption(private$..showNomogram)
self$.addOption(private$..use_stratify)
self$.addOption(private$..stratvar)
}),
active = list(
elapsedtime = function() private$..elapsedtime$value,
tint = function() private$..tint$value,
dxdate = function() private$..dxdate$value,
fudate = function() private$..fudate$value,
timetypedata = function() private$..timetypedata$value,
timetypeoutput = function() private$..timetypeoutput$value,
uselandmark = function() private$..uselandmark$value,
landmark = function() private$..landmark$value,
calculatedtime = function() private$..calculatedtime$value,
outcome = function() private$..outcome$value,
outcomeLevel = function() private$..outcomeLevel$value,
dod = function() private$..dod$value,
dooc = function() private$..dooc$value,
awd = function() private$..awd$value,
awod = function() private$..awod$value,
analysistype = function() private$..analysistype$value,
outcomeredefined = function() private$..outcomeredefined$value,
explanatory = function() private$..explanatory$value,
contexpl = function() private$..contexpl$value,
multievent = function() private$..multievent$value,
hr = function() private$..hr$value,
sty = function() private$..sty$value,
ph_cox = function() private$..ph_cox$value,
km = function() private$..km$value,
endplot = function() private$..endplot$value,
byplot = function() private$..byplot$value,
ci95 = function() private$..ci95$value,
risktable = function() private$..risktable$value,
censored = function() private$..censored$value,
medianline = function() private$..medianline$value,
pplot = function() private$..pplot$value,
cutp = function() private$..cutp$value,
calculateRiskScore = function() private$..calculateRiskScore$value,
numRiskGroups = function() private$..numRiskGroups$value,
plotRiskGroups = function() private$..plotRiskGroups$value,
addRiskScore = function() private$..addRiskScore$value,
addRiskGroup = function() private$..addRiskGroup$value,
ac = function() private$..ac$value,
adjexplanatory = function() private$..adjexplanatory$value,
ac_method = function() private$..ac_method$value,
showNomogram = function() private$..showNomogram$value,
use_stratify = function() private$..use_stratify$value,
stratvar = function() private$..stratvar$value),
private = list(
..elapsedtime = NA,
..tint = NA,
..dxdate = NA,
..fudate = NA,
..timetypedata = NA,
..timetypeoutput = NA,
..uselandmark = NA,
..landmark = NA,
..calculatedtime = NA,
..outcome = NA,
..outcomeLevel = NA,
..dod = NA,
..dooc = NA,
..awd = NA,
..awod = NA,
..analysistype = NA,
..outcomeredefined = NA,
..explanatory = NA,
..contexpl = NA,
..multievent = NA,
..hr = NA,
..sty = NA,
..ph_cox = NA,
..km = NA,
..endplot = NA,
..byplot = NA,
..ci95 = NA,
..risktable = NA,
..censored = NA,
..medianline = NA,
..pplot = NA,
..cutp = NA,
..calculateRiskScore = NA,
..numRiskGroups = NA,
..plotRiskGroups = NA,
..addRiskScore = NA,
..addRiskGroup = NA,
..ac = NA,
..adjexplanatory = NA,
..ac_method = NA,
..showNomogram = NA,
..use_stratify = NA,
..stratvar = NA)
)
multisurvivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"multisurvivalResults",
inherit = jmvcore::Group,
active = list(
todo = function() private$.items[["todo"]],
text = function() private$.items[["text"]],
text2 = function() private$.items[["text2"]],
plot = function() private$.items[["plot"]],
plot3 = function() private$.items[["plot3"]],
cox_ph = function() private$.items[["cox_ph"]],
plot8 = function() private$.items[["plot8"]],
plotKM = function() private$.items[["plotKM"]],
risk_score_analysis = function() private$.items[["risk_score_analysis"]],
risk_score_analysis2 = function() private$.items[["risk_score_analysis2"]],
riskScoreTable = function() private$.items[["riskScoreTable"]],
riskScoreMetrics = function() private$.items[["riskScoreMetrics"]],
riskGroupPlot = function() private$.items[["riskGroupPlot"]],
stratificationExplanation = function() private$.items[["stratificationExplanation"]],
calculatedtime = function() private$.items[["calculatedtime"]],
outcomeredefined = function() private$.items[["outcomeredefined"]],
addRiskScore = function() private$.items[["addRiskScore"]],
addRiskGroup = function() private$.items[["addRiskGroup"]],
plot_adj = function() private$.items[["plot_adj"]],
mydataview_nomogram2 = function() private$.items[["mydataview_nomogram2"]],
mydataview_nomogram = function() private$.items[["mydataview_nomogram"]],
plot_nomogram = function() private$.items[["plot_nomogram"]],
nomogram_display = function() private$.items[["nomogram_display"]]),
private = list(),
public=list(
initialize=function(options) {
super$initialize(
options=options,
name="",
title="Multivariable Survival Analysis",
refs=list(
"multivariable",
"survivaltutorial",
"survivalrwnahhas",
"ClinicoPathJamoviModule"))
self$add(jmvcore::Html$new(
options=options,
name="todo",
title="To Do",
clearWith=list(
"outcome",
"outcomeLevel",
"overalltime",
"explanatory",
"contexpl",
"fudate",
"dxdate",
"tint",
"multievent")))
self$add(jmvcore::Html$new(
options=options,
name="text",
title="Multivariable Survival",
refs="finalfit",
clearWith=list(
"outcome",
"outcomeLevel",
"overalltime",
"explanatory",
"contexpl",
"fudate",
"dxdate",
"tint",
"multievent")))
self$add(jmvcore::Html$new(
options=options,
name="text2",
title="",
refs="finalfit",
clearWith=list(
"outcome",
"outcomeLevel",
"overalltime",
"explanatory",
"contexpl",
"fudate",
"dxdate",
"tint",
"multievent")))
self$add(jmvcore::Image$new(
options=options,
name="plot",
title="Hazards Regression Plot",
width=600,
height=450,
renderFun=".plot",
requiresData=TRUE,
visible="(hr && sty:t1)",
refs="finalfit",
clearWith=list(
"hr",
"sty",
"outcome",
"outcomeLevel",
"overalltime",
"explanatory",
"contexpl",
"fudate",
"dxdate",
"tint",
"multievent")))
self$add(jmvcore::Image$new(
options=options,
name="plot3",
title="Hazards Regression Plot",
width=800,
height=600,
renderFun=".plot3",
requiresData=TRUE,
visible="(hr && sty:t3)",
refs="survminer",
clearWith=list(
"hr",
"sty",
"outcome",
"outcomeLevel",
"overalltime",
"explanatory",
"contexpl",
"fudate",
"dxdate",
"tint",
"multievent")))
self$add(jmvcore::Preformatted$new(
options=options,
name="cox_ph",
title="Proportional Hazards Assumption",
visible="(ph_cox)",
clearWith=list(
"explanatory",
"outcome",
"outcomeLevel",
"overalltime",
"fudate",
"dxdate",
"tint",
"multievent",
"contexpl")))
self$add(jmvcore::Image$new(
options=options,
name="plot8",
title="Proportional Hazards Assumption",
width=600,
height=450,
renderFun=".plot8",
visible="(ph_cox)",
requiresData=TRUE,
clearWith=list(
"ph_cox",
"endplot",
"byplot",
"explanatory",
"outcome",
"outcomeLevel",
"overalltime",
"fudate",
"dxdate",
"tint",
"multievent",
"contexpl")))
self$add(jmvcore::Image$new(
options=options,
name="plotKM",
title="Kaplan-Meier",
width=600,
height=450,
renderFun=".plotKM",
requiresData=TRUE,
visible="(km)",
refs="finalfit",
clearWith=list(
"km",
"endplot",
"byplot",
"ci95",
"risktable",
"outcome",
"outcomeLevel",
"overalltime",
"explanatory",
"contexpl",
"fudate",
"dxdate",
"tint",
"multievent",
"adjexplanatory",
"pplot",
"censored",
"medianline")))
self$add(jmvcore::Preformatted$new(
options=options,
name="risk_score_analysis",
title="Risk Score Analysis",
visible="(calculateRiskScore)",
clearWith=list(
"calculateRiskScore",
"outcome",
"outcomeLevel",
"explanatory",
"contexpl",
"numRiskGroups")))
self$add(jmvcore::Html$new(
options=options,
name="risk_score_analysis2",
title="Risk Score Analysis",
visible="(calculateRiskScore)",
clearWith=list(
"calculateRiskScore",
"outcome",
"outcomeLevel",
"explanatory",
"contexpl",
"numRiskGroups")))
self$add(jmvcore::Table$new(
options=options,
name="riskScoreTable",
title="Risk Score Summary",
visible="(calculateRiskScore)",
rows=0,
columns=list(
list(
`name`="group",
`title`="Risk Group",
`type`="text"),
list(
`name`="n_patients",
`title`="N",
`type`="integer"),
list(
`name`="percent",
`title`="Percent",
`type`="number"),
list(
`name`="median_score",
`title`="Median Score",
`type`="number"),
list(
`name`="events",
`title`="Events",
`type`="integer")),
clearWith=list(
"calculateRiskScore",
"outcome",
"outcomeLevel",
"explanatory",
"contexpl",
"numRiskGroups")))
self$add(jmvcore::Html$new(
options=options,
name="riskScoreMetrics",
title="Risk Score Model Metrics",
visible="(calculateRiskScore)",
clearWith=list(
"calculateRiskScore",
"outcome",
"outcomeLevel",
"explanatory",
"contexpl",
"numRiskGroups")))
self$add(jmvcore::Image$new(
options=options,
name="riskGroupPlot",
title="Risk Group Survival Plot",
width=600,
height=450,
renderFun=".plotRiskGroups",
requiresData=TRUE,
visible="(plotRiskGroups)",
clearWith=list(
"calculateRiskScore",
"outcome",
"outcomeLevel",
"explanatory",
"contexpl",
"numRiskGroups")))
self$add(jmvcore::Html$new(
options=options,
name="stratificationExplanation",
title="Stratification Notes",
visible="(use_stratify)"))
self$add(jmvcore::Output$new(
options=options,
name="calculatedtime",
title="Add Calculated Time to Data",
varTitle="`Calculated Time in Multivariable Survival Function - from ${ dxdate } to { fudate }`",
varDescription="Calculated Time from given Dates in Multivariable Survival Analysis",
clearWith=list(
"tint",
"dxdate",
"fudate")))
self$add(jmvcore::Output$new(
options=options,
name="outcomeredefined",
title="Add Redefined Outcome to Data",
varTitle="`Redefined Outcome in Multivariable Survival Function - from ${ outcome } for analysis { analysistype }`",
varDescription="Redefined Outcome from Outcome based on Analysis Type in Multivariable Survival Analysis",
clearWith=list(
"outcome",
"analysistype",
"multievent")))
self$add(jmvcore::Output$new(
options=options,
name="addRiskScore",
title="Add Calculated Risk Score to Data",
varTitle="`Calculated Risk Score in Multivariable Survival Function`",
varDescription="Calculated Risk Score Based on Model",
clearWith=list(
"addRiskScore",
"calculateRiskScore",
"outcome",
"outcomeLevel",
"overalltime",
"explanatory",
"contexpl",
"fudate",
"dxdate",
"tint",
"multievent",
"addRiskGroup")))
self$add(jmvcore::Output$new(
options=options,
name="addRiskGroup",
title="Add Calculated Risk Group to Data",
varTitle="`Calculated Risk Group in Multivariable Survival Function`",
varDescription="Calculated Risk Group Based on Model",
clearWith=list(
"addRiskScore",
"calculateRiskScore",
"outcome",
"outcomeLevel",
"overalltime",
"explanatory",
"contexpl",
"fudate",
"dxdate",
"tint",
"multievent",
"addRiskGroup")))
self$add(jmvcore::Image$new(
options=options,
name="plot_adj",
title="Adjusted Survival Plot",
width=600,
height=450,
renderFun=".plot_adj",
visible="(ac)",
refs="survminer",
clearWith=list(
"ac",
"adjexplanatory",
"ci95",
"risktable",
"ac_method",
"endplot",
"byplot",
"outcome",
"outcomeLevel",
"overalltime",
"explanatory",
"contexpl",
"fudate",
"dxdate",
"tint",
"multievent",
"adjexplanatory",
"pplot",
"censored",
"medianline")))
self$add(jmvcore::Preformatted$new(
options=options,
name="mydataview_nomogram2",
title="mydataview_nomogram2"))
self$add(jmvcore::Preformatted$new(
options=options,
name="mydataview_nomogram",
title="mydataview_nomogram"))
self$add(jmvcore::Image$new(
options=options,
name="plot_nomogram",
title="Nomogram",
width=800,
height=600,
requiresData=TRUE,
renderFun=".plot_nomogram",
visible="(showNomogram)"))
self$add(jmvcore::Html$new(
options=options,
name="nomogram_display",
title="Nomogram Scoring Guide",
visible="(showNomogram)"))}))
multisurvivalBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"multisurvivalBase",
inherit = jmvcore::Analysis,
public = list(
initialize = function(options, data=NULL, datasetId="", analysisId="", revision=0) {
super$initialize(
package = "jsurvival",
name = "multisurvival",
version = c(1,0,0),
options = options,
results = multisurvivalResults$new(options=options),
data = data,
datasetId = datasetId,
analysisId = analysisId,
revision = revision,
pause = NULL,
completeWhenFilled = FALSE,
requiresMissings = FALSE,
weightsSupport = 'none')
}))
#' Multivariable Survival Analysis
#'
#' Function for Multivariable Survival Analysis using Cox-regression.
#'
#' @examples
#' \donttest{
#' # example will be added
#'}
#' @param data The dataset to be analyzed, provided as a data frame. Must
#' contain the variables specified in the options below.
#' @param elapsedtime The numeric variable representing follow-up time until
#' the event or last observation. If \code{tint} = false, this should be a
#' pre-calculated numeric time variable. If \code{tint} = true, \code{dxdate}
#' and \code{fudate} will be used to calculate this time.
#' @param tint If true, survival time will be calculated from \code{dxdate}
#' and \code{fudate}. If false, \code{elapsedtime} should be provided as a
#' pre-calculated numeric variable.
#' @param dxdate Date of diagnosis. Required if \code{tint} = true. Must match
#' the format specified in \code{timetypedata}.
#' @param fudate Follow-up date or date of last observation. Required if
#' \code{tint} = true. Must match the format specified in \code{timetypedata}.
#' @param timetypedata Specifies the format of the date variables in the input
#' data. This is critical if \code{tint = true}, as \code{dxdate} and
#' \code{fudate} will be parsed according to this format to calculate survival
#' time. For example, if your data files record dates as "YYYY-MM-DD", select
#' \code{ymd}.
#' @param timetypeoutput The units in which survival time is reported in the
#' output. Choose from days, weeks, months, or years.
#' @param uselandmark If true, applies a landmark analysis starting at a
#' specified time point.
#' @param landmark The time point (in the units defined by
#' \code{timetypeoutput}) at which to start landmark analyses. Only used if
#' \code{uselandmark} = true.
#' @param outcome The outcome variable. Typically indicates event status
#' (e.g., death, recurrence). For survival analysis, this may be a factor or
#' numeric event indicator.
#' @param outcomeLevel The level of \code{outcome} considered as the event.
#' For example, if \code{outcome} is a factor, specify which level indicates
#' the event occurrence.
#' @param dod The level of \code{outcome} corresponding to death due to
#' disease, if applicable.
#' @param dooc The level of \code{outcome} corresponding to death due to other
#' causes, if applicable.
#' @param awd The level of \code{outcome} corresponding to alive with disease,
#' if applicable.
#' @param awod The level of \code{outcome} corresponding to alive without
#' disease, if applicable.
#' @param analysistype Type of survival analysis: - overall: All-cause
#' survival - cause: Cause-specific survival - compete: Competing risks
#' analysis
#' @param explanatory Categorical explanatory (predictor) variables included
#' in the Cox model.
#' @param contexpl Continuous explanatory (predictor) variables included in
#' the Cox model.
#' @param multievent If true, multiple event levels will be considered for
#' competing risks analysis. Requires specifying \code{dod}, \code{dooc}, etc.
#' @param hr If true, generates a plot of hazard ratios for each explanatory
#' variable in the Cox model.
#' @param sty The style of the hazard ratio (forest) plot. "finalfit" or
#' "survminer forestplot".
#' @param ph_cox If true, tests the proportional hazards assumption for the
#' Cox model. Use if you suspect violations of the PH assumption.
#' @param km If true, produces a Kaplan-Meier survival plot. Useful for
#' visualization of survival functions without covariate adjustment.
#' @param endplot The maximum follow-up time (in units defined by
#' \code{timetypeoutput}) to display on survival plots.
#' @param byplot The interval (in units defined by \code{timetypeoutput}) at
#' which time points or labels are shown on plots.
#' @param ci95 If true, displays 95\% confidence intervals around the survival
#' estimates on plots.
#' @param risktable If true, displays the number of subjects at risk at each
#' time point below the survival plot.
#' @param censored If true, marks censored observations (e.g., using tick
#' marks) on the survival plot.
#' @param medianline If true, displays a line indicating the median survival
#' time on the survival plot.
#' @param pplot If true, displays the p-value from the survival comparison
#' test on the survival plot.
#' @param cutp .
#' @param calculateRiskScore If true, calculates a risk score from the Cox
#' model coefficients for each individual.
#' @param numRiskGroups Select the number of risk groups to create from the
#' risk scores. The data will be divided into equal quantiles based on this
#' selection.
#' @param plotRiskGroups If true, stratifies individuals into risk groups
#' based on their calculated risk scores and plots their survival curves.
#' @param ac .
#' @param adjexplanatory .
#' @param ac_method Method for computing adjusted survival curves
#' @param showNomogram .
#' @param use_stratify If true, uses stratification to handle variables that
#' violate the proportional hazards assumption. Stratification creates
#' separate baseline hazard functions for different groups.
#' @param stratvar Variables used for stratification. When proportional
#' hazards are not met, stratification can adjust the model to better fit the
#' data by allowing different baseline hazards.
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$todo} \tab \tab \tab \tab \tab a html \cr
#' \code{results$text} \tab \tab \tab \tab \tab a html \cr
#' \code{results$text2} \tab \tab \tab \tab \tab a html \cr
#' \code{results$plot} \tab \tab \tab \tab \tab an image \cr
#' \code{results$plot3} \tab \tab \tab \tab \tab an image \cr
#' \code{results$cox_ph} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$plot8} \tab \tab \tab \tab \tab an image \cr
#' \code{results$plotKM} \tab \tab \tab \tab \tab an image \cr
#' \code{results$risk_score_analysis} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$risk_score_analysis2} \tab \tab \tab \tab \tab a html \cr
#' \code{results$riskScoreTable} \tab \tab \tab \tab \tab a table \cr
#' \code{results$riskScoreMetrics} \tab \tab \tab \tab \tab a html \cr
#' \code{results$riskGroupPlot} \tab \tab \tab \tab \tab an image \cr
#' \code{results$stratificationExplanation} \tab \tab \tab \tab \tab a html \cr
#' \code{results$calculatedtime} \tab \tab \tab \tab \tab an output \cr
#' \code{results$outcomeredefined} \tab \tab \tab \tab \tab an output \cr
#' \code{results$addRiskScore} \tab \tab \tab \tab \tab an output \cr
#' \code{results$addRiskGroup} \tab \tab \tab \tab \tab an output \cr
#' \code{results$plot_adj} \tab \tab \tab \tab \tab an image \cr
#' \code{results$mydataview_nomogram2} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$mydataview_nomogram} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$plot_nomogram} \tab \tab \tab \tab \tab an image \cr
#' \code{results$nomogram_display} \tab \tab \tab \tab \tab a html \cr
#' }
#'
#' Tables can be converted to data frames with \code{asDF} or \code{\link{as.data.frame}}. For example:
#'
#' \code{results$riskScoreTable$asDF}
#'
#' \code{as.data.frame(results$riskScoreTable)}
#'
#' @export
multisurvival <- function(
data,
elapsedtime,
tint = FALSE,
dxdate,
fudate,
timetypedata = "ymd",
timetypeoutput = "months",
uselandmark = FALSE,
landmark = 3,
outcome,
outcomeLevel,
dod,
dooc,
awd,
awod,
analysistype = "overall",
explanatory,
contexpl,
multievent = FALSE,
hr = FALSE,
sty = "t1",
ph_cox = FALSE,
km = FALSE,
endplot = 60,
byplot = 12,
ci95 = FALSE,
risktable = FALSE,
censored = FALSE,
medianline = "none",
pplot = TRUE,
cutp = "12, 36, 60",
calculateRiskScore = FALSE,
numRiskGroups = "four",
plotRiskGroups = FALSE,
ac = FALSE,
adjexplanatory,
ac_method = "average",
showNomogram = FALSE,
use_stratify = FALSE,
stratvar) {
if ( ! requireNamespace("jmvcore", quietly=TRUE))
stop("multisurvival requires jmvcore to be installed (restart may be required)")
if ( ! missing(elapsedtime)) elapsedtime <- jmvcore::resolveQuo(jmvcore::enquo(elapsedtime))
if ( ! missing(dxdate)) dxdate <- jmvcore::resolveQuo(jmvcore::enquo(dxdate))
if ( ! missing(fudate)) fudate <- jmvcore::resolveQuo(jmvcore::enquo(fudate))
if ( ! missing(outcome)) outcome <- jmvcore::resolveQuo(jmvcore::enquo(outcome))
if ( ! missing(explanatory)) explanatory <- jmvcore::resolveQuo(jmvcore::enquo(explanatory))
if ( ! missing(contexpl)) contexpl <- jmvcore::resolveQuo(jmvcore::enquo(contexpl))
if ( ! missing(adjexplanatory)) adjexplanatory <- jmvcore::resolveQuo(jmvcore::enquo(adjexplanatory))
if ( ! missing(stratvar)) stratvar <- jmvcore::resolveQuo(jmvcore::enquo(stratvar))
if (missing(data))
data <- jmvcore::marshalData(
parent.frame(),
`if`( ! missing(elapsedtime), elapsedtime, NULL),
`if`( ! missing(dxdate), dxdate, NULL),
`if`( ! missing(fudate), fudate, NULL),
`if`( ! missing(outcome), outcome, NULL),
`if`( ! missing(explanatory), explanatory, NULL),
`if`( ! missing(contexpl), contexpl, NULL),
`if`( ! missing(adjexplanatory), adjexplanatory, NULL),
`if`( ! missing(stratvar), stratvar, NULL))
for (v in explanatory) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
for (v in adjexplanatory) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
for (v in stratvar) if (v %in% names(data)) data[[v]] <- as.factor(data[[v]])
options <- multisurvivalOptions$new(
elapsedtime = elapsedtime,
tint = tint,
dxdate = dxdate,
fudate = fudate,
timetypedata = timetypedata,
timetypeoutput = timetypeoutput,
uselandmark = uselandmark,
landmark = landmark,
outcome = outcome,
outcomeLevel = outcomeLevel,
dod = dod,
dooc = dooc,
awd = awd,
awod = awod,
analysistype = analysistype,
explanatory = explanatory,
contexpl = contexpl,
multievent = multievent,
hr = hr,
sty = sty,
ph_cox = ph_cox,
km = km,
endplot = endplot,
byplot = byplot,
ci95 = ci95,
risktable = risktable,
censored = censored,
medianline = medianline,
pplot = pplot,
cutp = cutp,
calculateRiskScore = calculateRiskScore,
numRiskGroups = numRiskGroups,
plotRiskGroups = plotRiskGroups,
ac = ac,
adjexplanatory = adjexplanatory,
ac_method = ac_method,
showNomogram = showNomogram,
use_stratify = use_stratify,
stratvar = stratvar)
analysis <- multisurvivalClass$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.