tableOR: Results table with odds ratios from logistic regression...

View source: R/tableOR.R

tableORR Documentation

Results table with odds ratios from logistic regression models for binary or ordinal data

Description

Result table with odds ratios, 95%-CI, test statistics, and p-values from logistic regression models for binary or ordinal variables.

Usage

tableOR(
  model,
  caption = "",
  label = "",
  size = "scriptsize",
  factorNames = NULL,
  table.placement = "ht",
  refLevels = NULL,
  language = c("english", "german"),
  short = FALSE,
  latex = TRUE,
  rmStat = FALSE,
  wald = FALSE
)

Arguments

model

Object of class "polr" or "glm" with family binomial.

caption

Character vector of length 1 containing the table caption.

label

Character vector of length 1 containing the reference label of the Latex table.

size

Character vector of length 1 setting LaTeX font site, e.g. "small", "scriptsize", etc.

factorNames

A character vector of size k number of factors or regressor with custom factor labels.

table.placement

LaTeX table positioning. The default is "ht". See ?print.xtable for more information.

refLevels

A character vector of size k number of regressors with custom reference level names. This argument is usuful for objects of class glm(), which does not store the reference level labels internally.

language

Language of the table, either "english" (default) or "german".

short

If TRUE, factor names are removed from factor levels. Default is FALSE.

latex

If TRUE (default) LateX output is produced.

rmStat

Logical, if FALSE (default) output table inludes test statistics.

wald

Logical, if FALSE (default) Wilson confidence intervals are computed.

Value

The table as data.frame and, depending on the value of the argument latex, the function a print of the LaTeX code.

Author(s)

Simon Schwab

See Also

tableRegression, xtable, print.xtable

Examples


data <- carData::TitanicSurvival
# relevel: baseline is survived yes.
data$survived <- relevel(x = data$survived, ref = "yes") 
model <- glm(survived ~ sex + age + passengerClass, data = data, family = binomial())
tableOR(model = model, latex = FALSE, short = TRUE,
        refLevels = c("female", "1st"), 
        caption = "Changes in odds for risk of death in the Titanic tragedy.")

## using log regression for ordinal data
data$passengerClass <- factor(x = data$passengerClass, ordered = TRUE)
model <- MASS::polr(passengerClass ~ sex + age, data = data, Hess = TRUE)
tableOR(model = model, latex = FALSE, short = TRUE, 
        caption = "Changes in odds for being in a lower class, i.e. 2nd or 3rd class")


felix-hof/biostatUZH documentation built on Sept. 27, 2024, 1:48 p.m.