Skip to contents

Native coefficient table with the columns and row conventions of broom::tidy() for lm / glm fits: one row per coefficient in coef(model) order (aliased coefficients kept with NA statistics), columns term, estimate, std.error, statistic, p.value taken from summary(model)$coefficients, optional conf.low / conf.high from stats::confint(), and optional exponentiation of the estimate and interval. Any other model class whose summary() carries a coefficients matrix is tidied the same way.

Usage

morie_effects_tidy(
  model,
  conf.int = FALSE,
  conf.level = 0.95,
  exponentiate = FALSE,
  ...
)

Arguments

model

A fitted model object.

conf.int

Logical; add conf.low / conf.high.

conf.level

Confidence level for the interval.

exponentiate

Logical; exponentiate estimate and the interval bounds (e.g. odds ratios for a logit glm).

...

Further arguments passed to stats::confint().

Value

A data frame with one row per model term.

Examples

set.seed(1)
df <- data.frame(y = rnorm(60), x = rnorm(60), g = factor(rep(c("a", "b"), 30)))
fit <- stats::lm(y ~ x + g, data = df)
morie_effects_tidy(fit)
#>          term    estimate std.error  statistic   p.value
#> 1 (Intercept)  0.24510437 0.1569610  1.5615623 0.1239266
#> 2           x -0.03529005 0.1223341 -0.2884727 0.7740313
#> 3          gb -0.26708475 0.2218279 -1.2040176 0.2335589