surv_gethr: Get Hazard Ratio from Cox Model

View source: R/surv_gethr.R

surv_gethrR Documentation

Get Hazard Ratio from Cox Model

Description

The purpose of this function is so that the user can easily extract hazard ratios, hazard ratio confidence intervals, and hazard ratio pvalues easily. This function also outputs Hazard Ratios that can easily be added plots

Usage

surv_gethr(fit, vars, names = NULL, ndec = 4)

Arguments

fit

coxph model

vars

character vector including the covariates fo the cox model that we would like to extract hazard ratios for. Note: if a covariate was wrapped, for example tt(age_wk), the wrapping and the variable should be included

names

character vector of same length as vars that provides formal names for the variables in place of variable name.

ndec

numeric that specifies the number of decimal places to round the hazard ratios

Value

hr_table

a dataframe whos rows correspond the variables inputted by the vars argument and whos names are determined by the names argument. If the names argument is not given the names are the same as the variable names. This dataframe has the following columns (1) value - provides the hazard ratio (2) lower - lower bound of 95 (3) upper - upper bound of 95 (4) pval - the p-value for the hazard ratio (5) final - a character stirng that includes columns 1-4 for table output (6) with_names - character string like final, but the variable name is included

hr_text

a character string that has the with names for each variable separated by \n, so that the hazard ratios for vars can be included in a kaplan meier plot.

Author(s)

William Mueller, Eric J. Shiroma


wfmueller29/SLAM documentation built on April 5, 2025, 5:09 a.m.