Skip to contents

Compare multiple model fits on AIC, BIC, log-likelihood and (optional) LR tests

Usage

model_comparison_table(
  models,
  nested = FALSE,
  digits = 3L,
  output_format = "dataframe",
  title = "Model Comparison"
)

Arguments

models

Named list of fitted models.

nested

If TRUE, run LR tests against the previous model in the list.

digits

Decimal places.

output_format

Output target.

title

Title.

Value

A character string.

Examples

set.seed(1)
df <- data.frame(x = rnorm(30))
df$y <- df$x + rnorm(30)
m1 <- lm(y ~ 1, data = df)
m2 <- lm(y ~ x, data = df)
model_comparison_table(list(null = m1, fit = m2))
#>       N df Log.Lik     AIC     BIC  R.sq
#> null 30  2 -48.711 101.423 104.225 0.000
#> fit  30  3 -35.154  76.308  80.511 0.595