nicecoxph: Lisa's Cox Proportional Hazards Regression Table Reporting...

View source: R/nicecoxph.R

nicecoxphR Documentation

Lisa's Cox Proportional Hazards Regression Table Reporting Function

Description

This function creates a nice looking table of regression results for a coxph model. Input either a coxph object or dataframe, event variable, time variable, vector of covariates, and type of analysis (univariate or multiple regression). The function returns a dataframe of formatted regression results and prints the results table using kable or htmlTable.

Usage

nicecoxph(
  fit = NA,
  df = NA,
  covs = NA,
  ttevent = "ttevent",
  event = "event",
  ttentry = NA,
  weightvar = NA,
  cluster = NA,
  strata = NA,
  frailty = NA,
  regtype = "uni",
  type2 = FALSE,
  type3 = FALSE,
  phtest = FALSE,
  labels = NA,
  estname = NA,
  refcat = FALSE,
  est.dec = 2,
  ci.dec = 2,
  pval.dec = 3,
  color = "#EEEEEE",
  kable = TRUE,
  htmlTable = FALSE,
  title = "",
  footer = TRUE
)

Arguments

fit

coxph model object [fit or df/event/ttevent/covs are REQUIRED].

df

Dataframe [fit or df/event/ttevent/covs are REQUIRED].

covs

Character. Vector of covariates to include in model [fit or df/event/ttevent/covs are REQUIRED].

ttevent

Character. Name of time to event variable [fit or df/event/ttevent/covs are REQUIRED].

event

Character. Name of event variable [fit or df/event/ttevent/covs are REQUIRED].

ttentry

Character. Name of entry time variable for left truncated data. Default is NA (no delayed entry).

weightvar

Character. Name of weighting variable. Default is NA (no weights).

cluster

Character. Name of cluster variable. Default is NA (no clustering).

strata

Character. Vector of names of strata variable(s). Default is NA (no strata).

frailty

Character. Name of frailty variable. Default is NA (no random effect).

regtype

Logical. Should the covariates be run separately ("uni") or together in a multiple regression model ("multi") [REQUIRED if no fit].

type2

Logical. If TRUE, type II p-values will be added to the table. Default is FALSE.

type3

Logical, If TRUE, type III p-values will be added to the table. Default is FALSE.

phtest

Logical. If TRUE, a test for proportional hazards (via cox.zph) will be included in the footnote. Default is FALSE.

labels

Character. Vector of labels for covariates. Default is NA (use variable names).

estname

Character. Label for estimate. Default = NA: "HR" for univariate and "aHR" for multiple regression.

refcat

Logical. If TRUE the table will create a separate line for the reference category. Default is FALSE.

est.dec

Numeric. Number of decimal places for estimates. Default is 2.

ci.dec

Numeric. Number of decimal places for confidence interval. Default is 2.

pval.dec

Numeric. Number of decimal places for pvalues. Must be an integer from 1 to 4. Default is 3.

color

Character. Color to use for htmlTable striping. Default is "#EEEEEE" (light grey). Use "white" for no striping.

kable

Logical. Indicator to use kable to display table. Default = TRUE.

htmlTable

Logical. Indicator to use htmlTable package to display table instead of kable Default = FALSE.

title

Character. Optional title above table. Default is "".

footer

Logical. If TRUE, table will include a footnote with model details, nobs, R2. Default is TRUE.


lisaerein/nicesurv documentation built on Dec. 9, 2024, 12:17 a.m.