View source: R/compare_accuracy.R
compare_accuracy | R Documentation |
Computes some common model accuracy indices of several different models at once, allowing model comparison.
compare_accuracy(..., rank_by = NULL, quiet = FALSE)
... |
A list of models. The models can be of the same or of different
classes, including |
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
|
A data.frame
with a model per row and an index per column.
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")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.