Skip to contents

Function for Multivariable Survival Analysis using Cox-regression.

Usage

multisurvival(
  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,
  pplot = TRUE,
  calculateRiskScore = FALSE,
  plotRiskGroups = FALSE,
  ac = FALSE,
  adjexplanatory,
  ac_method = "average",
  ac_summary = FALSE,
  ac_timepoints = "12, 36, 60",
  ac_compare = FALSE,
  use_stratify = FALSE
)

Arguments

data

The dataset to be analyzed, provided as a data frame. Must contain the variables specified in the options below.

elapsedtime

The numeric variable representing follow-up time until the event or last observation. If tint = false, this should be a pre-calculated numeric time variable. If tint = true, dxdate and fudate will be used to calculate this time.

tint

If true, survival time will be calculated from dxdate and fudate. If false, elapsedtime should be provided as a pre-calculated numeric variable.

dxdate

Date of diagnosis. Required if tint = true. Must match the format specified in timetypedata.

fudate

Follow-up date or date of last observation. Required if tint = true. Must match the format specified in timetypedata.

timetypedata

Specifies the format of the date variables in the input data. This is critical if tint = true, as dxdate and 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 ymd.

timetypeoutput

The units in which survival time is reported in the output. Choose from days, weeks, months, or years.

uselandmark

If true, applies a landmark analysis starting at a specified time point.

landmark

The time point (in the units defined by timetypeoutput) at which to start landmark analyses. Only used if uselandmark = true.

outcome

The outcome variable. Typically indicates event status (e.g., death, recurrence). For survival analysis, this may be a factor or numeric event indicator.

outcomeLevel

The level of outcome considered as the event. For example, if outcome is a factor, specify which level indicates the event occurrence.

dod

The level of outcome corresponding to death due to disease, if applicable.

dooc

The level of outcome corresponding to death due to other causes, if applicable.

awd

The level of outcome corresponding to alive with disease, if applicable.

awod

The level of outcome corresponding to alive without disease, if applicable.

analysistype

Type of survival analysis: - overall: All-cause survival - cause: Cause-specific survival - compete: Competing risks analysis

explanatory

Categorical explanatory (predictor) variables included in the Cox model.

contexpl

Continuous explanatory (predictor) variables included in the Cox model.

multievent

If true, multiple event levels will be considered for competing risks analysis. Requires specifying dod, dooc, etc.

hr

If true, generates a plot of hazard ratios for each explanatory variable in the Cox model.

sty

The style of the hazard ratio (forest) plot. "finalfit" or "survminer forestplot".

ph_cox

If true, tests the proportional hazards assumption for the Cox model. Use if you suspect violations of the PH assumption.

km

If true, produces a Kaplan-Meier survival plot. Useful for visualization of survival functions without covariate adjustment.

endplot

The maximum follow-up time (in units defined by timetypeoutput) to display on survival plots.

byplot

The interval (in units defined by timetypeoutput) at which time points or labels are shown on plots.

ci95

If true, displays 95\ estimates on plots.

risktable

If true, displays the number of subjects at risk at each time point below the survival plot.

censored

If true, marks censored observations (e.g., using tick marks) on the survival plot.

pplot

If true, displays the p-value from the survival comparison test on the survival plot.

calculateRiskScore

If true, calculates a risk score from the Cox model coefficients for each individual.

plotRiskGroups

If true, stratifies individuals into risk groups based on their calculated risk scores and plots their survival curves.

ac

.

adjexplanatory

.

ac_method

Method for computing adjusted survival curves

ac_summary

Calculate and display summary statistics for adjusted curves

ac_timepoints

Timepoints for calculating summary statistics (comma-separated)

ac_compare

Perform statistical comparison between adjusted curves

use_stratify

.

Value

A results object containing:

results$todoa html
results$texta html
results$text2a html
results$plotan image
results$plot3an image
results$cox_pha preformatted
results$plot8an image
results$plotKMan image
results$riskScoreTablea table
results$riskScoreMetricsa html
results$riskGroupPlotan image
results$calculatedtimean output
results$outcomeredefinedan output
results$addRiskScorean output
results$addRiskGroupan output
results$plot_adjan image
results$adjustedSummaryTable2a preformatted
results$adjustedSummaryTablea table
results$adjustedComparisona preformatted
results$adjustedComparison_survdiff_resa preformatted
results$adjustedSurvTable2a preformatted
results$adjustedSurvTablea table
results$adjustedSurvTableSummarya html
results$adjustedPairwiseTablea table
results$adjustedPairwiseSummarya html
results$adjustedMedianTablea table
results$adjustedMedianSummarya html
results$adjustedCoxTablea table
results$adjustedCoxTexta html
results$adjustedCoxSummarya html
results$adjustedCoxPHa html
results$adjustedCoxPHPlotan image
results$model_comparisona html
results$reduced_model_metricsa html
results$text_model_selectiona html
results$text2_model_selectiona html
results$selectionStepsa table

Tables can be converted to data frames with asDF or as.data.frame. For example:

results$riskScoreTable$asDF

as.data.frame(results$riskScoreTable)

Examples

# \donttest{
# example will be added
# }