{"id":13689591,"url":"https://github.com/easystats/insight","last_synced_at":"2026-02-04T11:44:41.629Z","repository":{"id":34160919,"uuid":"168224077","full_name":"easystats/insight","owner":"easystats","description":":crystal_ball: Easy access to model information for various model objects","archived":false,"fork":false,"pushed_at":"2024-04-10T12:45:56.000Z","size":41798,"stargazers_count":367,"open_issues_count":59,"forks_count":38,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-04-13T21:52:21.528Z","etag":null,"topics":["easystats","hacktoberfest","insight","models","names","predictors","r","random","rstats"],"latest_commit_sha":null,"homepage":"https://easystats.github.io/insight/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/easystats.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"easystats"}},"created_at":"2019-01-29T20:32:45.000Z","updated_at":"2024-04-15T08:29:11.729Z","dependencies_parsed_at":"2023-10-29T09:23:33.006Z","dependency_job_id":"99a0efaa-8dfa-4137-b144-c9778bd21a73","html_url":"https://github.com/easystats/insight","commit_stats":{"total_commits":4368,"total_committers":27,"mean_commits":"161.77777777777777","dds":"0.16369047619047616","last_synced_commit":"dfecd01af066e5b5cfee59b424a72ba35546236d"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easystats%2Finsight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easystats%2Finsight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easystats%2Finsight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easystats%2Finsight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/easystats","download_url":"https://codeload.github.com/easystats/insight/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247809962,"owners_count":20999816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["easystats","hacktoberfest","insight","models","names","predictors","r","random","rstats"],"created_at":"2024-08-02T15:01:54.824Z","updated_at":"2025-10-04T20:29:47.751Z","avatar_url":"https://github.com/easystats.png","language":"R","readme":"---\noutput: github_document\n---\n\n```{r, warning=FALSE, message=FALSE, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  warning = FALSE,\n  message = FALSE,\n  fig.path = \"README-\",\n  comment = \"#\u003e\"\n)\n\noptions(knitr.kable.NA = \"\", digits = 2, width = 80)\n```\n\n# insight \u003cimg src='man/figures/logo.png' align=\"right\" height=\"139\" /\u003e\n\n[![DOI](https://joss.theoj.org/papers/10.21105/joss.01412/status.svg)](https://doi.org/10.21105/joss.01412)\n[![downloads](https://cranlogs.r-pkg.org/badges/insight)](https://cranlogs.r-pkg.org/) [![total](https://cranlogs.r-pkg.org/badges/grand-total/insight)](https://cranlogs.r-pkg.org/)\n\n**Gain insight into your models!**\n\nWhen fitting any statistical model, there are many useful pieces of information that are simultaneously calculated and stored beyond coefficient estimates and general model fit statistics. Although there exist some generic functions to obtain model information and data, many package-specific modelling functions do not provide such methods to allow users to access such valuable information.\n\n**insight** is an R-package that fills this important gap by providing a suite of functions to support almost any model (see a list of the many models supported below in the **List of Supported Packages and Models** section). The goal of **insight**, then, is to provide tools to provide *easy*, *intuitive*, and *consistent* access to information contained in model objects. These tools aid applied research in virtually any field who fit, diagnose, and present statistical models by streamlining access to every aspect of many model objects via consistent syntax and output.\n\n## Installation\n\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/insight)](https://cran.r-project.org/package=insight) [![insight status badge](https://easystats.r-universe.dev/badges/insight)](https://easystats.r-universe.dev) [![codecov](https://codecov.io/gh/easystats/insight/branch/main/graph/badge.svg)](https://app.codecov.io/gh/easystats/insight)\n\nThe *insight* package is available on CRAN, while its latest development version is available on R-universe (from _rOpenSci_) or GitHub.\n\nType | Source | Command\n---|---|---\nRelease | CRAN | `install.packages(\"insight\")`\nDevelopment | r-universe | `install.packages(\"insight\", repos = \"https://easystats.r-universe.dev\")`\nDevelopment | GitHub | `remotes::install_github(\"easystats/insight\")`\n\nOnce you have downloaded the package, you can then load it using:\n\n```{r, eval=FALSE}\nlibrary(\"insight\")\n```\n\n\u003e **Tip**\n\u003e\n\u003e Instead of `library(insight)`, use `library(easystats)`. This will make all features of the  easystats-ecosystem available.\n\u003e\n\u003e To stay updated, use `easystats::install_latest()`.\n\n## Documentation\n\n[![Documentation](https://img.shields.io/badge/documentation-insight-orange.svg?colorB=E91E63)](https://easystats.github.io/insight/)\n[![Blog](https://img.shields.io/badge/blog-easystats-orange.svg?colorB=FF9800)](https://easystats.github.io/blog/posts/)\n[![Features](https://img.shields.io/badge/features-insight-orange.svg?colorB=2196F3)](https://easystats.github.io/insight/reference/index.html)\n\nBuilt with non-programmers in mind, **insight** offers a broad toolbox for making model and data information easily accessible. While **insight** offers many useful functions for working with and understanding model objects (discussed below), we suggest users start with `model_info()`, as this function provides a clean and consistent overview of model objects (e.g., functional form of the model, the model family, link function, number of observations, variables included in the specification, etc.). With a clear understanding of the model introduced, users are able to adapt other functions for more nuanced exploration of and interaction with virtually any model object.Please visit [https://easystats.github.io/insight/](https://easystats.github.io/insight/) for documentation.\n\n### Definition of Model Components\n\nThe functions from **insight** address different components of a model. In an effort to avoid confusion about specific \"targets\" of each function, in this section we provide a short explanation of **insight**'s definitions of regression model components.\n\n#### Data\n\nThe dataset used to fit the model.\n\n#### Parameters\n\nValues estimated or learned from data that capture the relationship between variables. In regression models, these are usually referred to as *coefficients*.\n\n#### Response and Predictors\n\n* **response**: the outcome or response variable (dependent variable) of a regression model.\n* **predictor**: independent variables of (the _fixed_ part of) a regression model. For mixed models, variables that are only in the _random effects_ part (i.e. grouping factors) of the model are not returned as predictors by default. However, these can be included using additional arguments in the function call, treating predictors are \"unique\". As such, if a variable appears as a fixed effect and a random slope, it is treated as one (the same) predictor.\n\n#### Variables\n\nAny unique variable names that appear in a regression model, e.g., response variable, predictors or random effects. A \"variable\" only relates to the unique occurence of a term, or the term name. For instance, the expression `x + poly(x, 2)` has only the variable `x`.\n\n#### Terms\n\nTerms themselves consist of variable and factor names separated by operators, or involve arithmetic expressions. For instance, the expression `x + poly(x, 2)` has _one_ variable `x`, but _two_ terms `x` and `poly(x, 2)`.\n\n#### Random Effects\n\n* **random slopes**: variables that are specified as random slopes in a mixed effects model.\n* **random or grouping factors**: variables that are specified as grouping variables in a mixed effects model.\n\n*Aren't the predictors, terms and parameters the same thing?*\n\nIn some cases, yes. But not in all cases. Find out more by [**clicking here to access the documentation**](https://easystats.github.io/insight/articles/insight.html).\n\n### Functions\n\nThe package revolves around two key prefixes: `get_*` and `find_*`. The `get_*` prefix extracts *values* (or *data*) associated with model-specific objects (e.g., parameters or variables), while the `find_*` prefix *lists* model-specific objects (e.g., priors or predictors). These are powerful families of functions allowing for great flexibility in use, whether at a high, descriptive level (`find_*`) or narrower level of statistical inspection and reporting (`get_*`).\n\n![](https://raw.githubusercontent.com/easystats/insight/master/paper/figure1_small.png)\n\nIn total, the **insight** package includes 16 core functions: [get_data()](https://easystats.github.io/insight/reference/get_data.html), [get_priors()](https://easystats.github.io/insight/reference/get_priors.html), [get_variance()](https://easystats.github.io/insight/reference/get_variance.html), [get_parameters()](https://easystats.github.io/insight/reference/get_parameters.html), [get_predictors()](https://easystats.github.io/insight/reference/get_predictors.html), [get_random()](https://easystats.github.io/insight/reference/get_random.html), [get_response()](https://easystats.github.io/insight/reference/get_response.html), [find_algorithm()](https://easystats.github.io/insight/reference/find_algorithm.html), [find_formula()](https://easystats.github.io/insight/reference/find_formula.html), [find_variables()](https://easystats.github.io/insight/reference/find_variables.html), [find_terms()](https://easystats.github.io/insight/reference/find_terms.html), [find_parameters()](https://easystats.github.io/insight/reference/find_parameters.html), [find_predictors()](https://easystats.github.io/insight/reference/find_predictors.html), [find_random()](https://easystats.github.io/insight/reference/find_random.html), [find_response()](https://easystats.github.io/insight/reference/find_response.html), and [model_info()](https://easystats.github.io/insight/reference/model_info.html). In all cases, users must supply at a minimum, the name of the model fit object. In several functions, there are additional arguments that allow for more targeted returns of model information. For example, the `find_terms()` function's `effects` argument allows for the extraction of \"fixed effects\" terms, \"random effects\" terms, or by default, \"all\" terms in the model object. We point users to the package documentation or the complementary package website, \u003chttps://easystats.github.io/insight/\u003e, for a detailed list of the arguments associated with each function as well as the returned values from each function.\n\n### Examples of Use Cases in R\n\nWe now would like to provide examples of use cases of the **insight** package. These examples probably do not cover typical real-world problems, but serve as illustration of the core idea of this package: The unified interface to access model information. **insight** should help both users and package developers in order to reduce the hassle with the many exceptions from various modelling packages when accessing model information.\n\n#### Making Predictions at Specific Values of a Term of Interest\n\nSay, the goal is to make predictions for a certain term, holding remaining co-variates constant. This is  achieved by calling `predict()` and feeding the `newdata`-argument with the values of the term of interest as well as the \"constant\" values for remaining co-variates. The functions `get_data()` and `find_predictors()` are used to get this information, which then can be used in the call to `predict()`.\n\nIn this example, we fit a simple linear model, but it could be replaced by (m)any other models, so this approach is \"universal\" and applies to many different model objects.\n\n```{r}\nlibrary(insight)\nm \u003c- lm(\n  Sepal.Length ~ Species + Petal.Width + Sepal.Width,\n  data = iris\n)\n\ndat \u003c- get_data(m)\npred \u003c- find_predictors(m, flatten = TRUE)\n\nl \u003c- lapply(pred, function(x) {\n  if (is.numeric(dat[[x]])) {\n    mean(dat[[x]])\n  } else {\n    unique(dat[[x]])\n  }\n})\n\nnames(l) \u003c- pred\nl \u003c- as.data.frame(l)\n\ncbind(l, predictions = predict(m, newdata = l))\n```\n\n#### Printing Model Coefficients\n\nThe next example should emphasize the possibilities to generalize functions to many different model objects using **insight**. The aim is simply to print coefficients in a complete, human readable sentence.\n\nThe first approach uses the functions that are available for some, but obviously not for all models, to access the information about model coefficients.\n\n```{r}\nprint_params \u003c- function(model) {\n  paste0(\n    \"My parameters are \",\n    toString(row.names(summary(model)$coefficients)),\n    \", thank you for your attention!\"\n  )\n}\n\nm1 \u003c- lm(Sepal.Length ~ Petal.Width, data = iris)\nprint_params(m1)\n\n# obviously, something is missing in the output\nm2 \u003c- mgcv::gam(Sepal.Length ~ Petal.Width + s(Petal.Length), data = iris)\nprint_params(m2)\n```\n\nAs we can see, the function fails for *gam*-models. As the access to models depends on the type of the model in the R ecosystem, we would need to create specific functions for all models types. With **insight**, users can write a function without having to worry about the model type.\n\n```{r}\nprint_params \u003c- function(model) {\n  paste0(\n    \"My parameters are \",\n    toString(insight::find_parameters(model, flatten = TRUE)),\n    \", thank you for your attention!\"\n  )\n}\n\nm1 \u003c- lm(Sepal.Length ~ Petal.Width, data = iris)\nprint_params(m1)\n\nm2 \u003c- mgcv::gam(Sepal.Length ~ Petal.Width + s(Petal.Length), data = iris)\nprint_params(m2)\n```\n\n\n\n## Contributing and Support\n\nIn case you want to file an issue or contribute in another way to the package, please follow [this guide](https://github.com/easystats/insight/blob/master/.github/CONTRIBUTING.md). For questions about the functionality, you may either contact us via email or also file an issue.\n\n## List of Supported Models by Class\n\nCurrently, about `r length(supported_models())` model classes are supported.\n\n```{r, warning=FALSE, message=FALSE, eval=TRUE}\nsupported_models()\n```\n\n- **Didn't find a model?** [File an issue](https://github.com/easystats/insight/issues) and request additional model-support in _insight_!\n\n\n## Citation\n\nIf this package helped you, please consider citing as follows:\n\nLüdecke D, Waggoner P, Makowski D. insight: A Unified Interface to Access Information from Model Objects in R. Journal of Open Source Software 2019;4:1412. doi: [10.21105/joss.01412](https://doi.org/10.21105/joss.01412)\n\n## Code of Conduct\n\nPlease note that the insight project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.\n","funding_links":["https://github.com/sponsors/easystats"],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasystats%2Finsight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feasystats%2Finsight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasystats%2Finsight/lists"}