Learn R Programming

CLRtools (version 0.1.0)

univariable.models: Univariable Logistic Regression Summary Table

Description

Fits univariable logistic regression models glm function for a set of predictors and summarizes coefficients, standard errors, likelihood ratio test statistics, and optionally odds ratios with confidence intervals.

Usage

univariable.models(
  data,
  yval,
  xval,
  OR = FALSE,
  inc.or = NULL,
  confidence.level = 0.95
)

Value

A data frame with coefficients from the univariable models, standard errors, p-values, and, if requested, odds ratios with lower and upper confidence limits.

Arguments

data

A data frame containing the outcome and predictor variables.

yval

A string indicating the name of the binary outcome variable.

xval

A character vector with the names of the explanatory variables to be evaluated univariately.

OR

Logical; if TRUE, odds ratios and their confidence intervals are returned. Default to FALSE.

inc.or

A numeric vector of scaling factors to be applied to each coefficient to obtain odds ratios.

confidence.level

The confidence level to use for interval estimation of odds ratios. Defaults to 0.95.

Examples

Run this code
# Example from Hosmer et al., 2013
# Applied Logistic Regression (3rd ed.), Chapter 4, Table 4.7

# Define variables to evaluate
unvariables <- c(
  'age','weight','height', 'bmi', 'priorfrac', 'premeno', 'momfrac',
  'armassist','smoke', 'raterisk')

# Define value ranges used to interpret odds ratios (Optional)
val.pe <- c(5, 5, 10, 5, 1, 1, 1, 1, 1, 1, 1)

# Run univariable conditional logistic regressions
univariable.models(glow500, yval = 'fracture', xval = unvariables, OR = TRUE, inc.or = val.pe)

Run the code above in your browser using DataLab