From e6b11ed3c6651fb45b26e3be6803559d831c0b4c Mon Sep 17 00:00:00 2001 From: Ilse <55379552+iaugusty@users.noreply.github.com> Date: Wed, 20 Nov 2024 09:33:33 +0100 Subject: [PATCH 1/2] 1301 feature request add confidence intervals for quantiles in surv time (#1306) # Pull Request Fixes #1301 @melkiades I'm not sure about the impact of adding new stats to an analyze function on the remainder of the code/packages. Could you review and share your thoughts? This is the first function for which we'd like to add extra stats, there will be more functions for which we'd like to combine the stat and it's confidence interval into 1 line. Once we know the approach we can follow, more of these types of updates might follow. --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Davide Garolini Co-authored-by: Joe Zhu Co-authored-by: shajoezhu --- NEWS.md | 5 + R/analyze_variables.R | 11 + R/survival_coxph_pairwise.R | 8 +- R/survival_time.R | 50 ++++- R/survival_timepoint.R | 20 +- R/utils_default_stats_formats_labels.R | 38 +++- man/analyze_variables.Rd | 2 +- man/compare_variables.Rd | 2 +- man/summarize_change.Rd | 2 +- man/survival_time.Rd | 5 +- man/survival_timepoint.Rd | 4 +- tests/testthat/_snaps/analyze_variables.md | 198 +++++++++++++----- tests/testthat/_snaps/compare_variables.md | 12 +- tests/testthat/_snaps/summarize_change.md | 72 +++++++ .../_snaps/survival_coxph_pairwise.md | 20 ++ tests/testthat/_snaps/survival_time.md | 68 ++++-- tests/testthat/_snaps/survival_timepoint.md | 25 +++ .../utils_default_stats_formats_labels.md | 50 +++-- tests/testthat/test-utils_rtables.R | 1 + 19 files changed, 482 insertions(+), 111 deletions(-) diff --git a/NEWS.md b/NEWS.md index 7e8b78f29d..ead9eb614e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -20,6 +20,11 @@ # tern 0.9.6 ### Enhancements +* Added `median_ci_3d` to `s_summary` which includes estimate and confidence interval in one statistic. +* Added `median_ci_3d`, `quantiles_lower` and `quantiles_upper` to `s_surv_time` which includes estimate and confidence interval in one statistic. +* Added `hr_ci_3d` to `s_coxph_pairwise` which includes estimate and confidence interval in one statistic. +* Added `event_free_rate_3d` to `s_surv_timepoint` which includes estimate and confidence interval in one statistic. +* Added `rate_diff_ci_3d` to `s_surv_timepoint_diff` which includes estimate and confidence interval in one statistic. * Added `errorbar_width` and `linetype` parameters to `g_lineplot`. * Added the `.formats` argument to `tabulate_rsp_subgroups` and `tabulate_survival_subgroups` to allow users to specify formats. * Added the `riskdiff` argument to `tabulate_rsp_subgroups` and `tabulate_survival_subgroups` to allow users to add a risk difference table column, and function `control_riskdiff` to specify settings for the risk difference column. diff --git a/R/analyze_variables.R b/R/analyze_variables.R index 5af2961f10..392a253f18 100644 --- a/R/analyze_variables.R +++ b/R/analyze_variables.R @@ -190,6 +190,8 @@ s_summary.numeric <- function(x, mean_sdi <- y$mean[[1]] + c(-1, 1) * stats::sd(x, na.rm = FALSE) names(mean_sdi) <- c("mean_sdi_lwr", "mean_sdi_upr") y$mean_sdi <- formatters::with_label(mean_sdi, "Mean -/+ 1xSD") + mean_ci_3d <- c(y$mean, y$mean_ci) + y$mean_ci_3d <- formatters::with_label(mean_ci_3d, paste0("Mean (", f_conf_level(control$conf_level), ")")) mean_pval <- stat_mean_pval(x, test_mean = control$test_mean, na.rm = FALSE, n_min = 2) y$mean_pval <- formatters::with_label(mean_pval, paste("Mean", f_pval(control$test_mean))) @@ -201,6 +203,9 @@ s_summary.numeric <- function(x, median_ci <- stat_median_ci(x, conf_level = control$conf_level, na.rm = FALSE, gg_helper = FALSE) y$median_ci <- formatters::with_label(median_ci, paste("Median", f_conf_level(control$conf_level))) + median_ci_3d <- c(y$median, median_ci) + y$median_ci_3d <- formatters::with_label(median_ci_3d, paste0("Median (", f_conf_level(control$conf_level), ")")) + q <- control$quantiles if (any(is.na(x))) { qnts <- rep(NA_real_, length(q)) @@ -233,6 +238,12 @@ s_summary.numeric <- function(x, y$geom_cv <- c("geom_cv" = sqrt(exp(stats::sd(log(x_no_negative_vals), na.rm = FALSE) ^ 2) - 1) * 100) # styler: off + geom_mean_ci_3d <- c(y$geom_mean, y$geom_mean_ci) + y$geom_mean_ci_3d <- formatters::with_label( + geom_mean_ci_3d, + paste0("Geometric Mean (", f_conf_level(control$conf_level), ")") + ) + y } diff --git a/R/survival_coxph_pairwise.R b/R/survival_coxph_pairwise.R index 823c159379..f8cf696bf5 100644 --- a/R/survival_coxph_pairwise.R +++ b/R/survival_coxph_pairwise.R @@ -66,6 +66,7 @@ s_coxph_pairwise <- function(df, pvalue = formatters::with_label("", paste0("p-value (", pval_method, ")")), hr = formatters::with_label("", "Hazard Ratio"), hr_ci = formatters::with_label("", f_conf_level(conf_level)), + hr_ci_3d = formatters::with_label("", paste0("Hazard Ratio (", f_conf_level(conf_level), ")")), n_tot = formatters::with_label("", "Total n"), n_tot_events = formatters::with_label("", "Total events") ) @@ -112,6 +113,10 @@ s_coxph_pairwise <- function(df, pvalue = formatters::with_label(unname(pval), paste0("p-value (", pval_method, ")")), hr = formatters::with_label(sum_cox$conf.int[1, 1], "Hazard Ratio"), hr_ci = formatters::with_label(unname(sum_cox$conf.int[1, 3:4]), f_conf_level(conf_level)), + hr_ci_3d = formatters::with_label( + c(sum_cox$conf.int[1, 1], unname(sum_cox$conf.int[1, 3:4])), + paste0("Hazard Ratio (", f_conf_level(conf_level), ")") + ), n_tot = formatters::with_label(sum_cox$n, "Total n"), n_tot_events = formatters::with_label(sum_cox$nevent, "Total events") ) @@ -125,11 +130,12 @@ s_coxph_pairwise <- function(df, #' @keywords internal a_coxph_pairwise <- make_afun( s_coxph_pairwise, - .indent_mods = c(pvalue = 0L, hr = 0L, hr_ci = 1L, n_tot = 0L, n_tot_events = 0L), + .indent_mods = c(pvalue = 0L, hr = 0L, hr_ci = 1L, n_tot = 0L, n_tot_events = 0L, hr_ci_3d = 0L), .formats = c( pvalue = "x.xxxx | (<0.0001)", hr = "xx.xx", hr_ci = "(xx.xx, xx.xx)", + hr_ci_3d = "xx.xx (xx.xx - xx.xx)", n_tot = "xx.xx", n_tot_events = "xx.xx" ) diff --git a/R/survival_time.R b/R/survival_time.R index de12ff681d..6d1d2d5ee9 100644 --- a/R/survival_time.R +++ b/R/survival_time.R @@ -44,7 +44,10 @@ NULL #' * `s_surv_time()` returns the statistics: #' * `median`: Median survival time. #' * `median_ci`: Confidence interval for median time. +#' * `median_ci_3d`: Median with confidence interval for median time. #' * `quantiles`: Survival time for two specified quantiles. +#' * `quantiles_lower`: quantile with confidence interval for the first specified quantile. +#' * `quantiles_upper`: quantile with confidence interval for the second specified quantile. #' * `range_censor`: Survival time range for censored observations. #' * `range_event`: Survival time range for observations with events. #' * `range`: Survival time range for all observations. @@ -71,10 +74,24 @@ s_surv_time <- function(df, conf.type = conf_type ) srv_tab <- summary(srv_fit, extend = TRUE)$table - srv_qt_tab <- stats::quantile(srv_fit, probs = quantiles)$quantile + srv_qt_tab_pre <- stats::quantile(srv_fit, probs = quantiles) + srv_qt_tab <- srv_qt_tab_pre$quantile range_censor <- range_noinf(df[[.var]][!df[[is_event]]], na.rm = TRUE) range_event <- range_noinf(df[[.var]][df[[is_event]]], na.rm = TRUE) range <- range_noinf(df[[.var]], na.rm = TRUE) + + names(quantiles) <- as.character(100 * quantiles) + srv_qt_tab_pre <- unlist(srv_qt_tab_pre) + srv_qt_ci <- lapply(quantiles, function(x) { + name <- as.character(100 * x) + + c( + srv_qt_tab_pre[[paste0("quantile.", name)]], + srv_qt_tab_pre[[paste0("lower.", name)]], + srv_qt_tab_pre[[paste0("upper.", name)]] + ) + }) + list( median = formatters::with_label(unname(srv_tab["median"]), "Median"), median_ci = formatters::with_label( @@ -85,7 +102,20 @@ s_surv_time <- function(df, ), range_censor = formatters::with_label(range_censor, "Range (censored)"), range_event = formatters::with_label(range_event, "Range (event)"), - range = formatters::with_label(range, "Range") + range = formatters::with_label(range, "Range"), + median_ci_3d = formatters::with_label( + c( + unname(srv_tab["median"]), + unname(srv_tab[paste0(srv_fit$conf.int, c("LCL", "UCL"))]) + ), + paste0("Median (", f_conf_level(conf_level), ")") + ), + quantiles_lower = formatters::with_label( + unname(srv_qt_ci[[1]]), paste0(quantiles[1] * 100, "%-ile (", f_conf_level(conf_level), ")") + ), + quantiles_upper = formatters::with_label( + unname(srv_qt_ci[[2]]), paste0(quantiles[2] * 100, "%-ile (", f_conf_level(conf_level), ")") + ) ) } @@ -122,8 +152,17 @@ a_surv_time <- function(df, rng_censor_upr <- x_stats[["range_censor"]][2] # Use method-specific defaults - fmts <- c(median_ci = "(xx.x, xx.x)", quantiles = "xx.x, xx.x", range = "xx.x to xx.x") - lbls <- c(median_ci = "95% CI", range = "Range", range_censor = "Range (censored)", range_event = "Range (event)") + fmts <- c( + median_ci = "(xx.x, xx.x)", quantiles = "xx.x, xx.x", range = "xx.x to xx.x", + median_ci_3d = "xx.x (xx.x - xx.x)", + quantiles_lower = "xx.x (xx.x - xx.x)", quantiles_upper = "xx.x (xx.x - xx.x)" + ) + lbls <- c( + median_ci = "95% CI", range = "Range", range_censor = "Range (censored)", range_event = "Range (event)", + median_ci_3d = "Median (95% CI)", + quantiles_lower = "25%-ile (95% CI)", + quantiles_upper = "75%-ile (95% CI)" + ) lbls_custom <- .labels .formats <- c(.formats, fmts[setdiff(names(fmts), names(.formats))]) .labels <- c(.labels, lbls[setdiff(names(lbls), names(lbls_custom))]) @@ -156,7 +195,6 @@ a_surv_time <- function(df, .names = .labels, .labels = .labels, .indent_mods = .indent_mods, - .format_na_strs = na_str, .cell_footnotes = cell_fns ) } @@ -199,7 +237,7 @@ surv_time <- function(lyt, .labels = NULL, .indent_mods = c(median_ci = 1L)) { extra_args <- list( - .stats = .stats, .formats = .formats, .labels = .labels, .indent_mods = .indent_mods, na_str = na_str, + .stats = .stats, .formats = .formats, .labels = .labels, .indent_mods = .indent_mods, is_event = is_event, control = control, ref_fn_censor = ref_fn_censor, ... ) diff --git a/R/survival_timepoint.R b/R/survival_timepoint.R index 0bbb0e2248..9a95784504 100644 --- a/R/survival_timepoint.R +++ b/R/survival_timepoint.R @@ -40,6 +40,7 @@ NULL #' * `event_free_rate`: Event-free rate (%). #' * `rate_se`: Standard error of event free rate. #' * `rate_ci`: Confidence interval for event free rate. +#' * `event_free_rate_3d`: Event-free rate (%) with Confidence interval. #' #' @keywords internal s_surv_timepoint <- function(df, @@ -74,11 +75,15 @@ s_surv_timepoint <- function(df, rate_se <- df_srv_fit$std.err rate_ci <- c(df_srv_fit$lower, df_srv_fit$upper) } + event_free_rate_3d <- c(event_free_rate, rate_ci) list( pt_at_risk = formatters::with_label(pt_at_risk, "Patients remaining at risk"), event_free_rate = formatters::with_label(event_free_rate * 100, "Event Free Rate (%)"), rate_se = formatters::with_label(rate_se * 100, "Standard Error of Event Free Rate"), - rate_ci = formatters::with_label(rate_ci * 100, f_conf_level(conf_level)) + rate_ci = formatters::with_label(rate_ci * 100, f_conf_level(conf_level)), + event_free_rate_3d = formatters::with_label( + event_free_rate_3d * 100, paste0("Event Free Rate (", f_conf_level(conf_level), ")") + ) ) } @@ -111,6 +116,7 @@ a_surv_timepoint <- make_afun( #' * `s_surv_timepoint_diff()` returns the statistics: #' * `rate_diff`: Event-free rate difference between two groups. #' * `rate_diff_ci`: Confidence interval for the difference. +#' * `rate_diff_ci_3d`: Event-free rate difference and confidence interval between two groups. #' * `ztest_pval`: p-value to test the difference is 0. #' #' @keywords internal @@ -126,6 +132,9 @@ s_surv_timepoint_diff <- function(df, list( rate_diff = formatters::with_label("", "Difference in Event Free Rate"), rate_diff_ci = formatters::with_label("", f_conf_level(control$conf_level)), + rate_diff_ci_3d = formatters::with_label( + "", paste0("Difference in Event Free Rate", f_conf_level(control$conf_level)) + ), ztest_pval = formatters::with_label("", "p-value (Z-test)") ) ) @@ -143,6 +152,7 @@ s_surv_timepoint_diff <- function(df, qs <- c(-1, 1) * stats::qnorm(1 - (1 - control$conf_level) / 2) rate_diff_ci <- rate_diff + qs * se_diff + rate_diff_ci_3d <- c(rate_diff, rate_diff_ci) ztest_pval <- if (is.na(rate_diff)) { NA } else { @@ -151,6 +161,9 @@ s_surv_timepoint_diff <- function(df, list( rate_diff = formatters::with_label(rate_diff, "Difference in Event Free Rate"), rate_diff_ci = formatters::with_label(rate_diff_ci, f_conf_level(control$conf_level)), + rate_diff_ci_3d = formatters::with_label( + rate_diff_ci_3d, paste0("Difference in Event Free Rate", f_conf_level(control$conf_level)) + ), ztest_pval = formatters::with_label(ztest_pval, "p-value (Z-test)") ) } @@ -167,6 +180,7 @@ a_surv_timepoint_diff <- make_afun( .formats = c( rate_diff = "xx.xx", rate_diff_ci = "(xx.xx, xx.xx)", + rate_diff_ci_3d = format_xx("xx.xx (xx.xx, xx.xx)"), ztest_pval = "x.xxxx | (<0.0001)" ) ) @@ -260,8 +274,8 @@ surv_timepoint <- function(lyt, extra_args <- list(time_point = time_point, is_event = is_event, control = control, ...) f <- list( - surv = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci"), - surv_diff = c("rate_diff", "rate_diff_ci", "ztest_pval") + surv = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "event_free_rate_3d"), + surv_diff = c("rate_diff", "rate_diff_ci", "ztest_pval", "rate_diff_ci_3d") ) .stats <- h_split_param(.stats, .stats, f = f) .formats <- h_split_param(.formats, names(.formats), f = f) diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index b97acf4a08..64a041b715 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -395,6 +395,20 @@ labels_use_control <- function(labels_default, control, labels_custom = NULL) { labels_default["quantiles"] ) } + if ("quantiles" %in% names(control) && "quantiles_lower" %in% names(labels_default) && + !"quantiles_lower" %in% names(labels_custom)) { # nolint + labels_default["quantiles_lower"] <- gsub( + "[0-9]+%-ile", paste0(control[["quantiles"]][1] * 100, "%-ile", ""), + labels_default["quantiles_lower"] + ) + } + if ("quantiles" %in% names(control) && "quantiles_upper" %in% names(labels_default) && + !"quantiles_upper" %in% names(labels_custom)) { # nolint + labels_default["quantiles_upper"] <- gsub( + "[0-9]+%-ile", paste0(control[["quantiles"]][2] * 100, "%-ile", ""), + labels_default["quantiles_upper"] + ) + } if ("test_mean" %in% names(control) && "mean_pval" %in% names(labels_default) && !"mean_pval" %in% names(labels_custom)) { # nolint labels_default["mean_pval"] <- gsub( @@ -423,7 +437,9 @@ tern_default_stats <- list( analyze_vars_numeric = c( "n", "sum", "mean", "sd", "se", "mean_sd", "mean_se", "mean_ci", "mean_sei", "mean_sdi", "mean_pval", "median", "mad", "median_ci", "quantiles", "iqr", "range", "min", "max", "median_range", "cv", - "geom_mean", "geom_mean_ci", "geom_cv" + "geom_mean", "geom_mean_ci", "geom_cv", + "median_ci_3d", + "mean_ci_3d", "geom_mean_ci_3d" ), count_cumulative = c("count_fraction", "count_fraction_fixed_dp"), count_missed_doses = c("n", "count_fraction", "count_fraction_fixed_dp"), @@ -443,8 +459,14 @@ tern_default_stats <- list( summarize_glm_count = c("n", "rate", "rate_ci", "rate_ratio", "rate_ratio_ci", "pval"), summarize_num_patients = c("unique", "nonunique", "unique_count"), summarize_patients_events_in_cols = c("unique", "all"), - surv_time = c("median", "median_ci", "quantiles", "range_censor", "range_event", "range"), - surv_timepoint = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "rate_diff", "rate_diff_ci", "ztest_pval"), + surv_time = c( + "median", "median_ci", "median_ci_3d", "quantiles", + "quantiles_lower", "quantiles_upper", "range_censor", "range_event", "range" + ), + surv_timepoint = c( + "pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "rate_diff", "rate_diff_ci", "ztest_pval", + "event_free_rate_3d" + ), tabulate_rsp_biomarkers = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), tabulate_rsp_subgroups = c("n", "n_rsp", "prop", "n_tot", "or", "ci", "pval"), tabulate_survival_biomarkers = c("n_tot", "n_tot_events", "median", "hr", "ci", "pval"), @@ -479,10 +501,14 @@ tern_default_formats <- c( mean_sei = "(xx.xx, xx.xx)", mean_sdi = "(xx.xx, xx.xx)", mean_pval = "x.xxxx | (<0.0001)", + mean_ci_3d = "xx.xx (xx.xx - xx.xx)", median = "xx.x", mad = "xx.x", median_ci = "(xx.xx, xx.xx)", + median_ci_3d = "xx.xx (xx.xx - xx.xx)", quantiles = "xx.x - xx.x", + quantiles_lower = "xx.xx (xx.xx - xx.xx)", + quantiles_upper = "xx.xx (xx.xx - xx.xx)", iqr = "xx.x", range = "xx.x - xx.x", min = "xx.x", @@ -491,6 +517,7 @@ tern_default_formats <- c( cv = "xx.x", geom_mean = "xx.x", geom_mean_ci = "(xx.xx, xx.xx)", + geom_mean_ci_3d = "xx.xx (xx.xx - xx.xx)", geom_cv = "xx.x", pval = "x.xxxx | (<0.0001)", pval_counts = "x.xxxx | (<0.0001)", @@ -528,10 +555,14 @@ tern_default_labels <- c( mean_sei = "Mean -/+ 1xSE", mean_sdi = "Mean -/+ 1xSD", mean_pval = "Mean p-value (H0: mean = 0)", + mean_ci_3d = "Mean (95% CI)", median = "Median", mad = "Median Absolute Deviation", median_ci = "Median 95% CI", + median_ci_3d = "Median (95% CI)", quantiles = "25% and 75%-ile", + quantiles_lower = "25%-ile (95% CI)", + quantiles_upper = "75%-ile (95% CI)", iqr = "IQR", range = "Min - Max", min = "Minimum", @@ -540,6 +571,7 @@ tern_default_labels <- c( cv = "CV (%)", geom_mean = "Geometric Mean", geom_mean_ci = "Geometric Mean 95% CI", + geom_mean_ci_3d = "Geometric Mean (95% CI)", geom_cv = "CV % Geometric Mean", pval = "p-value (t-test)", # Default for numeric pval_counts = "p-value (chi-squared test)", # Default for counts diff --git a/man/analyze_variables.Rd b/man/analyze_variables.Rd index 18a6b603dc..ba567bd1ae 100644 --- a/man/analyze_variables.Rd +++ b/man/analyze_variables.Rd @@ -115,7 +115,7 @@ defined by this split instruction, or \code{NA_character_} (the default) for no \item{.stats}{(\code{character})\cr statistics to select for the table. -Options for numeric variables are: \verb{'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv'} +Options for numeric variables are: \verb{'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv', 'median_ci_3d', 'mean_ci_3d', 'geom_mean_ci_3d'} Options for non-numeric variables are: \verb{'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'fraction', 'n_blq'}} diff --git a/man/compare_variables.Rd b/man/compare_variables.Rd index 5f9d0cd1f7..b5b611ffd9 100644 --- a/man/compare_variables.Rd +++ b/man/compare_variables.Rd @@ -73,7 +73,7 @@ defined by this split instruction, or \code{NA_character_} (the default) for no \item{.stats}{(\code{character})\cr statistics to select for the table. -Options for numeric variables are: \verb{'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv', 'pval'} +Options for numeric variables are: \verb{'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv', 'median_ci_3d', 'mean_ci_3d', 'geom_mean_ci_3d', 'pval'} Options for non-numeric variables are: \verb{'n', 'count', 'count_fraction', 'count_fraction_fixed_dp', 'fraction', 'n_blq', 'pval_counts'}} diff --git a/man/summarize_change.Rd b/man/summarize_change.Rd index b37cdd761c..f324348b6a 100644 --- a/man/summarize_change.Rd +++ b/man/summarize_change.Rd @@ -65,7 +65,7 @@ defined by this split instruction, or \code{NA_character_} (the default) for no \item{.stats}{(\code{character})\cr statistics to select for the table. -Options are: \verb{'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv'}} +Options are: \verb{'n', 'sum', 'mean', 'sd', 'se', 'mean_sd', 'mean_se', 'mean_ci', 'mean_sei', 'mean_sdi', 'mean_pval', 'median', 'mad', 'median_ci', 'quantiles', 'iqr', 'range', 'min', 'max', 'median_range', 'cv', 'geom_mean', 'geom_mean_ci', 'geom_cv', 'median_ci_3d', 'mean_ci_3d', 'geom_mean_ci_3d'}} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/survival_time.Rd b/man/survival_time.Rd index 4a150208da..3961d4e1e3 100644 --- a/man/survival_time.Rd +++ b/man/survival_time.Rd @@ -78,7 +78,7 @@ times, to avoid warnings from \code{rtables}.} \item{.stats}{(\code{character})\cr statistics to select for the table. -Options are: \verb{'median', 'median_ci', 'quantiles', 'range_censor', 'range_event', 'range'}} +Options are: \verb{'median', 'median_ci', 'median_ci_3d', 'quantiles', 'quantiles_lower', 'quantiles_upper', 'range_censor', 'range_event', 'range'}} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} @@ -112,7 +112,10 @@ the statistics from \code{s_surv_time()} to the table layout. \itemize{ \item \code{median}: Median survival time. \item \code{median_ci}: Confidence interval for median time. +\item \code{median_ci_3d}: Median with confidence interval for median time. \item \code{quantiles}: Survival time for two specified quantiles. +\item \code{quantiles_lower}: quantile with confidence interval for the first specified quantile. +\item \code{quantiles_upper}: quantile with confidence interval for the second specified quantile. \item \code{range_censor}: Survival time range for censored observations. \item \code{range_event}: Survival time range for observations with events. \item \code{range}: Survival time range for all observations. diff --git a/man/survival_timepoint.Rd b/man/survival_timepoint.Rd index 2420718a1b..f3d96c5d2b 100644 --- a/man/survival_timepoint.Rd +++ b/man/survival_timepoint.Rd @@ -107,7 +107,7 @@ avoid warnings from duplicate table names.} \item{.stats}{(\code{character})\cr statistics to select for the table. -Options are: \verb{'pt_at_risk', 'event_free_rate', 'rate_se', 'rate_ci', 'rate_diff', 'rate_diff_ci', 'ztest_pval'}} +Options are: \verb{'pt_at_risk', 'event_free_rate', 'rate_se', 'rate_ci', 'rate_diff', 'rate_diff_ci', 'ztest_pval', 'event_free_rate_3d'}} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} @@ -142,6 +142,7 @@ the value of \code{method}. \item \code{event_free_rate}: Event-free rate (\%). \item \code{rate_se}: Standard error of event free rate. \item \code{rate_ci}: Confidence interval for event free rate. +\item \code{event_free_rate_3d}: Event-free rate (\%) with Confidence interval. } } @@ -154,6 +155,7 @@ the value of \code{method}. \itemize{ \item \code{rate_diff}: Event-free rate difference between two groups. \item \code{rate_diff_ci}: Confidence interval for the difference. +\item \code{rate_diff_ci_3d}: Event-free rate difference and confidence interval between two groups. \item \code{ztest_pval}: p-value to test the difference is 0. } } diff --git a/tests/testthat/_snaps/analyze_variables.md b/tests/testthat/_snaps/analyze_variables.md index f367f7e1ad..021a9756f7 100644 --- a/tests/testthat/_snaps/analyze_variables.md +++ b/tests/testthat/_snaps/analyze_variables.md @@ -49,6 +49,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $mean_ci_3d + mean mean_ci_lwr mean_ci_upr + NA NA NA + attr(,"label") + [1] "Mean (95% CI)" + $mean_pval p_value NA @@ -71,6 +77,12 @@ attr(,"label") [1] "Median 95% CI" + $median_ci_3d + median median_ci_lwr median_ci_upr + NA NA NA + attr(,"label") + [1] "Median (95% CI)" + $quantiles quantile_0.25 quantile_0.75 NA NA @@ -117,6 +129,12 @@ geom_cv NA + $geom_mean_ci_3d + geom_mean mean_ci_lwr mean_ci_upr + NaN NA NA + attr(,"label") + [1] "Geometric Mean (95% CI)" + # s_summary handles NA @@ -169,6 +187,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $mean_ci_3d + mean mean_ci_lwr mean_ci_upr + 1 NA NA + attr(,"label") + [1] "Mean (95% CI)" + $mean_pval p_value NA @@ -191,6 +215,12 @@ attr(,"label") [1] "Median 95% CI" + $median_ci_3d + median median_ci_lwr median_ci_upr + 1 NA NA + attr(,"label") + [1] "Median (95% CI)" + $quantiles quantile_0.25 quantile_0.75 1 1 @@ -237,6 +267,12 @@ geom_cv NA + $geom_mean_ci_3d + geom_mean mean_ci_lwr mean_ci_upr + 1 NA NA + attr(,"label") + [1] "Geometric Mean (95% CI)" + --- @@ -289,6 +325,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $mean_ci_3d + mean mean_ci_lwr mean_ci_upr + NA NA NA + attr(,"label") + [1] "Mean (95% CI)" + $mean_pval p_value NA @@ -311,6 +353,12 @@ attr(,"label") [1] "Median 95% CI" + $median_ci_3d + median median_ci_lwr median_ci_upr + NA NA NA + attr(,"label") + [1] "Median (95% CI)" + $quantiles quantile_0.25 quantile_0.75 NA NA @@ -357,6 +405,12 @@ geom_cv NA + $geom_mean_ci_3d + geom_mean mean_ci_lwr mean_ci_upr + NA NA NA + attr(,"label") + [1] "Geometric Mean (95% CI)" + # s_summary returns right results for n = 2 @@ -409,6 +463,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $mean_ci_3d + mean mean_ci_lwr mean_ci_upr + 1.500000 -4.853102 7.853102 + attr(,"label") + [1] "Mean (95% CI)" + $mean_pval p_value 0.2048328 @@ -431,6 +491,12 @@ attr(,"label") [1] "Median 95% CI" + $median_ci_3d + median median_ci_lwr median_ci_upr + 1.5 NA NA + attr(,"label") + [1] "Median (95% CI)" + $quantiles quantile_0.25 quantile_0.75 1 2 @@ -477,6 +543,12 @@ geom_cv 52.10922 + $geom_mean_ci_3d + geom_mean mean_ci_lwr mean_ci_upr + 1.41421356 0.01729978 115.60839614 + attr(,"label") + [1] "Geometric Mean (95% CI)" + # s_summary returns right results for n = 8 @@ -529,6 +601,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $mean_ci_3d + mean mean_ci_lwr mean_ci_upr + 6.000000 3.318768 8.681232 + attr(,"label") + [1] "Mean (95% CI)" + $mean_pval p_value 0.001133783 @@ -551,6 +629,12 @@ attr(,"label") [1] "Median 95% CI" + $median_ci_3d + median median_ci_lwr median_ci_upr + 6.5 1.0 10.0 + attr(,"label") + [1] "Median (95% CI)" + $quantiles quantile_0.25 quantile_0.75 3.5 8.5 @@ -597,6 +681,12 @@ geom_cv 96.61307 + $geom_mean_ci_3d + geom_mean mean_ci_lwr mean_ci_upr + 4.842534 2.456211 9.547283 + attr(,"label") + [1] "Geometric Mean (95% CI)" + # s_summary works with factors @@ -1033,31 +1123,34 @@ Output RowsVerticalSection (in_rows) object print method: ---------------------------- - row_name formatted_cell indent_mod row_label - 1 n 10 0 n - 2 sum 1.3 0 Sum - 3 mean 0.1 0 Mean - 4 sd 0.8 0 SD - 5 se 0.2 0 SE - 6 mean_sd 0.1 (0.8) 0 Mean (SD) - 7 mean_se 0.1 (0.2) 0 Mean (SE) - 8 mean_ci (-0.43, 0.69) 0 Mean 95% CI - 9 mean_sei (-0.11, 0.38) 0 Mean -/+ 1xSE - 10 mean_sdi (-0.65, 0.91) 0 Mean -/+ 1xSD - 11 mean_pval 0.6052 0 Mean p-value (H0: mean = 0) - 12 median 0.3 0 Median - 13 mad -0.0 0 Median Absolute Deviation - 14 median_ci (-0.82, 0.74) 0 Median 95% CI - 15 quantiles -0.6 - 0.6 0 25% and 75%-ile - 16 iqr 1.2 0 IQR - 17 range -0.8 - 1.6 0 Min - Max - 18 min -0.8 0 Minimum - 19 max 1.6 0 Maximum - 20 median_range 0.3 (-0.8 - 1.6) 0 Median (Min - Max) - 21 cv 590.4 0 CV (%) - 22 geom_mean NA 0 Geometric Mean - 23 geom_mean_ci NA 0 Geometric Mean 95% CI - 24 geom_cv NA 0 CV % Geometric Mean + row_name formatted_cell indent_mod row_label + 1 n 10 0 n + 2 sum 1.3 0 Sum + 3 mean 0.1 0 Mean + 4 sd 0.8 0 SD + 5 se 0.2 0 SE + 6 mean_sd 0.1 (0.8) 0 Mean (SD) + 7 mean_se 0.1 (0.2) 0 Mean (SE) + 8 mean_ci (-0.43, 0.69) 0 Mean 95% CI + 9 mean_sei (-0.11, 0.38) 0 Mean -/+ 1xSE + 10 mean_sdi (-0.65, 0.91) 0 Mean -/+ 1xSD + 11 mean_pval 0.6052 0 Mean p-value (H0: mean = 0) + 12 median 0.3 0 Median + 13 mad -0.0 0 Median Absolute Deviation + 14 median_ci (-0.82, 0.74) 0 Median 95% CI + 15 quantiles -0.6 - 0.6 0 25% and 75%-ile + 16 iqr 1.2 0 IQR + 17 range -0.8 - 1.6 0 Min - Max + 18 min -0.8 0 Minimum + 19 max 1.6 0 Maximum + 20 median_range 0.3 (-0.8 - 1.6) 0 Median (Min - Max) + 21 cv 590.4 0 CV (%) + 22 geom_mean NA 0 Geometric Mean + 23 geom_mean_ci NA 0 Geometric Mean 95% CI + 24 geom_cv NA 0 CV % Geometric Mean + 25 median_ci_3d 0.26 (-0.82 - 0.74) 0 Median (95% CI) + 26 mean_ci_3d 0.13 (-0.43 - 0.69) 0 Mean (95% CI) + 27 geom_mean_ci_3d NA 0 Geometric Mean (95% CI) --- @@ -1165,32 +1258,35 @@ Output RowsVerticalSection (in_rows) object print method: ---------------------------- - row_name formatted_cell indent_mod row_label - 1 n 10 0 n - 2 sum 51.3 0 Sum - 3 mean 5.1 0 Mean - 4 sd 0.8 0 SD - 5 se 0.2 0 SE - 6 mean_sd 5.1 (0.8) 0 Mean (SD) - 7 mean_se 5.1 (0.2) 0 Mean (SE) - 8 mean_ci (4.57, 5.69) 0 Mean 95% CI - 9 mean_sei (4.89, 5.38) 0 Mean -/+ 1xSE - 10 mean_sdi (4.35, 5.91) 0 Mean -/+ 1xSD - 11 mean_pval <0.0001 0 Mean p-value (H0: mean = 0) - 12 median 5.3 0 Median - 13 mad -0.0 0 Median Absolute Deviation - 14 median_ci (4.18, 5.74) 0 Median 95% CI - 15 quantiles 4.4 - 5.6 0 25% and 75%-ile - 16 iqr 1.2 0 IQR - 17 range 4.2 - 6.6 0 Min - Max - 18 min 4.2 0 Minimum - 19 max 6.6 0 Maximum - 20 median_range 5.3 (4.2 - 6.6) 0 Median (Min - Max) - 21 cv 15.2 0 CV (%) - 22 geom_mean 5.1 0 Geometric Mean - 23 geom_mean_ci (4.56, 5.66) 0 Geometric Mean 95% CI - 24 geom_cv 15.2 0 CV % Geometric Mean - 25 pval <0.0001 0 p-value (t-test) + row_name formatted_cell indent_mod row_label + 1 n 10 0 n + 2 sum 51.3 0 Sum + 3 mean 5.1 0 Mean + 4 sd 0.8 0 SD + 5 se 0.2 0 SE + 6 mean_sd 5.1 (0.8) 0 Mean (SD) + 7 mean_se 5.1 (0.2) 0 Mean (SE) + 8 mean_ci (4.57, 5.69) 0 Mean 95% CI + 9 mean_sei (4.89, 5.38) 0 Mean -/+ 1xSE + 10 mean_sdi (4.35, 5.91) 0 Mean -/+ 1xSD + 11 mean_pval <0.0001 0 Mean p-value (H0: mean = 0) + 12 median 5.3 0 Median + 13 mad -0.0 0 Median Absolute Deviation + 14 median_ci (4.18, 5.74) 0 Median 95% CI + 15 quantiles 4.4 - 5.6 0 25% and 75%-ile + 16 iqr 1.2 0 IQR + 17 range 4.2 - 6.6 0 Min - Max + 18 min 4.2 0 Minimum + 19 max 6.6 0 Maximum + 20 median_range 5.3 (4.2 - 6.6) 0 Median (Min - Max) + 21 cv 15.2 0 CV (%) + 22 geom_mean 5.1 0 Geometric Mean + 23 geom_mean_ci (4.56, 5.66) 0 Geometric Mean 95% CI + 24 geom_cv 15.2 0 CV % Geometric Mean + 25 median_ci_3d 5.26 (4.18 - 5.74) 0 Median (95% CI) + 26 mean_ci_3d 5.13 (4.57 - 5.69) 0 Mean (95% CI) + 27 geom_mean_ci_3d 5.08 (4.56 - 5.66) 0 Geometric Mean (95% CI) + 28 pval <0.0001 0 p-value (t-test) --- diff --git a/tests/testthat/_snaps/compare_variables.md b/tests/testthat/_snaps/compare_variables.md index 493db5697c..6c98b121bb 100644 --- a/tests/testthat/_snaps/compare_variables.md +++ b/tests/testthat/_snaps/compare_variables.md @@ -3,11 +3,13 @@ Code res Output - [1] "n" "sum" "mean" "sd" "se" - [6] "mean_sd" "mean_se" "mean_ci" "mean_sei" "mean_sdi" - [11] "mean_pval" "median" "mad" "median_ci" "quantiles" - [16] "iqr" "range" "min" "max" "median_range" - [21] "cv" "geom_mean" "geom_mean_ci" "geom_cv" "pval" + [1] "n" "sum" "mean" "sd" + [5] "se" "mean_sd" "mean_se" "mean_ci" + [9] "mean_sei" "mean_sdi" "mean_ci_3d" "mean_pval" + [13] "median" "mad" "median_ci" "median_ci_3d" + [17] "quantiles" "iqr" "range" "min" + [21] "max" "median_range" "cv" "geom_mean" + [25] "geom_mean_ci" "geom_cv" "geom_mean_ci_3d" "pval" # s_compare for numeric does not give p-value when not at least 2 values in each group diff --git a/tests/testthat/_snaps/summarize_change.md b/tests/testthat/_snaps/summarize_change.md index 9752712464..520ff1d99d 100644 --- a/tests/testthat/_snaps/summarize_change.md +++ b/tests/testthat/_snaps/summarize_change.md @@ -49,6 +49,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $mean_ci_3d + mean mean_ci_lwr mean_ci_upr + NA NA NA + attr(,"label") + [1] "Mean (95% CI)" + $mean_pval p_value NA @@ -71,6 +77,12 @@ attr(,"label") [1] "Median 95% CI" + $median_ci_3d + median median_ci_lwr median_ci_upr + NA NA NA + attr(,"label") + [1] "Median (95% CI)" + $quantiles quantile_0.25 quantile_0.75 NA NA @@ -117,6 +129,12 @@ geom_cv NA + $geom_mean_ci_3d + geom_mean mean_ci_lwr mean_ci_upr + NaN NA NA + attr(,"label") + [1] "Geometric Mean (95% CI)" + # s_change_from_baseline handles NA in baseline values @@ -169,6 +187,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $mean_ci_3d + mean mean_ci_lwr mean_ci_upr + 3.000000 -4.452413 10.452413 + attr(,"label") + [1] "Mean (95% CI)" + $mean_pval p_value 0.2254033 @@ -191,6 +215,12 @@ attr(,"label") [1] "Median 95% CI" + $median_ci_3d + median median_ci_lwr median_ci_upr + 3 NA NA + attr(,"label") + [1] "Median (95% CI)" + $quantiles quantile_0.25 quantile_0.75 0 6 @@ -237,6 +267,12 @@ geom_cv NA + $geom_mean_ci_3d + geom_mean mean_ci_lwr mean_ci_upr + NA NA NA + attr(,"label") + [1] "Geometric Mean (95% CI)" + # s_change_from_baseline handles baseline substitution @@ -290,6 +326,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $`FALSE`$mean_ci_3d + mean mean_ci_lwr mean_ci_upr + 1.500000 -4.853102 7.853102 + attr(,"label") + [1] "Mean (95% CI)" + $`FALSE`$mean_pval p_value 0.2048328 @@ -312,6 +354,12 @@ attr(,"label") [1] "Median 95% CI" + $`FALSE`$median_ci_3d + median median_ci_lwr median_ci_upr + 1.5 NA NA + attr(,"label") + [1] "Median (95% CI)" + $`FALSE`$quantiles quantile_0.25 quantile_0.75 1 2 @@ -358,6 +406,12 @@ geom_cv 52.10922 + $`FALSE`$geom_mean_ci_3d + geom_mean mean_ci_lwr mean_ci_upr + 1.41421356 0.01729978 115.60839614 + attr(,"label") + [1] "Geometric Mean (95% CI)" + $`TRUE` $`TRUE`$n @@ -406,6 +460,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $`TRUE`$mean_ci_3d + mean mean_ci_lwr mean_ci_upr + 2.50000 -16.55931 21.55931 + attr(,"label") + [1] "Mean (95% CI)" + $`TRUE`$mean_pval p_value 0.3440417 @@ -428,6 +488,12 @@ attr(,"label") [1] "Median 95% CI" + $`TRUE`$median_ci_3d + median median_ci_lwr median_ci_upr + 2.5 NA NA + attr(,"label") + [1] "Median (95% CI)" + $`TRUE`$quantiles quantile_0.25 quantile_0.75 1 4 @@ -474,6 +540,12 @@ geom_cv 127.0458 + $`TRUE`$geom_mean_ci_3d + geom_mean mean_ci_lwr mean_ci_upr + 2.000000e+00 2.992824e-04 1.336530e+04 + attr(,"label") + [1] "Geometric Mean (95% CI)" + # summarize_change works as expected diff --git a/tests/testthat/_snaps/survival_coxph_pairwise.md b/tests/testthat/_snaps/survival_coxph_pairwise.md index 282ac2e850..a309f01b0a 100644 --- a/tests/testthat/_snaps/survival_coxph_pairwise.md +++ b/tests/testthat/_snaps/survival_coxph_pairwise.md @@ -18,6 +18,11 @@ attr(,"label") [1] "95% CI" + $hr_ci_3d + [1] 0.7108557 0.4779138 1.0573368 + attr(,"label") + [1] "Hazard Ratio (95% CI)" + $n_tot [1] 142 attr(,"label") @@ -49,6 +54,11 @@ attr(,"label") [1] "90% CI" + $hr_ci_3d + [1] 0.7108557 0.5094153 0.9919525 + attr(,"label") + [1] "Hazard Ratio (90% CI)" + $n_tot [1] 142 attr(,"label") @@ -80,6 +90,11 @@ attr(,"label") [1] "95% CI" + $hr_ci_3d + [1] 0.6251817 0.4014842 0.9735181 + attr(,"label") + [1] "Hazard Ratio (95% CI)" + $n_tot [1] 142 attr(,"label") @@ -111,6 +126,11 @@ attr(,"label") [1] "90% CI" + $hr_ci_3d + [1] 0.6251817 0.4311132 0.9066115 + attr(,"label") + [1] "Hazard Ratio (90% CI)" + $n_tot [1] 142 attr(,"label") diff --git a/tests/testthat/_snaps/survival_time.md b/tests/testthat/_snaps/survival_time.md index b3779dd04d..10d0453dce 100644 --- a/tests/testthat/_snaps/survival_time.md +++ b/tests/testthat/_snaps/survival_time.md @@ -33,6 +33,21 @@ attr(,"label") [1] "Range" + $median_ci_3d + [1] 23.91143 18.25878 32.85945 + attr(,"label") + [1] "Median (95% CI)" + + $quantiles_lower + [1] 9.822926 5.628823 16.690121 + attr(,"label") + [1] "25%-ile (95% CI)" + + $quantiles_upper + [1] 41.98181 32.85945 53.41445 + attr(,"label") + [1] "75%-ile (95% CI)" + # s_surv_time works with customized arguments @@ -69,6 +84,21 @@ attr(,"label") [1] "Range" + $median_ci_3d + [1] 23.91143 13.59124 37.97055 + attr(,"label") + [1] "Median (99% CI)" + + $quantiles_lower + [1] 6.649204 1.887860 12.771697 + attr(,"label") + [1] "20%-ile (99% CI)" + + $quantiles_upper + [1] 51.09487 37.97055 NA + attr(,"label") + [1] "80%-ile (99% CI)" + # a_surv_time works with default arguments @@ -77,13 +107,16 @@ Output RowsVerticalSection (in_rows) object print method: ---------------------------- - row_name formatted_cell indent_mod row_label - 1 Median 24.8 0 Median - 2 95% CI (21.1, 31.3) 0 95% CI - 3 25% and 75%-ile 10.8, 47.6 0 25% and 75%-ile - 4 Range (censored) 0.8 to 78.9 0 Range (censored) - 5 Range (event) 0.1 to 155.5 0 Range (event) - 6 Range 0.1 to 155.5 0 Range + row_name formatted_cell indent_mod row_label + 1 Median 24.8 0 Median + 2 95% CI (21.1, 31.3) 0 95% CI + 3 Median (95% CI) 24.8 (21.1 - 31.3) 0 Median (95% CI) + 4 25% and 75%-ile 10.8, 47.6 0 25% and 75%-ile + 5 25%-ile (95% CI) 10.8 (6.6 - 13.4) 0 25%-ile (95% CI) + 6 75%-ile (95% CI) 47.6 (39.3 - 57.8) 0 75%-ile (95% CI) + 7 Range (censored) 0.8 to 78.9 0 Range (censored) + 8 Range (event) 0.1 to 155.5 0 Range (event) + 9 Range 0.1 to 155.5 0 Range # a_surv_time works with customized arguments @@ -115,15 +148,18 @@ Code res Output - ARM A ARM B ARM C - ——————————————————————————————————————————————————————————————————— - Survival Time (Months) - Median 32.0 23.9 20.8 - 90% CI (25.6, 49.3) (18.9, 32.1) (13.0, 26.0) - 40% and 60%-ile 25.6, 46.5 18.3, 29.2 13.0, 25.7 - Range (censored) 0.8 to 63.5 6.2 to 78.9 3.4 to 52.4 - Range (event) 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7 - Range 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7 + ARM A ARM B ARM C + ————————————————————————————————————————————————————————————————————————————————————— + Survival Time (Months) + Median 32.0 23.9 20.8 + 90% CI (25.6, 49.3) (18.9, 32.1) (13.0, 26.0) + Median (90% CI) 32.0 (25.6 - 49.3) 23.9 (18.9 - 32.1) 20.8 (13.0 - 26.0) + 40% and 60%-ile 25.6, 46.5 18.3, 29.2 13.0, 25.7 + 40%-ile (90% CI) 25.6 (20.7 - 33.4) 18.3 (12.8 - 23.9) 13.0 (10.1 - 24.8) + 60%-ile (90% CI) 46.5 (32.0 - 57.8) 29.2 (23.9 - 41.3) 25.7 (20.8 - 37.1) + Range (censored) 0.8 to 63.5 6.2 to 78.9 3.4 to 52.4 + Range (event) 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7 + Range 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7 # surv_time works with referential footnotes diff --git a/tests/testthat/_snaps/survival_timepoint.md b/tests/testthat/_snaps/survival_timepoint.md index 8c2a7691af..18e7f1f433 100644 --- a/tests/testthat/_snaps/survival_timepoint.md +++ b/tests/testthat/_snaps/survival_timepoint.md @@ -23,6 +23,11 @@ attr(,"label") [1] "95% CI" + $event_free_rate_3d + [1] 82.19178 73.41549 90.96807 + attr(,"label") + [1] "Event Free Rate (95% CI)" + # s_surv_timepoint works with customized arguments @@ -49,6 +54,11 @@ attr(,"label") [1] "99% CI" + $event_free_rate_3d + [1] 75.49797 62.15793 91.70097 + attr(,"label") + [1] "Event Free Rate (99% CI)" + # s_surv_timepoint also works when there are 0 patients at risk @@ -75,6 +85,11 @@ attr(,"label") [1] "95% CI" + $event_free_rate_3d + [1] NA NA NA + attr(,"label") + [1] "Event Free Rate (95% CI)" + # surv_timepoint works with default arguments @@ -115,6 +130,11 @@ attr(,"label") [1] "95% CI" + $rate_diff_ci_3d + [1] 4.269100 -7.767371 16.305570 + attr(,"label") + [1] "Difference in Event Free Rate95% CI" + $ztest_pval [1] 0.4869546 attr(,"label") @@ -136,6 +156,11 @@ attr(,"label") [1] "90% CI" + $rate_diff_ci_3d + [1] 9.640872 -1.404177 20.685921 + attr(,"label") + [1] "Difference in Event Free Rate90% CI" + $ztest_pval [1] 0.1510762 attr(,"label") diff --git a/tests/testthat/_snaps/utils_default_stats_formats_labels.md b/tests/testthat/_snaps/utils_default_stats_formats_labels.md index 774a14a31d..aa5850acc1 100644 --- a/tests/testthat/_snaps/utils_default_stats_formats_labels.md +++ b/tests/testthat/_snaps/utils_default_stats_formats_labels.md @@ -27,11 +27,13 @@ Code res Output - [1] "n" "sum" "mean" "sd" "se" - [6] "mean_sd" "mean_se" "mean_ci" "mean_sei" "mean_sdi" - [11] "mean_pval" "median" "mad" "median_ci" "quantiles" - [16] "iqr" "range" "min" "max" "median_range" - [21] "cv" "geom_mean" "geom_mean_ci" "geom_cv" + [1] "n" "sum" "mean" "sd" + [5] "se" "mean_sd" "mean_se" "mean_ci" + [9] "mean_sei" "mean_sdi" "mean_pval" "median" + [13] "mad" "median_ci" "quantiles" "iqr" + [17] "range" "min" "max" "median_range" + [21] "cv" "geom_mean" "geom_mean_ci" "geom_cv" + [25] "median_ci_3d" "mean_ci_3d" "geom_mean_ci_3d" # get_labels_from_stats works as expected @@ -82,22 +84,24 @@ Code res Output - n sum mean - "xx." "xx.x" "xx.x" - sd se mean_sd - "xx.x" "xx.x" "xx.x (xx.x)" - mean_se mean_ci mean_sei - "xx.x (xx.x)" "(xx.xx, xx.xx)" "(xx.xx, xx.xx)" - mean_sdi mean_pval median - "(xx.xx, xx.xx)" "x.xxxx | (<0.0001)" "xx.x" - mad median_ci quantiles - "xx.x" "(xx.xx, xx.xx)" "xx.x - xx.x" - iqr range min - "xx.x" "xx.x - xx.x" "xx.x" - max median_range cv - "xx.x" "xx.x (xx.x - xx.x)" "xx.x" - geom_mean geom_mean_ci geom_cv - "xx.x" "(xx.xx, xx.xx)" "xx.x" + n sum mean + "xx." "xx.x" "xx.x" + sd se mean_sd + "xx.x" "xx.x" "xx.x (xx.x)" + mean_se mean_ci mean_sei + "xx.x (xx.x)" "(xx.xx, xx.xx)" "(xx.xx, xx.xx)" + mean_sdi mean_pval median + "(xx.xx, xx.xx)" "x.xxxx | (<0.0001)" "xx.x" + mad median_ci quantiles + "xx.x" "(xx.xx, xx.xx)" "xx.x - xx.x" + iqr range min + "xx.x" "xx.x - xx.x" "xx.x" + max median_range cv + "xx.x" "xx.x (xx.x - xx.x)" "xx.x" + geom_mean geom_mean_ci geom_cv + "xx.x" "(xx.xx, xx.xx)" "xx.x" + median_ci_3d mean_ci_3d geom_mean_ci_3d + "xx.xx (xx.xx - xx.xx)" "xx.xx (xx.xx - xx.xx)" "xx.xx (xx.xx - xx.xx)" # summary_labels works as expected @@ -128,6 +132,10 @@ "CV (%)" "Geometric Mean" geom_mean_ci geom_cv "Geometric Mean 95% CI" "CV % Geometric Mean" + median_ci_3d mean_ci_3d + "Median (95% CI)" "Mean (95% CI)" + geom_mean_ci_3d + "Geometric Mean (95% CI)" --- diff --git a/tests/testthat/test-utils_rtables.R b/tests/testthat/test-utils_rtables.R index 3e482c9a39..fbeb9e337c 100644 --- a/tests/testthat/test-utils_rtables.R +++ b/tests/testthat/test-utils_rtables.R @@ -291,4 +291,5 @@ testthat::test_that("default na_str works properly", { analyze_vars(vars = "VAR", .stats = c("n", "mean")) %>% build_table(dt) testthat::expect_identical(matrix_form(tbl)$strings[-1, 2], c("0", "")) + set_default_na_str(NULL) }) From 7f8a165066bb8c63b440a8eda7bd02d1615f5652 Mon Sep 17 00:00:00 2001 From: Melkiades Date: Wed, 20 Nov 2024 08:34:51 +0000 Subject: [PATCH 2/2] [skip actions] Bump version to 0.9.6.9016 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8d8b2bbe06..d12a525cd6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: tern Title: Create Common TLGs Used in Clinical Trials -Version: 0.9.6.9015 -Date: 2024-11-07 +Version: 0.9.6.9016 +Date: 2024-11-20 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Daniel", "Sabanés Bové", , "daniel.sabanes_bove@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index ead9eb614e..1fb0cc7b09 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# tern 0.9.6.9015 +# tern 0.9.6.9016 ### Enhancements * Added the `denom` parameter to `s_count_cumulative()`, `s_count_missed_doses()`, and `s_count_occurrences_by_grade()`.