Performs Cox regression on right-censored data using a multiple covariates.
analyse_multivariate(
data,
time_status,
covariates,
strata = NULL,
covariate_name_dict = NULL,
covariate_label_dict = NULL,
reference_level_dict = NULL,
sort_frame_by = vars(HR)
)analyze_multivariate(
data,
time_status,
covariates,
strata = NULL,
covariate_name_dict = NULL,
covariate_label_dict = NULL,
reference_level_dict = NULL,
sort_frame_by = vars(HR)
)
A data frame containing the time/status information and, if used, the covariate.
A vector of length 2 giving the time and status fields.
It is recommended to use vars() and symbolic column names or code that is tidily-evaluated on data
.
You can also pass a character vector with the column names or a numeric vector with column indices.
The covariates.
Pass symbolic columns names or code that is tidily-evaluated on data
.
Column names or column indices are also possible.
In any case, factors with appropriate labels will be generated which in all printouts.
You can use covariate_name_dict
and covariate_label_dict
to rename these factors and their levels.
Strata (optional). Same format as covariates. For each strata level (if multiple fields, unique combinations of levels) a separate baseline hazard is fit.
A dictionary (named list or vector) of old->new covariate names
A dictionary (named list or vector) of old->new covariate value level labels
For categorical variables, the Cox regression uses pseudo variables for each level
relative to a reference category, resulting in n-1 variables for n levels of a categorical covariate.
Hazard ratios will be relative to the reference level, which is defined as having hazard ratio 1.0.
Per default, the reference level is the first factor level.
You can specify a different level by passing a named vector: factor name -> value of reference level.
Note that this is independent of covariate_label_dict, i.e. specify the factor level as it is in data
#'
A vars() list of one or more symbolic column names.
The result contains a data frame of the cox regression results (cox_as_data_frame
).
This frame contains the variables "Lower_CI", "HR", "Upper_CI", "Inv_Lower_CI", "Inv_HR", "Inv_Upper_CI", "p".
You can specify by which variables the frame should be sorted. Default: Hazard Ratio.
An object of class "SurvivalAnalysisResult" and "SurvivalAnalysisMultivariateResult".
You can use this result as a black box for further functions in this package,
format
or
print
it,
retrieve information as a data frame via multivariate_as_data_frame
or
access individual pieces via pluck_multivariate_analysis
This method builds upon the survival
package and returns a comprehensive result object
for survival analysis containing the coxph results.
A format
/print
method is provided that prints the essential statistics.
# NOT RUN {
library(magrittr)
library(dplyr)
survival::colon %>%
analyse_multivariate(vars(time, status),
vars(rx, sex, age, obstruct, perfor, nodes, differ, extent)) %>%
print()
# }
Run the code above in your browser using DataLab