Let’s imagine that we are interested in explaining the variability in the
Sepal.Length using 3 different predictors. For that, we can build 3 linear models.
The eponymous function from the package,
performance(), can be used to compute different indices of performance (an umbrella term for indices of fit).
library(performance) library(insight) library(magrittr) # for pipe operator # we will use `print_md` function to display a well-formatted table performance(model1) %>% print_md()
But for multiple models, one can obtain a useful table to compare these indices at a glance using the
If you remember your stats lessons, while comparing different model fits, you would like to choose a model that has a high \(R^2\) value (a measure of how much variance is explained by predictors), low AIC and BIC values, and low root mean squared error (RMSE). Based on these criteria, we can immediately see that
model1 has the best fit.
If you don’t like looking at tables, you can also plot them using a plotting method supported in
For more, see: https://easystats.github.io/see/articles/performance.html
While comparing these indices is often useful, making a decision (for instance, which model to keep or drop) can often be hard, as the indices can give conflicting suggestions. Additionally, it is sometimes unclear which index to favour in the given context.
This is one of the reason why tests are useful, as they facilitate decisions via (infamous) “significance” indices, like p-values (in frequentist framework) or Bayes Factors (in Bayesian framework).
|Name||Model||BF||Omega2||p (Omega2)||LR||p (LR)|
|model2||lm||< 0.001||0.19||< .001||4.57||< .001|
|model3||lm||< 0.001||0.56||< .001||11.52||< .001|
Each model is compared to model1.
However, these tests also have strong limitations and shortcomings, and cannot be used as the one criterion to rule them all!
You can find more information on how these tests here.
Although we have shown here examples only with simple linear models, we will highly encourage you to try these functions out with models of your choosing. For example, these functions work with mixed-effects regression models, Bayesian regression models, etc.
To demonstrate this, we will run Bayesian versions of linear regression models we just compared:
Note that, since these are Bayesian regression models, the function automatically picked up the appropriate indices to compare!
If you are unfamiliar with some of these, explore more here.
Now it’s your turn to play! :)