Learn R Programming

weights (version 1.1.1)

onetable: Create a clean regression summary table from one or more models

Description

onetable extracts and formats coefficients, standard errors, p-values, significance stars, and model fit statistics from one or more model objects. It returns a matrix-style table suitable for printing or export. Models may include linear models, generalized linear models, ordinal regressions, mixed-effects models, generalized additive models, penalized regressions, and multinomial regressions.

Usage

onetable(..., digits = 2, p.digits = 3,
         fitstats = c("r.squared", "adj.r.squared", "mcfadden", "aic", "n"),
         model.names = NULL, collapse = FALSE, formatted = TRUE,
         show.cutpoints = TRUE, approx.p = FALSE)

Value

A character matrix with one row per coefficient (and optionally model fit statistics), and one or more columns depending on whether collapse = TRUE. The object is suitable for display using functions like kable or export to LaTeX or HTML tables.

Arguments

...

One or more fitted model objects. Supported classes include lm, glm, polr, lmerMod, gam, glmnet, and multinom.

digits

Number of digits to display for estimates and standard errors (default is 2).

p.digits

Number of digits to display for p-values (default is 3).

fitstats

A character vector of model fit statistics to display. Options include "r.squared", "adj.r.squared", "mcfadden", "aic", and "n".

model.names

An optional character vector to name the models in the output.

collapse

If TRUE, each model is displayed in a single column with format estimate (se)***.

formatted

If TRUE, values are formatted using rd for readability. If FALSE, raw numeric values are returned.

show.cutpoints

If TRUE, includes cutpoints for ordinal models (e.g., from polr).

approx.p

If TRUE, attempts to compute approximate p-values (e.g., from t-statistics) for models that do not provide them natively (e.g., lmerMod).

See Also

coeffer, findn, rd, pR2, polr, multinom, lmer, gam, glmnet, kable

Examples

Run this code
data(mtcars)
mod1 <- lm(mpg ~ wt + hp, data = mtcars)
mod2 <- glm(am ~ wt + hp, data = mtcars, family = binomial)

onetable(mod1, mod2)

# Collapsed form
onetable(mod1, mod2, collapse = TRUE)

# Use formatted = FALSE for raw numeric output
onetable(mod1, mod2, formatted = FALSE)

# Add approximate p-values for mixed models
library(lme4)
mod3 <- lmer(Reaction ~ Days + (1 | Subject), data = sleepstudy)
onetable(mod3, approx.p = TRUE)

Run the code above in your browser using DataLab