compare_accuracy: Compare models accuracy

Description Usage Arguments Value Examples

View source: R/compare_accuracy.R

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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")
}

lvmisc documentation built on April 5, 2021, 5:06 p.m.