glm_table: Produce a formatted generalized linear model table

Description Usage Arguments Value Examples

View source: R/glm_table.R

Description

This function returns a formatted table of generalized linear model results.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
glm_table(fit, digits = 4, p.digits = digits + 1, se = "normal",
  intercept = FALSE, fmt = FALSE, fun_coef = if (class(fit)[1] == "lm" ||
  fit$family$link == c("identity")) I else exp, id, ...)

fmt.glm_table(glm_tbl, tbl_colnames = c(colnames(glm_tbl)[1], "95% CI",
  "p-value"), tbl_rownames = rownames(glm_tbl), digits = 2,
  p.digits = digits + 1, p_fmt = function(p)
  format.pval(round(as.numeric(p), p.digits), eps = 0.001),
  beta_fmt = function(b) format(as.numeric(b), digits = digits, nsmall =
  digits), ci_fmt = function(col1, col2) paste0(beta_fmt(col1), " to ",
  beta_fmt(col2)))

Arguments

fit

An glm fit object of class glm.

digits

Integer. The number of significant digits to return in coefficients

p.digits

Integer. The numeric of significant digits to return in p-values

se

Character. The type of standard error to use, "normal" or "robust".

intercept

Logical. Whether or not to include the intercept row in the returned table.

fmt

Logical. If true, passes the returned table to fmt.glm_table, returning a publication-ready table.

fun_coef

Function to apply to the coefficients. By default, exp if link is "log" or "logit", otherwise identity.

...

Arguments passed to fmt.glm_table.

Value

A matrix with coefficients, 95% confidence intervals, and p-values.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Basic logistic regression example
n <- 50
x <- rnorm(n)
y <- sample(c(TRUE, FALSE), size=n, replace=TRUE)
fit <- glm(y~x, family=binomial)
glm_table(fit)

## Use se="robust" to get risk ratios from poisson regression
fit <- glm(y~x, family=poisson)
glm_table(fit, se="robust")

## Get a nicely formatted table
glm_table(fit, fmt=TRUE)

audreyrenson/clinRes documentation built on Feb. 14, 2020, 10:27 a.m.