Function for Multivariable Survival Analysis using Cox-regression.
multisurvival(
data,
elapsedtime,
tint = FALSE,
dxdate,
fudate,
outcome,
outcomeLevel,
dod,
dooc,
awd,
awod,
explanatory,
contexpl,
multievent = FALSE,
analysistype = "overall",
timetypedata = "ymd",
timetypeoutput = "months",
uselandmark = FALSE,
landmark = 3,
hr = FALSE,
sty = "t1",
ph_cox = FALSE,
calculateRiskScore = FALSE,
plotRiskGroups = FALSE,
km = FALSE,
endplot = 60,
byplot = 12,
ci95 = FALSE,
risktable = FALSE,
censored = FALSE,
pplot = TRUE,
ac = FALSE,
adjexplanatory,
ac_method = "average",
ac_summary = FALSE,
ac_timepoints = "12, 36, 60",
ac_compare = FALSE,
reduced_explanatory,
compare_models = FALSE,
use_modelSelection = FALSE,
modelSelection = "enter",
selectionCriteria = "aic",
pEntry = 0.05,
pRemoval = 0.1,
use_stratify = FALSE,
stratvar
)
The dataset to be analyzed, provided as a data frame. Must contain the variables specified in the options below.
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.
If true, survival time will be calculated from dxdate
and fudate
. If false, elapsedtime
should be provided as a
pre-calculated numeric variable.
Date of diagnosis. Required if tint
= true. Must match
the format specified in timetypedata
.
Follow-up date or date of last observation. Required if
tint
= true. Must match the format specified in timetypedata
.
The outcome variable. Typically indicates event status (e.g., death, recurrence). For survival analysis, this may be a factor or numeric event indicator.
The level of outcome
considered as the event.
For example, if outcome
is a factor, specify which level indicates
the event occurrence.
The level of outcome
corresponding to death due to
disease, if applicable.
The level of outcome
corresponding to death due to other
causes, if applicable.
The level of outcome
corresponding to alive with disease,
if applicable.
The level of outcome
corresponding to alive without
disease, if applicable.
Categorical explanatory (predictor) variables included in the Cox model.
Continuous explanatory (predictor) variables included in the Cox model.
If true, multiple event levels will be considered for
competing risks analysis. Requires specifying dod
, dooc
, etc.
Type of survival analysis: - overall: All-cause survival - cause: Cause-specific survival - compete: Competing risks analysis
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
.
The units in which survival time is reported in the output. Choose from days, weeks, months, or years.
If true, applies a landmark analysis starting at a specified time point.
The time point (in the units defined by
timetypeoutput
) at which to start landmark analyses. Only used if
uselandmark
= true.
If true, generates a plot of hazard ratios for each explanatory variable in the Cox model.
The style of the hazard ratio (forest) plot. "finalfit" or "survminer forestplot".
If true, tests the proportional hazards assumption for the Cox model. Use if you suspect violations of the PH assumption.
If true, calculates a risk score from the Cox model coefficients for each individual.
If true, stratifies individuals into risk groups based on their calculated risk scores and plots their survival curves.
If true, produces a Kaplan-Meier survival plot. Useful for visualization of survival functions without covariate adjustment.
The maximum follow-up time (in units defined by
timetypeoutput
) to display on survival plots.
The interval (in units defined by timetypeoutput
) at
which time points or labels are shown on plots.
If true, displays 95\ estimates on plots.
If true, displays the number of subjects at risk at each time point below the survival plot.
If true, marks censored observations (e.g., using tick marks) on the survival plot.
If true, displays the p-value from the survival comparison test on the survival plot.
.
.
Method for computing adjusted survival curves
Calculate and display summary statistics for adjusted curves
Timepoints for calculating summary statistics (comma-separated)
Perform statistical comparison between adjusted curves
Variables to include in a reduced model for comparison. This can be used to test whether excluding some variables affects model fit.
If true, compares the full model against the reduced model to assess the impact of removing certain explanatory variables.
If true, applies a variable selection procedure to find the best-fitting model based on criteria like AIC or likelihood ratio tests.
The method used to select variables: - enter: Includes all variables (no selection) - forward: Adds variables one at a time if they improve the model - backward: Removes variables that do not significantly contribute - both: Combination of forward and backward steps
The criterion used for adding or removing variables in model selection: - aic: Balances model fit and complexity - lrt: Uses likelihood ratio tests to decide inclusion/removal
Significance level at which a variable enters the model during forward or stepwise selection.
Significance level at which a variable is removed from the model during backward or stepwise selection.
If true, uses stratification to handle variables that violate the proportional hazards assumption. Stratification creates separate baseline hazard functions for different groups.
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.
A results object containing:
results$todo | a html | ||||
results$text | a html | ||||
results$text2 | a html | ||||
results$plot | an image | ||||
results$plot3 | an image | ||||
results$cox_ph | a preformatted | ||||
results$plot8 | an image | ||||
results$plotKM | an image | ||||
results$riskScoreTable | a table | ||||
results$riskScoreMetrics | a html | ||||
results$riskGroupPlot | an image | ||||
results$calculatedtime | an output | ||||
results$outcomeredefined | an output | ||||
results$addRiskScore | an output | ||||
results$addRiskGroup | an output | ||||
results$plot_adj | an image | ||||
results$adjustedSummaryTable | a table | ||||
results$adjustedComparison | a preformatted | ||||
results$adjustedSurvTable | a table | ||||
results$adjustedSurvTableSummary | a html | ||||
results$adjustedPairwiseTable | a table | ||||
results$adjustedPairwiseSummary | a html | ||||
results$adjustedMedianTable | a table | ||||
results$adjustedMedianSummary | a html | ||||
results$adjustedCoxTable | a table | ||||
results$adjustedCoxText | a html | ||||
results$adjustedCoxSummary | a html | ||||
results$adjustedCoxPH | a html | ||||
results$adjustedCoxPHPlot | an image | ||||
results$model_comparison | a html | ||||
results$reduced_model_metrics | a html | ||||
results$text_model_selection | a html | ||||
results$text2_model_selection | a html | ||||
results$selectionSteps | a table |
Tables can be converted to data frames with asDF
or as.data.frame
. For example:
results$riskScoreTable$asDF
as.data.frame(results$riskScoreTable)
# \donttest{
# example will be added
# }