insight

insight: A Unified Interface to Access Information from Model Objects in R - Published in JOSS (2019)

https://github.com/easystats/insight

Science Score: 93.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 7 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

easystats hacktoberfest insight models names predictors r random rstats

Keywords from Contributors

standardization correlation predict r2 mixed-models loo aic bayes-factors visualisation marginal-effects

Scientific Fields

Economics Social Sciences - 40% confidence
Engineering Computer Science - 40% confidence
Last synced: 4 months ago · JSON representation

Repository

:crystal_ball: Easy access to model information for various model objects

Basic Info
Statistics
  • Stars: 422
  • Watchers: 9
  • Forks: 40
  • Open Issues: 57
  • Releases: 37
Topics
easystats hacktoberfest insight models names predictors r random rstats
Created almost 7 years ago · Last pushed 4 months ago
Metadata Files
Readme Changelog Contributing Funding License Code of conduct Support

README.Rmd

---
output: github_document
---

```{r, warning=FALSE, message=FALSE, echo = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  warning = FALSE,
  message = FALSE,
  fig.path = "README-",
  comment = "#>"
)

options(knitr.kable.NA = "", digits = 2, width = 80)
```

# insight 

[![DOI](https://joss.theoj.org/papers/10.21105/joss.01412/status.svg)](https://doi.org/10.21105/joss.01412)
[![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/)

**Gain insight into your models!**

When 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.

**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.

## Installation

[![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)

The *insight* package is available on CRAN, while its latest development version is available on R-universe (from _rOpenSci_) or GitHub.

Type | Source | Command
---|---|---
Release | CRAN | `install.packages("insight")`
Development | r-universe | `install.packages("insight", repos = "https://easystats.r-universe.dev")`
Development | GitHub | `remotes::install_github("easystats/insight")`

Once you have downloaded the package, you can then load it using:

```{r, eval=FALSE}
library("insight")
```

> **Tip**
>
> Instead of `library(insight)`, use `library(easystats)`. This will make all features of the  easystats-ecosystem available.
>
> To stay updated, use `easystats::install_latest()`.

## Documentation

[![Documentation](https://img.shields.io/badge/documentation-insight-orange.svg?colorB=E91E63)](https://easystats.github.io/insight/)
[![Blog](https://img.shields.io/badge/blog-easystats-orange.svg?colorB=FF9800)](https://easystats.github.io/blog/posts/)
[![Features](https://img.shields.io/badge/features-insight-orange.svg?colorB=2196F3)](https://easystats.github.io/insight/reference/index.html)

Built 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.

### Definition of Model Components

The 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.

#### Data

The dataset used to fit the model.

#### Parameters

Values estimated or learned from data that capture the relationship between variables. In regression models, these are usually referred to as *coefficients*.

#### Response and Predictors

* **response**: the outcome or response variable (dependent variable) of a regression model.
* **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.

#### Variables

Any 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`.

#### Terms

Terms 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)`.

#### Random Effects

* **random slopes**: variables that are specified as random slopes in a mixed effects model.
* **random or grouping factors**: variables that are specified as grouping variables in a mixed effects model.

*Aren't the predictors, terms and parameters the same thing?*

In 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).

### Functions

The 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_*`).

![](https://raw.githubusercontent.com/easystats/insight/master/paper/figure1_small.png)

In 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, , for a detailed list of the arguments associated with each function as well as the returned values from each function.

### Examples of Use Cases in R

We 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.

#### Making Predictions at Specific Values of a Term of Interest

Say, 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()`.

In 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.

```{r}
library(insight)
m <- lm(
  Sepal.Length ~ Species + Petal.Width + Sepal.Width,
  data = iris
)

dat <- get_data(m)
pred <- find_predictors(m, flatten = TRUE)

l <- lapply(pred, function(x) {
  if (is.numeric(dat[[x]])) {
    mean(dat[[x]])
  } else {
    unique(dat[[x]])
  }
})

names(l) <- pred
l <- as.data.frame(l)

cbind(l, predictions = predict(m, newdata = l))
```

#### Printing Model Coefficients

The 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.

The first approach uses the functions that are available for some, but obviously not for all models, to access the information about model coefficients.

```{r}
print_params <- function(model) {
  paste0(
    "My parameters are ",
    toString(row.names(summary(model)$coefficients)),
    ", thank you for your attention!"
  )
}

m1 <- lm(Sepal.Length ~ Petal.Width, data = iris)
print_params(m1)

# obviously, something is missing in the output
m2 <- mgcv::gam(Sepal.Length ~ Petal.Width + s(Petal.Length), data = iris)
print_params(m2)
```

As 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.

```{r}
print_params <- function(model) {
  paste0(
    "My parameters are ",
    toString(insight::find_parameters(model, flatten = TRUE)),
    ", thank you for your attention!"
  )
}

m1 <- lm(Sepal.Length ~ Petal.Width, data = iris)
print_params(m1)

m2 <- mgcv::gam(Sepal.Length ~ Petal.Width + s(Petal.Length), data = iris)
print_params(m2)
```



## Contributing and Support

In 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.

## List of Supported Models by Class

Currently, about `r length(supported_models())` model classes are supported.

```{r, warning=FALSE, message=FALSE, eval=TRUE}
supported_models()
```

- **Didn't find a model?** [File an issue](https://github.com/easystats/insight/issues) and request additional model-support in _insight_!


## Citation

If this package helped you, please consider citing as follows:

Lü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)

## Code of Conduct

Please 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.

Owner

  • Name: easystats
  • Login: easystats
  • Kind: organization
  • Location: worldwide

Make R stats easy!

JOSS Publication

insight: A Unified Interface to Access Information from Model Objects in R
Published
June 25, 2019
Volume 4, Issue 38, Page 1412
Authors
Daniel Lüdecke ORCID
University Medical Center Hamburg-Eppendorf, Germany
Philip D. Waggoner ORCID
College of William & Mary, Virginia, U.S.
Dominique Makowski ORCID
Nanyang Technological University, Singapore
Editor
Karthik Ram ORCID
Tags
model information regression models

Papers & Mentions

Total mentions: 6

Accelerative effect of topical <i>Zataria multiflora</i> essential oil against infected wound model by modulating inflammation, angiogenesis, and collagen biosynthesis
Last synced: 3 months ago
Inter- and intraspecific diversity of food legumes among households and communities in Ethiopia
Last synced: 3 months ago
From morphology to biochemical state – intravital multiphoton fluorescence lifetime imaging of inflamed human skin
Last synced: 3 months ago
What Are the Reasons for the Different COVID-19 Situations in Different Cities of China? A Study from the Perspective of Population Migration
Last synced: 3 months ago
Nightly torpor use in response to weather conditions and individual state in an insectivorous bat
Last synced: 3 months ago
Metaphyseal anchoring short stem hip arthroplasty provides a more physiological load transfer: a comparative finite element analysis study
Last synced: 3 months ago

GitHub Events

Total
  • Create event: 105
  • Release event: 6
  • Issues event: 121
  • Watch event: 23
  • Delete event: 105
  • Issue comment event: 293
  • Push event: 1,004
  • Pull request review comment event: 44
  • Pull request review event: 59
  • Pull request event: 221
  • Fork event: 1
Last Year
  • Create event: 105
  • Release event: 6
  • Issues event: 121
  • Watch event: 23
  • Delete event: 105
  • Issue comment event: 293
  • Push event: 1,004
  • Pull request review comment event: 44
  • Pull request review event: 59
  • Pull request event: 221
  • Fork event: 1

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 4,744
  • Total Committers: 20
  • Avg Commits per committer: 237.2
  • Development Distribution Score (DDS): 0.154
Past Year
  • Commits: 272
  • Committers: 5
  • Avg Commits per committer: 54.4
  • Development Distribution Score (DDS): 0.04
Top Committers
Name Email Commits
Daniel m****l@d****e 4,013
Indrajeet Patil p****e@g****m 216
Dominique Makowski d****9@g****m 210
Vincent Arel-Bundock v****k@u****a 151
mattansb 3****b 56
Brenton M. Wiernik b****k 37
Etienne Bacher 5****r 22
Philip Waggoner 3****r 11
etiennebacher y****u@e****m 6
Rémi Thériault 1****c 6
Grant McDermott g****t@g****m 5
Iago i****o@d****e 2
Milan Bouchet-Valat n****n@c****r 2
Alex Reinhart a****x@r****m 1
Ben Bolker b****r@g****m 1
Boyd Tarlinton b****n@o****m 1
Fernando Miguez f****z@g****m 1
Guido Biele g****e@g****m 1
Matthias Grenié m****e@e****r 1
hhp94 5****4 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 169
  • Total pull requests: 442
  • Average time to close issues: 5 months
  • Average time to close pull requests: 5 days
  • Total issue authors: 56
  • Total pull request authors: 15
  • Average comments per issue: 3.43
  • Average comments per pull request: 1.36
  • Merged pull requests: 378
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 61
  • Pull requests: 231
  • Average time to close issues: 5 days
  • Average time to close pull requests: about 22 hours
  • Issue authors: 21
  • Pull request authors: 5
  • Average comments per issue: 1.87
  • Average comments per pull request: 1.13
  • Merged pull requests: 191
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • strengejacke (30)
  • vincentarelbundock (20)
  • DominiqueMakowski (19)
  • IndrajeetPatil (17)
  • mattansb (9)
  • matschmitz (7)
  • profandyfield (5)
  • bwiernik (5)
  • JoakimStefansson (4)
  • iago-pssjd (3)
  • rempsyc (3)
  • bbolker (2)
  • Sandhu-SS (2)
  • nahorp (1)
  • devincaughey (1)
Pull Request Authors
  • strengejacke (384)
  • vincentarelbundock (17)
  • etiennebacher (8)
  • IndrajeetPatil (7)
  • mattansb (7)
  • DominiqueMakowski (6)
  • bbolker (2)
  • bwiernik (2)
  • B0ydT (2)
  • rempsyc (2)
  • github-actions[bot] (1)
  • ianhussey (1)
  • capnrefsmmat (1)
  • nalimilan (1)
  • hhp94 (1)
Top Labels
Issue Labels
3 investigators :grey_question::question: (27) bug :bug: (19) Bug :bug: (15) enhancement :boom: (13) get_variance (11) Enhancement :boom: (9) low priority :sleeping: (6) new models :alien: (6) get_predicted (5) Consistency :green_apple: :apple: (5) Low priority :sleeping: (4) Docs :books: (4) feature idea :fire: (3) Question :interrobang: (3) wontfix :no_entry_sign: (2) help us :eyes: (2) breaking 🏴‍☠️ (2) waiting for response :love_letter: (2) high priority :runner: (2) New models :alien: (2) Reprex :bar_chart: (2) consistency :green_apple: :apple: (2) What's your opinion :hear_no_evil: (1) reprex :bar_chart: (1) Invalid :x: (1) High priority :runner: (1) Help us :eyes: (1) Feature idea :fire: (1) what's your opinion :hear_no_evil: (1) WIP :hourglass_flowing_sand: (1)
Pull Request Labels
enhancement :boom: (1) bug :bug: (1) auto-update (1) 3 investigators :grey_question::question: (1)

Packages

  • Total packages: 3
  • Total downloads:
    • cran 151,000 last-month
  • Total docker downloads: 49,888
  • Total dependent packages: 59
    (may contain duplicates)
  • Total dependent repositories: 84
    (may contain duplicates)
  • Total versions: 141
  • Total maintainers: 1
cran.r-project.org: insight

Easy Access to Model Information for Various Model Objects

  • Versions: 72
  • Dependent Packages: 41
  • Dependent Repositories: 81
  • Downloads: 151,000 Last month
  • Docker Downloads: 49,888
Rankings
Downloads: 1.0%
Stargazers count: 1.1%
Dependent packages count: 2.1%
Forks count: 2.2%
Dependent repos count: 2.5%
Average: 4.8%
Docker downloads count: 19.8%
Maintainers (1)
Last synced: 4 months ago
proxy.golang.org: github.com/easystats/insight
  • Versions: 27
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 4 months ago
conda-forge.org: r-insight
  • Versions: 42
  • Dependent Packages: 18
  • Dependent Repositories: 3
Rankings
Dependent packages count: 3.5%
Dependent repos count: 17.9%
Average: 18.4%
Stargazers count: 21.2%
Forks count: 30.9%
Last synced: 4 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.5 depends
  • methods * imports
  • stats * imports
  • utils * imports
  • AER * suggests
  • BayesFactor * suggests
  • GLMMadaptive * suggests
  • JM * suggests
  • MASS * suggests
  • MCMCglmm * suggests
  • Matrix * suggests
  • TMB * suggests
  • VGAM * suggests
  • afex * suggests
  • aod * suggests
  • bayestestR * suggests
  • bbmle * suggests
  • bdsmatrix * suggests
  • betareg * suggests
  • bife * suggests
  • biglm * suggests
  • blavaan * suggests
  • blme * suggests
  • boot * suggests
  • brms * suggests
  • censReg * suggests
  • cgam * suggests
  • clubSandwich * suggests
  • coxme * suggests
  • cplm * suggests
  • crch * suggests
  • datawizard * suggests
  • effectsize * suggests
  • emmeans * suggests
  • epiR * suggests
  • estimatr * suggests
  • feisr * suggests
  • fixest * suggests
  • fungible * suggests
  • gam * suggests
  • gamlss * suggests
  • gamm4 * suggests
  • gbm * suggests
  • gee * suggests
  • geepack * suggests
  • geoR * suggests
  • glmmTMB * suggests
  • gmnl * suggests
  • gt * suggests
  • httr * suggests
  • ivreg * suggests
  • knitr * suggests
  • lavaSearch2 * suggests
  • lavaan * suggests
  • lfe * suggests
  • lme4 * suggests
  • lmerTest * suggests
  • lmtest * suggests
  • logistf * suggests
  • logitr * suggests
  • marginaleffects * suggests
  • mclogit * suggests
  • mclust * suggests
  • merTools * suggests
  • metaBMA * suggests
  • mgcv * suggests
  • mhurdle * suggests
  • mice * suggests
  • mlogit * suggests
  • mmrm * suggests
  • multgee * suggests
  • nlme * suggests
  • nnet * suggests
  • nonnest2 * suggests
  • ordinal * suggests
  • panelr * suggests
  • parameters * suggests
  • parsnip * suggests
  • pbkrtest * suggests
  • performance * suggests
  • plm * suggests
  • poorman * suggests
  • pscl * suggests
  • psych * suggests
  • quantreg * suggests
  • rmarkdown * suggests
  • rms * suggests
  • robustbase * suggests
  • robustlmm * suggests
  • rstanarm >= 2.21.1 suggests
  • rstantools * suggests
  • rstudioapi * suggests
  • sandwich * suggests
  • speedglm * suggests
  • splines * suggests
  • statmod * suggests
  • survey * suggests
  • survival * suggests
  • testthat * suggests
  • truncreg * suggests
  • tweedie * suggests
.github/workflows/R-CMD-check-devel-easystats.yaml actions
.github/workflows/R-CMD-check-hard.yaml actions
.github/workflows/R-CMD-check-strict.yaml actions
.github/workflows/R-CMD-check.yaml actions
.github/workflows/check-all-examples.yaml actions
.github/workflows/check-link-rot.yaml actions
.github/workflows/check-random-test-order.yaml actions
.github/workflows/check-readme.yaml actions
.github/workflows/check-spelling.yaml actions
.github/workflows/check-styling.yaml actions
.github/workflows/check-test-warnings.yml actions
.github/workflows/check-vignette-warnings.yaml actions
.github/workflows/html-5-check.yaml actions
.github/workflows/lint-changed-files.yaml actions
.github/workflows/lint.yaml actions
.github/workflows/pkgdown-no-suggests.yaml actions
.github/workflows/pkgdown.yaml actions
.github/workflows/revdepcheck.yaml actions
.github/workflows/test-coverage.yaml actions
.github/workflows/update-to-latest-easystats.yaml actions