regression_table: Produce a table summarising a regression model for a study...

View source: R/regression_table.R

regression_tableR Documentation

Produce a table summarising a regression model for a study report

Description

Produce a table summarising a regression model for a study report

Usage

regression_table(
  x,
  labels = names(coef(x)),
  digits = getOption("cctu_digits", default = 3),
  p_digits = getOption("cctu_p_digits", default = 4),
  trans = if (class(x)[1] %in% c("glm", "coxph")) {
     exp
 } else {
     NULL
 },
  level = 0.95,
  col_names = guess_col_names(x, trans)
)

Arguments

x

a regression object

labels

character vector describing the meaning of the coefficient parameters in plain English

digits

integer giving the number of significant figures to print

p_digits

integer giving the number of digits to print p-values, or print as "<0.001" for example

trans

a function to transform the coefficients by, e.g. present the odds ratios, as well as log-odds ratios. It intelligent tries to guess between no transformation and exp, but may be wrong.

level

value in the unit interval to use for calculating confidence intervals

col_names

character vector of the column labels. It intelligently tries to guess based on the class of x and the transformation, but may be wrong.

Details

methods exists when x is of the following classes: lm, glm, gls, lme, coxph, gee. Extensions to other classes may be written by defining methods for coef_table and covar functions

Value

a matrix giving standard inference of coefficients, SE, confidence intervals, p-values, plus a brief summary of the number of data points and residual error variance.

Examples

library(survival)
cfit1 <- coxph(Surv(time, status) ~ age + sex + wt.loss, data = lung)
regression_table(cfit1,
  digits = 4,
  labels = c(
    "Age (per year)", "Sex (Female vs Male)",
    "Weight loss (per pound)"
  )
)


shug0131/cctu documentation built on Feb. 15, 2025, 3:27 p.m.