{"id":32370372,"url":"https://github.com/rvalavi/curves","last_synced_at":"2026-06-19T16:31:39.952Z","repository":{"id":281294362,"uuid":"944465408","full_name":"rvalavi/curves","owner":"rvalavi","description":"Generating response curves from any fitted model","archived":false,"fork":false,"pushed_at":"2026-05-05T22:44:17.000Z","size":8150,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-05-06T00:35:57.079Z","etag":null,"topics":["partial-dependence-plots","pdp","response-curves","spatial-modelling","species-distribution-modelling"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rvalavi.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-07T11:48:07.000Z","updated_at":"2026-05-05T22:44:21.000Z","dependencies_parsed_at":"2025-03-08T05:35:06.466Z","dependency_job_id":null,"html_url":"https://github.com/rvalavi/curves","commit_stats":null,"previous_names":["rvalavi/curvitude"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rvalavi/curves","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvalavi%2Fcurves","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvalavi%2Fcurves/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvalavi%2Fcurves/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvalavi%2Fcurves/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rvalavi","download_url":"https://codeload.github.com/rvalavi/curves/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvalavi%2Fcurves/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34539676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-19T02:00:06.005Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["partial-dependence-plots","pdp","response-curves","spatial-modelling","species-distribution-modelling"],"created_at":"2025-10-24T20:28:19.354Z","updated_at":"2026-06-19T16:31:39.934Z","avatar_url":"https://github.com/rvalavi.png","language":"R","funding_links":[],"categories":["Data and models"],"sub_categories":[],"readme":"# curves \u003cimg src=\"man/figures/logo.png\" align=\"right\" width=\"120\"/\u003e\n\n[![R build status](https://github.com/rvalavi/curves/workflows/R-CMD-check/badge.svg)](https://github.com/rvalavi/curves/actions)\n[![CRAN version](https://www.r-pkg.org/badges/version/curves)](https://CRAN.R-project.org/package=curves)\n\n**curves** is an experimental R package for plotting response curves from\nfitted models with **ggplot2**. The package is intentionally small and\nmodel-agnostic: supply a fitted model, predictor data, and, when needed, a\ncustom prediction function.\n\n\u003cimg src=\"man/figures/readme-univariate.png\" alt=\"Partial dependence curves from the species distribution vignette\" width=\"85%\" /\u003e\n\nThe figure above shows partial dependence curves from the included species\ndistribution vignette.\n\n## Current package scope\n\nThe current API is centred around five exported functions:\n\n- `univariate()` for one-predictor response curves with\n  `method = \"profile\"`, `\"pdp\"`, `\"ice\"`, `\"ice+pdp\"`, or `\"ale\"`.\n- `bivariate()` for two-predictor profile, PDP, or ALE surfaces as static\n  heatmaps, filled contours, or interactive 3D `plotly` surfaces.\n- `interactions()` for ranking numeric predictor pairs by the strength of\n  their centred second-order ALE interaction surfaces.\n- `multimodel()` for ensemble profile, PDP, or ALE curves across multiple\n  fitted models, with optional interval ribbons and member-model overlays.\n- `mapcurve()` for Shiny-based exploration that links a\n  prediction raster to response curves at clicked map cells.\n\nA few practical details are worth calling out:\n\n- Predictor inputs can be ordinary data frames or `terra::SpatRaster`\n  objects.\n- Numeric and factor predictors are supported. Univariate ALE summaries now\n  support both numeric and factor predictors, while bivariate ALE remains\n  limited to numeric predictor pairs.\n- If `predict()` returns multiple columns, `response` can be used to choose\n  the column to plot.\n- Static plots return `ggplot2` objects, so they can be styled or combined in\n  downstream workflows.\n\nIn short, profile curves use one reference row, PDP averages predictions over\nsampled rows, ICE keeps those row-level curves visible, and ALE accumulates\nlocal prediction differences within the observed predictor distribution.\n\n## Installation\n\nInstall the released version from CRAN:\n\n```r\ninstall.packages(\"curves\")\n```\n\nInstall the development version from GitHub:\n\n```r\ninstall.packages(\"remotes\")\nremotes::install_github(\"rvalavi/curves\")\n```\n\nOptional packages:\n\n- `terra` for raster-backed predictor inputs.\n- `plotly` for interactive 3D surfaces.\n- `mgcv` for the GAM ensemble example below.\n- `randomForest` and `disdat` for the species distribution vignette.\n\n## Quick start\n\n```r\nlibrary(curves)\n\nmodel \u003c- lm(\n  Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width,\n  data = iris\n)\n\npredictors \u003c- iris[, c(\"Sepal.Width\", \"Petal.Length\", \"Petal.Width\")]\n\n# Partial dependence curves (default)\nunivariate(model, predictors)\n\n# Single-profile response curves\nunivariate(\n  model,\n  predictors,\n  method = \"profile\"\n)\n\n# Accumulated local effects curves\nunivariate(model, predictors, method = \"ale\", n = 40)\n\n# Bivariate response surface\nbivariate(\n  model,\n  predictors,\n  pairs = c(\"Sepal.Width\", \"Petal.Length\"),\n  background_n = 50,\n  rug = TRUE,\n  plot_type = \"heatmap\"\n)\n\n# Rank pairwise ALE interactions\ninteractions(model, predictors, n = 10)\n\n# Plot only the strongest ALE surfaces\nbivariate(model, predictors, method = \"ale\", top_n = 3, n = 10)\n```\n\nFor ensemble modelling or repeated-fit comparisons, pass a list of fitted\nmodels to `multimodel()`. This is useful not only for formal ensembles, but\nalso for cross-validation folds, bootstrap or bagged refits, and models fit\nwith different background samples or closely related training sets. The models\nshould share compatible predictors, and their predictions should be on the\nsame response scale. If a set of models shares the same prediction interface,\npass non-default prediction arguments through `...`. For mixed model types,\nsupply `fun` as a list of wrappers, one per model. If a shared prediction\nfunction returns multiple prediction columns, either set `response` or provide\na small wrapper through `fun`. Use `agg`, `weights`, `interval`, and\n`show_models` to control how the model curves are combined and displayed.\n\n```r\nmodels \u003c- list(\n  lm(Sepal.Length ~ Sepal.Width + Petal.Length, data = iris),\n  mgcv::gam(Sepal.Length ~ s(Sepal.Width) + s(Petal.Length), data = iris)\n)\n\nmultimodel(\n  models,\n  predictors[, c(\"Sepal.Width\", \"Petal.Length\")],\n  background_n = 200,\n  show_models = TRUE\n)\n```\n\n## Species distribution vignette\n\nThe package includes a fuller\n[species distribution vignette](vignettes/random-forest-species-distribution.Rmd)\nbuilt around a down-sampled random forest classifier. It demonstrates:\n\n- presence-class response plots with `response = \"1\"`\n- profile, PDP, ICE, and ALE workflows through `univariate()`\n- bivariate profile, PDP, and ALE surfaces with an optional 3D surface\n\nYou can open it after installation with:\n\n```r\nvignette(\"random-forest-species-distribution\", package = \"curves\")\n```\n\n## Interactive map-linked curves\n\n`mapcurve()` opens a Shiny explorer that links a predicted map\nto fitted response curves. Clicking a raster cell marks that site's predictor\nvalues on the curve panels, which helps compare local conditions with profile,\nPDP, ICE, or ALE summaries.\n\n\u003cimg src=\"man/figures/readme-interactive.png\" alt=\"Interactive map-linked response curve explorer\" width=\"100%\" /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frvalavi%2Fcurves","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frvalavi%2Fcurves","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frvalavi%2Fcurves/lists"}