cox_output: Calculate cox regression and extract Hazard Ratio and pvalues

View source: R/cox_output.R

cox_outputR Documentation

Calculate cox regression and extract Hazard Ratio and pvalues

Description

This function calculates a cox regression with the coxph function of the survival package (univariate if number of vars = 1, multivariate if number of vars > 1). Hazard ratios and pvalues are extracted and shown in a table format. If a variable is divided in more than 2 groups the wald test statistic for overall significance is also shown. This function calculates a univariate cox regression with the coxph function from the survival package if the argument vars is length 1; otherwise a multivariate cox regression is calculated. Hazard ratios and pvalues are extracted and shown in a table format. If a variable in univariate cox regression is divided in more than 2 groups the wald test statistic for overall significance is also shown.

Usage

cox_output(
  data,
  time,
  status,
  vars,
  fixed.var = NULL,
  output = "table",
  modeltype = "full",
  p.thres = 0.1,
  niter = 10,
  weights = NULL
)

Arguments

data

data.frame or data.table containing survival data.

time

the time interval from start of observation until date of event (e.g. disease progression or death) or censoring.

status

variable specifying if event occured or data has been censored.

vars

variables tested for Influence on outcome. Defines type of cox regression: if length is 1 the output is a univariate cox regression, for length > 1 the output is a multivariate cox regression

fixed.var

specifies fixed variables to be included in the cox model.

output

Defines the output object of the function. Default is \"table\". Another possible option is \"fit\" to return a coxph object.

modeltype

character value. Allowed values include: "full" and "backwards". Specify if full model or backwards selection model should be used for multivariate cox regression.

p.thres

pvalue threshold for backwards selection model.

niter

number of iterations for backwards selection model.

weights

character variable specifying the name of the weights column. Weights have to be added to the original dataframe in order to be applied correctly.


MBender1992/emR documentation built on Feb. 18, 2025, 9:21 a.m.