display_logistic: Display logistic regression results (given a model fit)

View source: R/display-logistic.R

display_logisticR Documentation

Display logistic regression results (given a model fit)

Description

Given a fit object, univariable and (optionally) multivariable results from logistic regression are displayed in a format suitable for presentation.

Usage

display_logistic(
  fit,
  data,
  add_multi = FALSE,
  format = "html",
  conf_level = 0.95,
  exponentiate = TRUE,
  include_last_row = TRUE
)

Arguments

fit

An object of class glm inheriting from "glm" which inherits from the class "lm.

data

A tibble or data frame with the full data set.

add_multi

Logical; include multivariable results. Default is FALSE

format

Display format in case I need to escape some characters. A place holder for now in case I need it in the future. Default is "html".

conf_level

The confidence level to use for the confidence interval. Must be strictly greater than 0 and less than 1. Defaults to 0.95, which corresponds to a 95 percent confidence interval.

exponentiate

Logical indicating whether or not to exponentiate the the coefficient estimates. This is typical for logistic and multinomial regressions, but a bad idea if there is no log or logit link. Defaults to TRUE.

include_last_row

Adds a row at the end of each set of results to give some breathing room. Default is TRUE.

Value

A tibble

Examples

## Not run: 
library(epiDisplay)
library(tidyverse)

dplyr::glimpse(infert)
model0 <- glm(case ~ induced + spontaneous + education,
              family = binomial,
              data = infert)
summary(model0)

display_logistic(fit = model0,
                 data = infert)

display_logistic(fit = model0,
                 data = infert,
                 add_multi = TRUE)


# How does an interaction term work?
# This sort of works right now, but still needs work (2019-03-23)
model0 <- glm(case ~ induced * education,
              family = binomial,
              data = infert)
summary(model0)

display_logistic(fit = model0,
                 data = infert,
                 add_multi = FALSE)

display_logistic(fit = model0,
                 data = infert,
                 add_multi = TRUE)


#### Another data set --------------------------------

library(compareGroups)
data(predimed)
dplyr::glimpse(predimed)
predimed <- predimed %>%
  mutate_if(is.double, as.double)

fit = glm(htn ~ sex + bmi + smoke,
          family = binomial(link = "logit"),
          data = predimed)

display_logistic(fit = fit,
                 data = predimed,
                 add_multi = TRUE)

## End(Not run)

emilelatour/latable documentation built on Sept. 14, 2023, 9:32 a.m.