glm_coef {pubh}R Documentation

Table of coefficients from generalised linear models.

Description

glm_coef displays estimates with confidence intervals and p-values from generalised linear models (see Details).

Usage

glm_coef(
  model,
  digits = 2,
  alpha = 0.05,
  labels = NULL,
  se_rob = FALSE,
  type = "cond",
  exp_norm = FALSE
)

Arguments

model

A model from any of the classes listed in the details section.

digits

A scalar, number of digits for rounding the results (default = 2).

alpha

Significant level (default = 0.05) used to calculate confidence intervals.

labels

An optional character vector with the names of the coefficients (including intercept).

se_rob

Logical, should robust errors be used to calculate confidence intervals? (default = FALSE).

type

Character, either "cond" (condensed) or "ext" (extended). See details.

exp_norm

Logical, should estimates and confidence intervals should be exponentiated? (for family == "gaussian").

Details

glm_coef recognises objects (models) from the following classes: clm, clogit, coxph, gee, glm, glmerMod, lm, lme, lmerMod, multinom, negbin, polr and surveg

For models from logistic regression (including conditional logistic, ordinal and multinomial), Poisson or survival analysis, coefficient estimates and corresponding confidence intervals are automatically exponentiated (back-transformed).

By default, glm_coef uses naive standard errors for calculating confidence intervals but has the option of using robust standard errors instead.

glm_coef can display two different data frames depending on the option of type, for type type = "cond" (the default), glm_coef displays the standard table of coefficients with confidence intervals and p-values; for type = "ext", glm_coef displays additional statistics including standard errors.

Please read the Vignette on Regression for more details.

Value

A data frame with estimates, confidence intervals and p-values from glm objects.

Examples

require(dplyr, quietly = TRUE)
require(sjlabelled, quietly = TRUE)

## Continuous outcome.
data(birthwt, package = "MASS")
birthwt <- birthwt %>%
  mutate(
    smoke = factor(smoke, labels = c("Non-smoker", "Smoker")),
    race = factor(race, labels = c("White", "African American", "Other"))
  ) %>%
  var_labels(
    bwt = "Birth weight (g)",
    smoke = "Smoking status",
    race = "Race"
  )

model_norm <- lm(bwt ~ smoke + race, data = birthwt)

glm_coef(model_norm, labels = model_labels(model_norm))

## Logistic regression.
data(diet, package = "Epi")
model_binom <- glm(chd ~ fibre, data = diet, family = binomial)
model_binom %>%
  glm_coef(labels = c("Constant", "Fibre intake (g/day)"))

model_binom %>%
  glm_coef(labels = c("Constant", "Fibre intake (g/day)"), type = "ext")

[Package pubh version 1.3.2 Index]