Skip to contents

The numerical examples in this guide execute when the article is rendered. Use them to check the arithmetic and interpret selected results. For the same workflows in jamovi, open the teaching workbooks. Saved jamovi examples

Choose the quantity before choosing the analysis

Question Quantity and analysis Interpretation
How long until death from any cause? Overall-survival Kaplan-Meier; Single Arm or Survival Analysis Survival probability at a stated time
How often does one terminal cause occur with other terminal causes present? Cumulative incidence in competing-risk mode Probability of the specified cause by a stated time
Which baseline covariates are associated with hazard? Multivariable Cox Conditional hazard ratios, under proportional hazards
Which covariates are associated with cumulative incidence? Multivariable Fine-Gray Subdistribution hazard ratios
How many events per observation time? Person-time table Crude events per person-time; no covariate adjustment
Which candidate predictors survive an L1 penalty? LASSO Cox Exploratory penalized coefficients and apparent performance
Which factors are associated with a binary endpoint? Odds Ratio Odds ratios; requires a defined outcome window and sampling design

Use the Aalen–Johansen cumulative incidence estimate for the probability that a given event occurs by a specified time in the presence of competing events. Censoring competing events in Kaplan–Meier instead answers a net survival question. The Fine–Gray model relates covariates to cumulative incidence through the subdistribution hazard, so report its hazard ratios on that scale. Competing-risk guide Fine and Gray

DateTime Converter’s native parsing-count percentages use all observations. For four rows containing two valid dates, one missing value and one unparseable string, the parsed share is 50%, missing is 25%, and failed is 25%. The separate parse rate among non-missing values is 2/3 (66.7%). A high parse rate cannot verify the date order.

Check the risk sets and rate denominator

Six independent patients have the following times. At time 2, an event and a censoring occur together; both patients belong to the risk set just before that time. The survival probabilities are (5/6), (5/6)*(4/5) and (5/6)*(4/5)*(1/2) at times 1, 2 and 4.

cohort <- data.frame(
  time = c(1, 2, 2, 3, 4, 5),
  event = c(1, 1, 0, 0, 1, 0)
)
result <- jsurvival::singlearm(
  data = cohort, elapsedtime = "time", outcome = "event", outcomeLevel = "1",
  dod = NULL, dooc = NULL, awd = NULL, awod = NULL,
  timetypeoutput = "months", cutp = "1, 2, 4", person_time = TRUE
)
km <- result$survTable$asDF
stopifnot(isTRUE(all.equal(km$surv, c(5/6, 2/3, 1/3))))
km
#>   time n.risk n.event      surv      lower     upper
#> 1    1      6       1 0.8333333 0.27312285 0.9747124
#> 2    2      5       1 0.6666667 0.19461664 0.9044342
#> 3    4      2       1 0.3333333 0.01368488 0.7548440

Total follow-up is 17 person-months and there are three events. The crude rate is 100 * 3/17, or about 17.65 per 100 person-months. This is not a percentage risk. Exact Poisson limits concern the count/rate model and do not remove informative censoring or population differences. A zero-event interval can have a positive upper confidence limit.

rate <- result$personTimeTable$asDF
expected_ci <- c(stats::qchisq(.025, 2 * 3),
                 stats::qchisq(.975, 2 * (3 + 1))) / (2 * 17) * 100
stopifnot(
  rate$events[1] == 3,
  rate$person_time[1] == 17,
  isTRUE(all.equal(rate$rate[1], 100 * 3/17)),
  isTRUE(all.equal(c(rate$rate_ci_lower[1], rate$rate_ci_upper[1]), expected_ci))
)
rate
#>          interval events person_time     rate rate_ci_lower rate_ci_upper
#> 1 Overall (0-max)      3          17 17.64706      3.639248      51.57219

The Kaplan–Meier median is the time where the estimate crosses 50%. When it stays at exactly 50% before dropping below, the midpoint of that plateau is reported. If the curve reaches 50% and stays there through the end of follow-up, the table reports when it first reached 50%. If estimated survival stays above 50%, the median is unreached. Censored observations contribute to the risk sets. The mean observed time ends at the event or censoring and can therefore be shortened by early events. Kaplan–Meier quantiles

plateau <- data.frame(time = c(2, 4, 5, 8), event = rep(1L, 4))
fit <- survival::survfit(survival::Surv(time, event) ~ 1, data = plateau)
stopifnot(isTRUE(all.equal(unname(summary(fit)$table["median"]), 4.5)))

terminal_plateau <- transform(plateau, event = c(1L, 1L, 0L, 0L))
fit <- survival::survfit(survival::Surv(time, event) ~ 1, data = terminal_plateau)
stopifnot(isTRUE(all.equal(unname(summary(fit)$table["median"]), 4)))

Report the multiplier and time unit, the eligible cohort and censoring rules. Different follow-up patterns and case mixes can change crude rate comparisons even when the rate denominators are arithmetically correct. Median follow-up uses reverse Kaplan-Meier; it is distinct from median survival and median observed time.

Compare restricted mean survival at a common horizon

Through time 4, the area under the earlier Kaplan–Meier curve is 1 × 1 + 1 × (5/6) + 2 × (2/3) = 19/6 time units. In a group comparison, choose the same horizon for all groups and check that each has adequate follow-up through that time. The RMST difference describes additional mean event-free time through the stated horizon.

When a Continuous Survival group’s Kaplan–Meier curve has no observed event before the horizon, its restricted mean equals the horizon. The group table leaves the standard error and confidence interval blank. The difference’s confidence interval also requires estimable uncertainty in both groups.

fit <- survival::survfit(survival::Surv(time, event) ~ 1, data = cohort)
rmst <- unname(summary(fit, rmean = 4)$table["rmean"])
stopifnot(isTRUE(all.equal(rmst, 19/6)))

Prepare endpoints and times together

Define which events count for OS, PFS, DFS, RFS or TTP in the study protocol; these names alone do not specify every clinical rule. Outcome Organizer combines indicators but cannot derive the earliest recurrence/death time. A composite indicator must be paired with time to its first qualifying event. Do not pair recurrence-or-death status with time to death when recurrence occurred earlier.

An unknown vital status stays unknown until verified. Administrative censoring truncates follow-up at a fixed date and keeps qualifying events on or before that date. A negative numeric cut-off duration places the cut-off before a patient’s time origin. Outcome Organizer reports such rows with recorded follow-up and skips the administrative-censoring step. Review cohort eligibility and time units before rerunning. Check the origin, date convention, timezone, last verified event-free assessment and follow-up end. The interval calculator defaults to calendar months/years and also offers standardized durations. Fixed divisions of days by 365.25 or 30.4375 use the latter convention. Precalculated times are never converted just by changing the output-unit selector, and time points you type are read in the selected unit as typed. The built-in default 12, 36, 60 is written in months; with days selected it means 12, 36 and 60 days, and Survival Analysis says so in a table note (enter 365, 1095, 1825 for 1, 3 and 5 years).

Landmark analyses condition on observation beyond the landmark, exclude exact ties, and subtract the landmark from retained times. They answer a conditional question and do not implement delayed entry. Standard survival analyses disclose zero-time events; LASSO Cox requires strictly positive follow-up. Do not add an arbitrary constant to make data fit.

For competing risks, the probability of the event of interest, the competing event probability and the event-free probability sum to one at a given time. In the six-patient fixture, change the observed event at time 2 to a competing event. By time 4 the event of interest has estimated probability 1/6 + (2/3) × (1/2) = 1/2, the competing event probability is 1/6, and the event-free probability is 1/3.

competing <- transform(cohort, status = factor(c("Target", "Other", "Censored",
                                                "Censored", "Target", "Censored")))
cr <- jsurvival::singlearm(
  data = competing, elapsedtime = "time", outcome = "status", outcomeLevel = NULL,
  multievent = TRUE, analysistype = "compete", dod = "Target", dooc = "Other",
  awd = NULL, awod = "Censored", timetypeoutput = "months", cutp = "4",
  cif_all_causes = TRUE
)
cif <- cr$cifTable$asDF
stopifnot(isTRUE(all.equal(sort(cif$estimate), c(1/6, 1/3, 1/2))))
cif
#>     group time              cause  estimate       lower     upper n_risk
#> 1 Overall    4         Event-free 0.3333333 0.013684878 0.7548440      2
#> 2 Overall    4  Event of interest 0.5000000 0.046122308 0.8554131      2
#> 3 Overall    4 Competing event(s) 0.1666667 0.007723104 0.5168018      2
#>   n_events n_censored
#> 1        3          2
#> 2        2          2
#> 3        1          2

Preserve scaling and cutoff definitions

Continuous age per decade is age / 10, so its HR refers to a ten-year increase. Rounding age down to a decade changes the predictor into bins. Ordinal factors in the standard Cox analyses are represented as level comparisons; that is not an assumed linear trend.

For a cutoff selected by survivalcont, the grouping rule is Low ≤ cutoff; High > cutoff. Use the unrounded value and the same equality rule for a held-out cohort:

cutoff <- 15.2
marker <- c(15.1, 15.2, 15.3, NA_real_)
group <- ifelse(marker > cutoff, "High", "Low")
stopifnot(identical(group, c("Low", "Low", "High", NA_character_)))

The single optimal-cutoff table includes a search-adjusted p-value. That adjustment does not correct the optimism of the selected group HR. Outcome-guided multiple cutoffs have unadjusted inferential comparisons. Keep a continuous model when it answers the research question, and validate a selected threshold in patients who did not influence its selection.

Separate model fitting, tuning and validation

A Cox HR is a relative instantaneous hazard. A group with no events has no estimable HR: the partial likelihood is monotone, the coefficient diverges, and the Wald interval (0 to infinity) and p-value (near 1) carry no information even when the log-rank test is clearly significant. Survival Analysis leaves those cells blank with a footnote and keeps the group out of the written summaries; compare such groups with the log-rank or pairwise tests. When the principal Cox model for Continuous Survival or Multivariable Survival reports nonconvergence or a potentially infinite coefficient, the module withholds its fitted model outputs. Review sparse levels, coding and separation before interpreting a refit.

set.seed(1)
zero <- data.frame(
  time = c(rexp(20, 0.1), rexp(15, 0.1), runif(8, 1, 30)),
  status = c(rbinom(20, 1, 0.8), rbinom(15, 1, 0.8), rep(0, 8)),
  group = factor(rep(c("A", "B", "C"), c(20, 15, 8)))
)
fit <- jsurvival::survival(
  data = zero, elapsedtime = "time", outcome = "status", outcomeLevel = "1",
  dod = NULL, dooc = NULL, awd = NULL, awod = NULL, explanatory = "group", cutp = "5, 10"
)
cox <- fit$coxTable$asDF
hr_c <- as.character(cox$HR_univariable[cox$Levels == "C"])
stopifnot(is.na(hr_c) || !nzchar(hr_c))   # group C had no events: no HR is shown
cox
#>   Explanatory Levels       all            HR_univariable
#> 1       group      A 20 (46.5)                         -
#> 2        <NA>      B 15 (34.9) 1.21 (0.57-2.60, p=0.617)
#> 3        <NA>      C  8 (18.6)                      <NA>

An interaction main effect applies at the reference/zero value of the other term; it is not an overall average effect. Assess PH and the functional form of continuous predictors. Sparse events, missingness, collinearity and overfitting can undermine a numerically successful fit.

LASSO cross-validation selects lambda. The displayed C-index and risk groups use the development patients and are apparent performance. The C-index ranges from 0 to 1 when comparable pairs exist, with chance ordering at 0.5; it measures ordering, not calibration. An empty LASSO model is a valid result. Conventional post-selection p-values and confidence intervals are withheld. For performance validation repeat preprocessing, selection and tuning within resampling, then assess the frozen model externally. Fixed event-count rules do not establish sufficient sample size (Riley et al., 2020).

Survival Analysis adjusted curves use the same fitted model and complete-case cohort as the age-adjusted table. Baseline strata and age-group strata are retained under every group assignment. Patient predictions are aligned on a common time grid before averaging; curves end at the shortest observed stratum follow-up, so an unsupported late plateau does not enter the average. Confidence bands for these standardized averages are not provided. In Multivariable Survival, pooled cross-stratum risk scores are withheld when stratification is enabled because each stratum has its own baseline hazard.

Multivariable Survival interaction forest plots show all fitted coefficients with their 95% confidence intervals, conditioning values and a caption. Both styles use this coefficient display when interactions are present. A main effect applies at the stated reference/zero values; an interaction row is a ratio of hazard ratios. Retain the caption with the figure, including any warning that a conditioning value is outside the data. Non-estimable coefficients are labelled without an estimate or interval. The written summaries count significant “factors” only among variables outside interactions, and say so; a conditional main effect or a ratio of hazard ratios is not a risk factor on its own.

The optimism-corrected C-index refits the model in bootstrap resamples. Missing factor levels can make a resample unusable for validation. When exclusions exceed 10%, the table flags possible selection bias in the corrected estimate. If clinically justified, prespecify a grouping of levels, refit the model and repeat validation. Report the exclusion count and the limitation if sparse levels remain.

Binary endpoints and diagnostic tests

In the binary pathology workbook, nodal status at surgery is the reference outcome. The ordinary logistic model estimates adjusted odds ratios and its prediction nomogram converts model points to predicted probabilities. The separate diagnostic predictor uses paired observations and explicitly selected positive and negative levels. For the saved test, 79 true positive, 20 false positive, 12 false negative and 129 true negative observations give the following fractions.

sensitivity <- 79 / (79 + 12)
specificity <- 129 / (129 + 20)
c(sensitivity = sensitivity, specificity = specificity,
  LR_positive = sensitivity / (1 - specificity),
  LR_negative = (1 - sensitivity) / specificity)
#> sensitivity specificity LR_positive LR_negative 
#>   0.8681319   0.8657718   6.4675824   0.1523128

For clinical studies, report how the reference diagnosis was obtained, which patients had paired observations, the test threshold, and uncertainty. Predictive values depend on the population’s outcome prevalence. The apparent C-statistic orders patients by their fitted probability of the selected positive outcome. Evaluate discrimination and calibration on new data before applying the prediction nomogram. Case-control sampling can support odds-ratio estimation under suitable design assumptions, while probabilities from the fitted intercept reflect the sampled outcome distribution. Boundary diagnostic counts can leave log-method likelihood-ratio confidence intervals unavailable.

Reporting checklist

  • Cohort, exclusions, missingness, number of patients and events, and unit of analysis.
  • Endpoint definition, event/censor coding, time origin, unit/convention, and landmark if used.
  • Estimand and estimator, uncertainty method, risk sets and follow-up support at reported times.
  • Covariate units, factor references, interactions, PH assessment and adjustment variables.
  • Whether cutoffs were prespecified or selected, search correction, exact threshold and tie rule.
  • Model candidate set, penalty rule, seed/folds, apparent versus validated performance, and limitations.
  • Module version and reproducible options; interpretation in the study’s clinical context.