compare_accuracy {lvmisc}R Documentation

Compare models accuracy

Description

Computes some common model accuracy indices of several different models at once, allowing model comparison.

Usage

compare_accuracy(..., rank_by = NULL, quiet = FALSE)

Arguments

...

A list of models. The models can be of the same or of different classes, including lvmisc_cv class.

rank_by

A character string with the name of an accuracy index to rank the models by.

quiet

A logical indicating whether or not to show any warnings. If FALSE (the default) no warnings are shown.

Value

A data.frame with a model per row and an index per column.

Examples

m1 <- lm(Sepal.Length ~ Species, data = iris)
m2 <- lm(Sepal.Length ~ Species + Petal.Length, data = iris)
m3 <- lm(Sepal.Length ~ Species * Petal.Length, data = iris)
compare_accuracy(m1, m2, m3)

if (require(lme4, quietly = TRUE)) {
  mtcars <- tibble::as_tibble(mtcars, rownames = "cars")
  m1 <- lm(Sepal.Length ~ Species, data = iris)
  m2 <- lmer(
    Sepal.Length ~ Sepal.Width + Petal.Length + (1 | Species), data = iris
  )
  m3 <- lm(disp ~ mpg * hp, mtcars)
  cv3 <- loo_cv(m3, mtcars, cars)
  compare_accuracy(m1, m2, cv3, rank_by = "AIC")
}

[Package lvmisc version 0.1.2 Index]