{"id":17122087,"url":"https://github.com/gavinsimpson/gratia","last_synced_at":"2025-05-15T13:08:47.778Z","repository":{"id":37396548,"uuid":"145020858","full_name":"gavinsimpson/gratia","owner":"gavinsimpson","description":"ggplot-based graphics and useful functions for GAMs fitted using the mgcv package","archived":false,"fork":false,"pushed_at":"2025-05-04T15:08:13.000Z","size":322794,"stargazers_count":218,"open_issues_count":76,"forks_count":31,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-14T02:47:17.515Z","etag":null,"topics":["distributional-regression","gam","gamm","generalized-additive-mixed-models","generalized-additive-models","ggplot2","glm","lm","mgcv","penalized-spline","r","r-package","random-effects","smoothing","splines"],"latest_commit_sha":null,"homepage":"https://gavinsimpson.github.io/gratia/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gavinsimpson.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-08-16T17:42:14.000Z","updated_at":"2025-05-04T15:05:05.000Z","dependencies_parsed_at":"2023-02-15T18:01:45.462Z","dependency_job_id":"d6e9fbdb-2be7-4d04-a18a-5e5c2fc48b4d","html_url":"https://github.com/gavinsimpson/gratia","commit_stats":{"total_commits":2168,"total_committers":23,"mean_commits":94.26086956521739,"dds":"0.016143911439114422","last_synced_commit":"e3cd0fb69d0340ebb573710061660e84c8184374"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinsimpson%2Fgratia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinsimpson%2Fgratia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinsimpson%2Fgratia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinsimpson%2Fgratia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gavinsimpson","download_url":"https://codeload.github.com/gavinsimpson/gratia/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254346624,"owners_count":22055808,"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":["distributional-regression","gam","gamm","generalized-additive-mixed-models","generalized-additive-models","ggplot2","glm","lm","mgcv","penalized-spline","r","r-package","random-effects","smoothing","splines"],"created_at":"2024-10-14T18:06:28.846Z","updated_at":"2025-05-15T13:08:42.765Z","avatar_url":"https://github.com/gavinsimpson.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\noptions(tibble.print_min = 5, tibble.print_max = 5)\nlibrary(\"mgcv\")\nlibrary(\"gratia\")\n```\n\n# gratia\n\n\u003c!-- badges: start --\u003e\n[![R build status](https://github.com/gavinsimpson/gratia/workflows/R-CMD-check/badge.svg)](https://github.com/gavinsimpson/gratia/actions)\n[![codecov](https://codecov.io/gh/gavinsimpson/gratia/branch/main/graph/badge.svg?token=GG5NQfgRFu)](https://app.codecov.io/gh/gavinsimpson/gratia)\n[![CRAN\\_Status\\_Badge](https://www.r-pkg.org/badges/version/gratia)](https://cran.r-project.org/package=gratia)\n[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/gratia)](https://cran.r-project.org/package=gratia)\n[![DOI](https://joss.theoj.org/papers/10.21105/joss.06962/status.svg)](https://doi.org/10.21105/joss.06962)\n\u003c!-- badges: end --\u003e\n\n## Overview\n\nWorking with GAMs within the 'tidyverse' can be tedious and even difficult\nwithout a good understanding of GAMs themselves and how the model is returned\nby 'mgcv' and what the model objects contain. 'gratia' is designed to help with\nthis.\n\n'gratia' provides 'ggplot'-based graphics and utility functions for working with\ngeneralized additive models (GAMs) fitted using the 'mgcv' package, via a\nreimplementation of the `plot()` method for GAMs that 'mgcv' provides, as well\nas 'tidyverse' compatible representations of estimated smooths.\n\n## Features\n\n```{r draw-gam-figure, dev = \"png\", fig.height = 6, fig.width = 9, dpi = 120, echo = FALSE, fig.show = \"hide\", message = FALSE}\ndf1 \u003c- data_sim(\"eg1\", n = 400, seed = 42)\nm1 \u003c- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = df1, method = \"REML\")\ndraw(m1, residuals = TRUE)\n```\n\n```{r draw-gam-figure-2d, dev = \"png\", fig.height = 6, fig.width = 9, dpi = 120, echo = FALSE, fig.show = \"hide\", message = FALSE}\ndf2 \u003c- data_sim(\"eg2\", n = 1000, seed = 42)\nm2 \u003c- gam(y ~ s(x, z), data = df2, method = \"REML\")\ndraw(m2)\n```\n\n```{r appraise-figure, dev = \"png\", fig.height = 6, fig.width = 9, dpi = 120, echo = FALSE, fig.show = \"hide\"}\nappraise(m1)\n```\n\nThe main features of *gratia* are currently\n\n* A *ggplot2*-based replacement for `mgcv:::plot.gam()`: `draw.gam()`.\n\n  For example, the classic four term additive example from Gu \u0026 Wahba:\n\t\n  ![Estimated smooths from a GAM](man/figures/README-draw-gam-figure-1.png)\n\n  Or for a bivariate smooth:\n    \n  ![Estimated smooths from a GAM](man/figures/README-draw-gam-figure-2d-1.png)\n\n  Note that some specialist smoothers (`bs %in% c(\"mrf\",\"sw\", \"sf\")`) are not\n  currently supported, but univariate, *factor* and *continuous* `by`-variable\n  smooths, simple random effect smooths (`bs = 're'`), factor-smooth\n  interaction smooths (`bs = \"fs\"`), constrained factor smooths (`bs = \"sz\"`),\n  full soap film smooths (`bs = \"so\"`), and bivariate, trivariate, and\n  quadvariate TPRS and tensor product smooths are supported,\n\n* Estimation of derivatives of fitted smoothers: `derivatives()`,\n\n* Estimation of point-wise across-the-function confidence intervals and\n  simultaneous intervals for smooths: `confint.gam()`.\n\n* Model diagnostics via `appraise()`\n\n  ![Model diagnostics figure](man/figures/README-appraise-figure-1.png)\n\n## Installing *gratia*\n\n*gratia* is now available on CRAN, and can be installed with\n\n```{r install, eval = FALSE}\ninstall.packages(\"gratia\")\n```\n\nhowever *gratia* is under active development and you may wish to install the\ndevelopment version from github. The easiest way to do this is via the\n`install_github()` function from package *remotes*. Make sure you have\n*remotes* installed, then run\n\n```{r install-github, eval = FALSE}\nremotes::install_github(\"gavinsimpson/gratia\")\n```\n\nto install the package. Alternatively, binary packages of the development\nversion are available from rOpenSci's R Universe service:\n\n```{r install-r-universe, eval = FALSE}\n# Install gratia in R\ninstall.packages(\"gratia\", repos = c(\n  \"https://gavinsimpson.r-universe.dev\",\n  \"https://cloud.r-project.org\"\n))\n```\n\n## History\n\n*gratia* grew out of an earlier package, *schoenberg*, itself a development of\nthe earlier package *tsgam*, which was originally intended to be used with GAMs\nfitted to time series. As I was developing *tsgam* however it became clear that\nthe package could be used more generally and that the name \"tsgam\" was no longer\nappropriate. To avoid breaking blog posts I had written using *tsgam* I decided\nto copy the git repo and all the history to a new repo for the package under the\nname *schoenberg*. At a later date someone released another package called\n*schoenberg* to CRAN, so that scuppered that idea. Now I'm calling the package\n*gratia*. Hopefully I won't have to change it again\u0026hellip;\n\n## Why *gratia*?\n\nIn naming his [*greta*](https://github.com/greta-dev/greta) package, Nick\nGolding observed the recent phenomena of naming statistical modelling software,\nsuch as Stan or Edward, after individuals that played a prominent role in the\ndevelopment of the field. This lead Nick to name his Tensor Flow-based package\n*greta* after [*Grete Hermann*](https://greta-stats.org/articles/webpages/why_greta.html).\n\nIn the same spirit, *gratia* is named in recognition of the contributions of\n[Grace Wahba](https://en.wikipedia.org/wiki/Grace_Wahba), who did pioneering\nwork on the penalised spline models that are at the foundation of the way GAMs\nare estimated in *mgcv*. I wanted to name the package *grace*, to explicitly\nrecognise Grace's contributions, but unfortunately there was already a package\nnamed *Grace* on CRAN. So I looked elsewhere for inspiration.\n\nThe English word \"grace\" derives from the Latin *gratia*, meaning \"favor, charm,\nthanks\" ([according to Merriam Webster](https://www.merriam-webster.com/dictionary/grace)).\n\nThe chair that Grace Wabha currently holds is named after \n[Isaac J Schoenberg](https://en.wikipedia.org/wiki/Isaac_Jacob_Schoenberg), a\nformer University Madison-Wisconsin Professor of Mathematics, who in a 1946\npaper provided the first mathematical reference to \"splines\". (Hence the\nprevious name for the package.)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgavinsimpson%2Fgratia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgavinsimpson%2Fgratia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgavinsimpson%2Fgratia/lists"}