Skip to content

Commit 73b17fe

Browse files
committed
v0.0.33 for jamovi library
Add parametric and tree options to survival analyses Introduces parametric survival modeling options (flexsurv, distribution selection, splines, extrapolation, diagnostics, and plots) to the survival module. Adds decision tree (survival tree) options to multivariable survival analysis. Enhances odds ratio analysis with Firth penalized regression and user-specified positive predictor level. Updates documentation, version numbers, and jamovi module metadata accordingly.
1 parent f9b6751 commit 73b17fe

31 files changed

+1329
-661
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Type: Package
22
Package: jsurvival
33
Title: Survival Module of ClinicoPath for jamovi
4-
Version: 0.0.32.64
5-
Date: 2025-12-31
4+
Version: 0.0.33
5+
Date: 2026-01-17
66
Authors@R: person(given = "Serdar", family = "Balci", role = c("aut",
77
"cre"), email = "serdarbalci@serdarbalci.com", comment =
88
c(ORCID = "0000-0002-7852-3851"))

R/datetimeconverter.h.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ datetimeconverterBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Cl
482482
super$initialize(
483483
package = "jsurvival",
484484
name = "datetimeconverter",
485-
version = c(0,0,32),
485+
version = c(0,0,33),
486486
options = options,
487487
results = datetimeconverterResults$new(options=options),
488488
data = data,
@@ -504,7 +504,7 @@ datetimeconverterBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Cl
504504
#' creating time-based variables.
505505
#'
506506
#' @examples
507-
#' # Basic datetime conversion: '0.0.32'
507+
#' # Basic datetime conversion: '0.0.33'
508508
#' datetimeconverter(
509509
#' data = study_data,
510510
#' datetime_var = "event_date",

R/multisurvival.b.R

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8142,5 +8142,50 @@ where 0.5 suggests no discriminative ability and 1.0 indicates perfect discrimin
81428142
})
81438143
}
81448144

8145-
) # Close private list
8145+
), # End of private list
8146+
public = list(
8147+
#' @description
8148+
#' Generate R source code for Multi-Variable Survival analysis
8149+
#' @return Character string with R syntax for reproducible analysis
8150+
asSource = function() {
8151+
elapsedtime <- self$options$elapsedtime
8152+
outcome <- self$options$outcome
8153+
8154+
if (is.null(elapsedtime) || is.null(outcome))
8155+
return('')
8156+
8157+
# Escape variable names that contain spaces or special characters
8158+
elapsedtime_escaped <- if (!is.null(elapsedtime) && !identical(make.names(elapsedtime), elapsedtime)) {
8159+
paste0('`', elapsedtime, '`')
8160+
} else {
8161+
elapsedtime
8162+
}
8163+
8164+
outcome_escaped <- if (!is.null(outcome) && !identical(make.names(outcome), outcome)) {
8165+
paste0('`', outcome, '`')
8166+
} else {
8167+
outcome
8168+
}
8169+
8170+
# Build arguments
8171+
elapsedtime_arg <- paste0('elapsedtime = "', elapsedtime_escaped, '"')
8172+
outcome_arg <- paste0('outcome = "', outcome_escaped, '"')
8173+
8174+
# Get other arguments using base helper (if available)
8175+
args <- ''
8176+
if (!is.null(private$.asArgs)) {
8177+
args <- private$.asArgs(incData = FALSE)
8178+
}
8179+
if (args != '')
8180+
args <- paste0(',\n ', args)
8181+
8182+
# Get package name dynamically
8183+
pkg_name <- utils::packageName()
8184+
if (is.null(pkg_name)) pkg_name <- "ClinicoPath" # fallback
8185+
8186+
# Build complete function call
8187+
paste0(pkg_name, '::multisurvival(\n data = data,\n ',
8188+
elapsedtime_arg, ',\n ', outcome_arg, args, ')')
8189+
}
8190+
) # End of public list
81468191
)

R/multisurvival.h.R

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ multisurvivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Cla
4848
person_time = FALSE,
4949
time_intervals = "12, 36, 60",
5050
rate_multiplier = 100,
51+
use_tree = FALSE,
52+
min_node = 20,
53+
complexity = 0.01,
54+
max_depth = 5,
55+
show_terminal_nodes = FALSE,
5156
showExplanations = FALSE,
5257
showSummaries = TRUE, ...) {
5358

@@ -314,6 +319,32 @@ multisurvivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Cla
314319
"rate_multiplier",
315320
rate_multiplier,
316321
default=100)
322+
private$..use_tree <- jmvcore::OptionBool$new(
323+
"use_tree",
324+
use_tree,
325+
default=FALSE)
326+
private$..min_node <- jmvcore::OptionInteger$new(
327+
"min_node",
328+
min_node,
329+
min=5,
330+
max=100,
331+
default=20)
332+
private$..complexity <- jmvcore::OptionNumber$new(
333+
"complexity",
334+
complexity,
335+
min=0.001,
336+
max=0.1,
337+
default=0.01)
338+
private$..max_depth <- jmvcore::OptionInteger$new(
339+
"max_depth",
340+
max_depth,
341+
min=1,
342+
max=10,
343+
default=5)
344+
private$..show_terminal_nodes <- jmvcore::OptionBool$new(
345+
"show_terminal_nodes",
346+
show_terminal_nodes,
347+
default=FALSE)
317348
private$..showExplanations <- jmvcore::OptionBool$new(
318349
"showExplanations",
319350
showExplanations,
@@ -369,6 +400,11 @@ multisurvivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Cla
369400
self$.addOption(private$..person_time)
370401
self$.addOption(private$..time_intervals)
371402
self$.addOption(private$..rate_multiplier)
403+
self$.addOption(private$..use_tree)
404+
self$.addOption(private$..min_node)
405+
self$.addOption(private$..complexity)
406+
self$.addOption(private$..max_depth)
407+
self$.addOption(private$..show_terminal_nodes)
372408
self$.addOption(private$..showExplanations)
373409
self$.addOption(private$..showSummaries)
374410
}),
@@ -419,6 +455,11 @@ multisurvivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Cla
419455
person_time = function() private$..person_time$value,
420456
time_intervals = function() private$..time_intervals$value,
421457
rate_multiplier = function() private$..rate_multiplier$value,
458+
use_tree = function() private$..use_tree$value,
459+
min_node = function() private$..min_node$value,
460+
complexity = function() private$..complexity$value,
461+
max_depth = function() private$..max_depth$value,
462+
show_terminal_nodes = function() private$..show_terminal_nodes$value,
422463
showExplanations = function() private$..showExplanations$value,
423464
showSummaries = function() private$..showSummaries$value),
424465
private = list(
@@ -468,6 +509,11 @@ multisurvivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Cla
468509
..person_time = NA,
469510
..time_intervals = NA,
470511
..rate_multiplier = NA,
512+
..use_tree = NA,
513+
..min_node = NA,
514+
..complexity = NA,
515+
..max_depth = NA,
516+
..show_terminal_nodes = NA,
471517
..showExplanations = NA,
472518
..showSummaries = NA)
473519
)
@@ -1169,7 +1215,7 @@ multisurvivalBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
11691215
super$initialize(
11701216
package = "jsurvival",
11711217
name = "multisurvival",
1172-
version = c(0,0,32),
1218+
version = c(0,0,33),
11731219
options = options,
11741220
results = multisurvivalResults$new(options=options),
11751221
data = data,
@@ -1381,6 +1427,19 @@ multisurvivalBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
13811427
#' 60+.
13821428
#' @param rate_multiplier Specify the multiplier for incidence rates (e.g.,
13831429
#' 100 for rates per 100 person-years, 1000 for rates per 1000 person-years).
1430+
#' @param use_tree If true, fits a survival decision tree to identify
1431+
#' subgroups with different survival outcomes. Decision trees provide an
1432+
#' intuitive alternative to Cox regression for identifying risk factors.
1433+
#' @param min_node The minimum number of observations required in a terminal
1434+
#' node. Larger values create simpler trees that may be more generalizable but
1435+
#' potentially miss important subgroups.
1436+
#' @param complexity The complexity parameter for tree pruning. Higher values
1437+
#' result in smaller trees. This parameter controls the trade-off between tree
1438+
#' size and goodness of fit.
1439+
#' @param max_depth The maximum depth of the decision tree. Limits the
1440+
#' complexity of the tree to avoid overfitting.
1441+
#' @param show_terminal_nodes If true, displays Kaplan-Meier survival curves
1442+
#' for each terminal node of the decision tree.
13841443
#' @param showExplanations Display detailed explanations for each analysis
13851444
#' component to help interpret the statistical methods and results.
13861445
#' @param showSummaries Display natural language summaries alongside tables
@@ -1491,6 +1550,11 @@ multisurvival <- function(
14911550
person_time = FALSE,
14921551
time_intervals = "12, 36, 60",
14931552
rate_multiplier = 100,
1553+
use_tree = FALSE,
1554+
min_node = 20,
1555+
complexity = 0.01,
1556+
max_depth = 5,
1557+
show_terminal_nodes = FALSE,
14941558
showExplanations = FALSE,
14951559
showSummaries = TRUE) {
14961560

@@ -1564,6 +1628,11 @@ multisurvival <- function(
15641628
person_time = person_time,
15651629
time_intervals = time_intervals,
15661630
rate_multiplier = rate_multiplier,
1631+
use_tree = use_tree,
1632+
min_node = min_node,
1633+
complexity = complexity,
1634+
max_depth = max_depth,
1635+
show_terminal_nodes = show_terminal_nodes,
15671636
showExplanations = showExplanations,
15681637
showSummaries = showSummaries)
15691638

0 commit comments

Comments
 (0)