align_coefs: Align and combine fixed-effect coefficients from multiple...

View source: R/modelling.R

align_coefsR Documentation

Align and combine fixed-effect coefficients from multiple models

Description

Extracts and aligns the fixed-effect estimates from a list of fitted model objects, returning them in a single tidy data frame with consistent columns for easy comparison. Works with a mix of model types such as lm, glm, gls, lmer, etc.

For models without p-values (e.g., lmer), the function computes approximate Wald statistics and two-sided normal p-values.

Usage

align_coefs(models)

Arguments

models

A named list of fitted model objects. Each element should be a model that can be passed to broom::tidy().

Value

A tibble with columns:

model

The name of the model (from the list).

term

The term name (coefficient).

estimate

The estimated coefficient.

std.error

The standard error.

statistic

The Wald statistic (estimate / std.error).

p.value

Two-sided normal p-value.

Examples

# Example using the built-in CO2 dataset
data(CO2)

# Fit models
lm_fit  <- lm(uptake ~ conc + Type + Treatment, data = CO2)
glm_fit <- glm(uptake ~ conc + Type + Treatment, family = Gamma(identity), data = CO2)

# Combine estimates
models_list <- list(lm = lm_fit, glm = glm_fit)
result <- align_coefs(models_list)
print(result)


doBy documentation built on Dec. 2, 2025, 9:08 a.m.