analyse_multivariate: Multivariate analysis (Cox Regression)

Description Usage Arguments Details Value See Also Examples

View source: R/cox.R

Description

Performs Cox regression on right-censored data using a multiple covariates.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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)
)

Arguments

data

A data frame containing the time/status information and, if used, the covariate.

time_status

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.

covariates

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

Strata (optional). Same format as covariates. For each strata level (if multiple fields, unique combinations of levels) a separate baseline hazard is fit.

covariate_name_dict

A dictionary (named list or vector) of old->new covariate names

covariate_label_dict

A dictionary (named list or vector) of old->new covariate value level labels

reference_level_dict

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#'

sort_frame_by

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.

Details

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.

Value

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

See Also

forest_plot

Examples

1
2
3
4
5
6
library(magrittr)
library(dplyr)
survival::colon %>%
   analyse_multivariate(vars(time, status),
                        vars(rx, sex, age, obstruct, perfor, nodes, differ, extent)) %>%
   print()

Example output

Attaching package:dplyrThe following objects are masked frompackage:stats:

    filter, lag

The following objects are masked frompackage:base:

    intersect, setdiff, setequal, union

Overall:
    n                                            covariates
 1776 rx, sex, age, obstruct, perfor, nodes, differ, extent
 Likelihood ratio test p Wald test p Score (logrank) test p
                  <0.001      <0.001                 <0.001

Hazard Ratios:
  factor.id factor.name factor.value   HR Lower_CI Upper_CI Inv_HR Inv_Lower_CI
 rx:Lev+5FU          rx      Lev+5FU 0.64     0.54     0.75   1.57         1.33
        sex         sex <continuous> 0.91      0.8     1.04   1.09         0.96
     rx:Lev          rx          Lev 0.93      0.8     1.09   1.08         0.92
        age         age <continuous>  1.0      1.0     1.01    1.0         0.99
      nodes       nodes <continuous> 1.08     1.07      1.1   0.92         0.91
     differ      differ <continuous> 1.16     1.01     1.33   0.86         0.75
     perfor      perfor <continuous> 1.16     0.81     1.66   0.86          0.6
   obstruct    obstruct <continuous> 1.22     1.04     1.44   0.82         0.69
     extent      extent <continuous>  1.6     1.36     1.87   0.63         0.53
 Inv_Upper_CI      p
         1.86 <0.001
         1.25  0.185
         1.26  0.358
          1.0  0.452
         0.93 <0.001
         0.99  0.036
         1.23  0.412
         0.96  0.016
         0.74 <0.001

survivalAnalysis documentation built on April 24, 2021, 5:07 p.m.