A unified syntax for accessing models’ information

[This article was first published on R on easystats, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The richness and variety of packages for building and fitting statistical models in R is absolutely astonishing and contributes to the language’s popularity. However, this diversity makes it hard for developpers that want to create tools that work with different types of models. Indeed, the way to access models’ internal information (such as parameters names, formulae, data, etc.) is not unified, forcing the developers to spend some time figuring out how to do it for each model type.

This time is over!

Insight

Recently, we have decided to collaborate around the new easystats project, a set of packages designed to make your life easier (currently very work in progress). However, in order to create these packages and functions, we needed a basis, a stable cornerstone, that would allow the unified way of accessing models information.

And insight was born.

The goal of insight is to provide tools to help an easy, intuitive and consistent accesss to information contained in various models. Indeed, although there are generic functions to get information and data from models, many modelling-functions from different packages do not provide such methods to access these information. The insight package aims at closing this gap by providing functions that work for (almost) any model.

insight can be installed as follows:

install.packages("insight")  # Install from CRAN
library(insight)  # Load the package

Example

Let’s see how it works on a very simple regression model:

model <- lm(Sepal.Length ~ Species, data=iris)
  • Find the parameters:
find_parameters(model)
> $conditional
> [1] "(Intercept)"       "Speciesversicolor" "Speciesvirginica"
  • Find the outcome’s name:
find_response(model)
> [1] "Sepal.Length"
  • Find the formula:
find_formula(model)
> $conditional
> Sepal.Length ~ Species
  • Find the variables in the formula:
find_variables(model)
> $response
> [1] "Sepal.Length"
> 
> $conditional
> [1] "Species"
  • Find the algorithm:
find_algorithm(model)
> $algorithm
> [1] "OLS"

Moreover, insight also includes functions to deal with Bayesian (get_priors()) and mixed models (find_random()).

insight works on a high number of models (see the list here), and continue to grow thanks to your suggestions! As easystats is a new project in active development, do not hesitate to contact us if you want to get involved 🙂

  • Check out our other blog posts here!

To leave a comment for the author, please follow the link and comment on their blog: R on easystats.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)