{"id":20119235,"url":"https://github.com/harrystevens/d3-regression","last_synced_at":"2025-04-04T11:14:27.807Z","repository":{"id":46222584,"uuid":"177360780","full_name":"HarryStevens/d3-regression","owner":"HarryStevens","description":"Calculate statistical regressions from two-dimensional data.","archived":false,"fork":false,"pushed_at":"2024-04-02T19:25:15.000Z","size":2583,"stargazers_count":158,"open_issues_count":18,"forks_count":16,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-14T07:30:21.034Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://observablehq.com/collection/@harrystevens/d3-regression","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HarryStevens.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2019-03-24T02:11:41.000Z","updated_at":"2024-06-18T13:43:51.620Z","dependencies_parsed_at":"2024-06-18T13:43:40.728Z","dependency_job_id":"b3a519e8-02bd-40ff-ba6e-35108d8525a8","html_url":"https://github.com/HarryStevens/d3-regression","commit_stats":{"total_commits":214,"total_committers":8,"mean_commits":26.75,"dds":0.07943925233644855,"last_synced_commit":"41e9980f90cba24378d746cc5fc69c28fe9b9f36"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarryStevens%2Fd3-regression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarryStevens%2Fd3-regression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarryStevens%2Fd3-regression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarryStevens%2Fd3-regression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HarryStevens","download_url":"https://codeload.github.com/HarryStevens/d3-regression/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166168,"owners_count":20894654,"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":[],"created_at":"2024-11-13T19:14:51.635Z","updated_at":"2025-04-04T11:14:27.764Z","avatar_url":"https://github.com/HarryStevens.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# d3-regression\nCalculate statistical regressions from two-dimensional data.\n\n[\u003cimg alt=\"Stastical Regressions\" src=\"https://raw.githubusercontent.com/harrystevens/d3-regression/master/img/cover.png\" width=\"882\"\u003e](https://observablehq.com/@harrystevens/introducing-d3-regression)\n\n## Installing\nIf you use NPM, `npm install d3-regression`. Otherwise, download the [latest release](https://github.com/HarryStevens/d3-regression/raw/master/dist/d3-regression.zip). AMD, CommonJS, and vanilla environments are supported. In vanilla, a d3 global is exported:\n\n```html\n\u003cscript src=\"https://unpkg.com/d3-regression@1.3.10/dist/d3-regression.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n\nconst regression = d3.regressionLinear()\n  .x(d =\u003e d.x)\n  .y(d =\u003e d.y)\n  .domain([0, 100]);\n\n\u003c/script\u003e\n```\n\n## API Reference\n- [Linear](#regressionLinear)\n- [Exponential](#regressionExp)\n- [Logarithmic](#regressionLog)\n- [Quadratic](#regressionQuad)\n- [Polynomial](#regressionPoly)\n- [Power law](#regressionPow)\n- [LOESS](#regressionLoess)\n\n\u003ca name=\"regressionLinear\" href=\"#regressionLinear\"\u003e#\u003c/a\u003e d3.\u003cb\u003eregressionLinear\u003c/b\u003e() · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/linear.js \"Source\"), [Example](https://observablehq.com/@harrystevens/linear-regression \"Example\")\n\nCreates a new linear regression generator with default [\u003cem\u003ex\u003c/em\u003e-](#linear_x) and [\u003cem\u003ey\u003c/em\u003e-](#linear_y) accessors and a null [domain](#linear_domain).\n\n[\u003cimg alt=\"Linear regression\" src=\"https://raw.githubusercontent.com/harrystevens/d3-regression/master/img/linear.png\" width=\"250\"\u003e](https://observablehq.com/@harrystevens/linear-regression)\n\n\u003ca name=\"_linear\" href=\"#_linear\"\u003e#\u003c/a\u003e \u003ci\u003elinear\u003c/i\u003e(\u003ci\u003edata\u003c/i\u003e) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/linear.js#L9 \"Source\")\n\nComputes the linear regression, which takes the form \u003cem\u003ey\u003c/em\u003e = \u003cem\u003eax\u003c/em\u003e + \u003cem\u003eb\u003c/em\u003e, for the specified *data* points, ignoring points with invalid values (null, undefined, NaN, Infinity).\n\nReturns a line represented as an array of two points, where each point is an array of two numbers representing the point's coordinates. \n\nAlso returns properties \u003cem\u003ea\u003c/em\u003e and \u003cem\u003eb\u003c/em\u003e, representing the equation's coefficients, and \u003cem\u003erSquared\u003c/em\u003e, representing the coefficient of determination. Lastly, returns a \u003cem\u003epredict\u003c/em\u003e property, which is a function that outputs a \u003cem\u003ey\u003c/em\u003e-coordinate given an input \u003cem\u003ex\u003c/em\u003e-coordinate.\n\n\u003ca name=\"linear_x\" href=\"#linear_x\"\u003e#\u003c/a\u003e \u003ci\u003elinear\u003c/i\u003e.\u003cb\u003ex\u003c/b\u003e([\u003ci\u003ex\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/linear.js#L47 \"Source\")\n\nIf \u003cem\u003ex\u003c/em\u003e is specified, sets the \u003cem\u003ex\u003c/em\u003e-coordinate accessor, which is passed passed the current datum (\u003cem\u003ed\u003c/em\u003e), the current index (\u003cem\u003ei\u003c/em\u003e), and the entire data array (\u003cem\u003edata\u003c/em\u003e). If \u003cem\u003ex\u003c/em\u003e is not specified, returns the current \u003cem\u003ex\u003c/em\u003e-coordinate accessor, which defaults to:\n\n```js\nfunction x(d, i, data) {\n  return d[0];\n}\n```\n\n\u003ca name=\"linear_y\" href=\"#linear_y\"\u003e#\u003c/a\u003e \u003ci\u003elinear\u003c/i\u003e.\u003cb\u003ey\u003c/b\u003e([\u003ci\u003ey\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/linear.js#L51 \"Source\")\n\nIf \u003cem\u003ey\u003c/em\u003e is specified, sets the \u003cem\u003ey\u003c/em\u003e-coordinate accessor, which is passed passed the current datum (\u003cem\u003ed\u003c/em\u003e), the current index (\u003cem\u003ei\u003c/em\u003e), and the entire data array (\u003cem\u003edata\u003c/em\u003e). If \u003cem\u003ey\u003c/em\u003e is not specified, returns the current \u003cem\u003ey\u003c/em\u003e-coordinate accessor, which defaults to:\n\n```js\nfunction y(d, i, data) {\n  return d[1];\n}\n```\n\n\u003ca name=\"linear_domain\" href=\"#linear_domain\"\u003e#\u003c/a\u003e \u003ci\u003elinear\u003c/i\u003e.\u003cb\u003edomain\u003c/b\u003e([\u003ci\u003edomain\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/linear.js#L43 \"Source\")\n\nIf \u003cem\u003edomain\u003c/em\u003e is specified, sets the minimum and maximum \u003cem\u003ex\u003c/em\u003e-coordinates of the returned line to the specified array of numbers. The array must contain two elements. If the elements in the given array are not numbers, they will be coerced to numbers. If \u003cem\u003edomain\u003c/em\u003e is not specified, returns a copy of the regression generator’s current domain.\n\nIf data is passed to the regression generator before a \u003cem\u003edomain\u003c/em\u003e has been specified, the domain will be set to the minimum and maximum \u003cem\u003ex\u003c/em\u003e-coordinate values of the data.\n\n\u003ca name=\"regressionExp\" href=\"#regressionExp\"\u003e#\u003c/a\u003e d3.\u003cb\u003eregressionExp\u003c/b\u003e() · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/exponential.js \"Source\"), [Example](https://observablehq.com/@harrystevens/exponential-regression \"Example\")\n\nCreates a new exponential regression generator with default [\u003cem\u003ex\u003c/em\u003e-](#exp_x) and [\u003cem\u003ey\u003c/em\u003e-](#exp_y) accessors and a null [domain](#exp_domain).\n\n[\u003cimg alt=\"Exponential regression\" src=\"https://raw.githubusercontent.com/harrystevens/d3-regression/master/img/exponential-2.png\" width=\"250\"\u003e](https://observablehq.com/@harrystevens/exponential-regression)\n\n\u003ca name=\"_exponential\" href=\"#_exponential\"\u003e#\u003c/a\u003e \u003ci\u003eexp\u003c/i\u003e(\u003ci\u003edata\u003c/i\u003e) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/exponential.js#L10 \"Source\")\n\nComputes the exponential regression, which takes the form \u003cem\u003ey\u003c/em\u003e = \u003cem\u003eae\u003c/em\u003e\u003csup\u003e\u003cem\u003ebx\u003c/em\u003e\u003c/sup\u003e, for the specified *data* points, ignoring points with invalid values (null, undefined, NaN, Infinity).\n\nReturns a smooth line represented as an array of points, where each point is an array of two numbers representing the point's coordinates.\n\nAlso returns properties \u003cem\u003ea\u003c/em\u003e and \u003cem\u003eb\u003c/em\u003e, representing the equation's coefficients, and \u003cem\u003erSquared\u003c/em\u003e, representing the coefficient of determination. Lastly, returns a \u003cem\u003epredict\u003c/em\u003e property, which is a function that outputs a \u003cem\u003ey\u003c/em\u003e-coordinate given an input \u003cem\u003ex\u003c/em\u003e-coordinate.\n\n\u003ca name=\"exp_x\" href=\"#exp_x\"\u003e#\u003c/a\u003e \u003ci\u003eexp\u003c/i\u003e.\u003cb\u003ex\u003c/b\u003e([\u003ci\u003ex\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/exponential.js#L53 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.x()](#linear_x).\n\n\u003ca name=\"exp_y\" href=\"#exp_y\"\u003e#\u003c/a\u003e \u003ci\u003eexp\u003c/i\u003e.\u003cb\u003ey\u003c/b\u003e([\u003ci\u003ey\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/exponential.js#L57 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.y()](#linear_y).\n\n\u003ca name=\"exp_domain\" href=\"#exp_domain\"\u003e#\u003c/a\u003e \u003ci\u003eexp\u003c/i\u003e.\u003cb\u003edomain\u003c/b\u003e([\u003ci\u003edomain\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/exponential.js#L49 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.domain()](#linear_domain).\n\n\u003ca name=\"regressionLog\" href=\"#regressionLog\"\u003e#\u003c/a\u003e d3.\u003cb\u003eregressionLog\u003c/b\u003e() · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/logarithmic.js \"Source\"), [Example](https://observablehq.com/@harrystevens/logarithmic-regression \"Example\")\n\nCreates a new logarithmic regression generator with default [\u003cem\u003ex\u003c/em\u003e-](#log_x) and [\u003cem\u003ey\u003c/em\u003e-](#log_y) accessors and a null [domain](#log_domain).\n\n[\u003cimg alt=\"Logarithmic regression\" src=\"https://raw.githubusercontent.com/harrystevens/d3-regression/master/img/logarithmic.png\" width=\"250\"\u003e](https://observablehq.com/@harrystevens/logarithmic-regression)\n\n\u003ca name=\"_log\" href=\"#_log\"\u003e#\u003c/a\u003e \u003ci\u003elog\u003c/i\u003e(\u003ci\u003edata\u003c/i\u003e) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/logarithmic.js#L12 \"Source\")\n\nComputes the logarithmic regression, which takes the form \u003cem\u003ey\u003c/em\u003e = \u003cem\u003ea\u003c/em\u003e · ln(\u003cem\u003ex\u003c/em\u003e) + \u003cem\u003eb\u003c/em\u003e, for the specified *data* points, ignoring points with invalid values (null, undefined, NaN, Infinity).\n\nReturns a smooth line represented as an array of points, where each point is an array of two numbers representing the point's coordinates.\n\nAlso returns properties \u003cem\u003ea\u003c/em\u003e and \u003cem\u003eb\u003c/em\u003e, representing the equation's coefficients, and \u003cem\u003erSquared\u003c/em\u003e, representing the coefficient of determination. Lastly, returns a \u003cem\u003epredict\u003c/em\u003e property, which is a function that outputs a \u003cem\u003ey\u003c/em\u003e-coordinate given an input \u003cem\u003ex\u003c/em\u003e-coordinate.\n\n\u003ca name=\"log_x\" href=\"#log_x\"\u003e#\u003c/a\u003e \u003ci\u003elog\u003c/i\u003e.\u003cb\u003ex\u003c/b\u003e([\u003ci\u003ex\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/logarithmic.js#L52 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.x()](#linear_x).\n\n\u003ca name=\"log_y\" href=\"#log_y\"\u003e#\u003c/a\u003e \u003ci\u003elog\u003c/i\u003e.\u003cb\u003ey\u003c/b\u003e([\u003ci\u003ey\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/logarithmic.js#L56 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.y()](#linear_y).\n\n\u003ca name=\"log_domain\" href=\"#log_domain\"\u003e#\u003c/a\u003e \u003ci\u003elog\u003c/i\u003e.\u003cb\u003edomain\u003c/b\u003e([\u003ci\u003edomain\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/logarithmic.js#L48 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.domain()](#linear_domain).\n\n\u003ca name=\"log_base\" href=\"#log_base\"\u003e#\u003c/a\u003e \u003ci\u003elog\u003c/i\u003e.\u003cb\u003ebase\u003c/b\u003e([\u003ci\u003ebase\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/logarithmic.js#L60 \"Source\")\n\nIf \u003ci\u003ebase\u003c/i\u003e is specified, sets the base of the logarithmic regression. If \u003ci\u003ebase\u003c/i\u003e is not specified, returns the current base, which defaults to [Euler's number](https://en.wikipedia.org/wiki/E_(mathematical_constant)).\n\n\u003ca name=\"regressionQuad\" href=\"#regressionQuad\"\u003e#\u003c/a\u003e d3.\u003cb\u003eregressionQuad\u003c/b\u003e() · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/quadratic.js \"Source\"), [Example](https://observablehq.com/@harrystevens/quadratic-regression \"Example\")\n\nCreates a new quadratic regression generator with default [\u003cem\u003ex\u003c/em\u003e-](#quad_x) and [\u003cem\u003ey\u003c/em\u003e-](#quad_y) accessors and a null [domain](#quad_domain).\n\n[\u003cimg alt=\"Quadratic regression\" src=\"https://raw.githubusercontent.com/harrystevens/d3-regression/master/img/quadratic.png\" width=\"250\"\u003e](https://observablehq.com/@harrystevens/quadratic-regression)\n\n\u003ca name=\"_quad\" href=\"#_quad\"\u003e#\u003c/a\u003e \u003ci\u003equad\u003c/i\u003e(\u003ci\u003edata\u003c/i\u003e) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/quadratic.js#L9 \"Source\")\n\nComputes the quadratic regression, which takes the form \u003cem\u003ey\u003c/em\u003e = \u003cem\u003eax\u003c/em\u003e\u003csup\u003e2\u003c/sup\u003e + \u003cem\u003ebx\u003c/em\u003e + \u003cem\u003ec\u003c/em\u003e, for the specified *data* points, ignoring points with invalid values (null, undefined, NaN, Infinity).\n\nReturns a smooth line represented as an array of points, where each point is an array of two numbers representing the point's coordinates.\n\nAlso returns properties \u003cem\u003ea\u003c/em\u003e, \u003cem\u003eb\u003c/em\u003e, and \u003ce\u003ec\u003c/e\u003e, representing the equation's coefficients, and \u003cem\u003erSquared\u003c/em\u003e, representing the coefficient of determination. Lastly, returns a \u003cem\u003epredict\u003c/em\u003e property, which is a function that outputs a \u003cem\u003ey\u003c/em\u003e-coordinate given an input \u003cem\u003ex\u003c/em\u003e-coordinate.\n\n\u003ca name=\"quad_x\" href=\"#quad_x\"\u003e#\u003c/a\u003e \u003ci\u003equad\u003c/i\u003e.\u003cb\u003ex\u003c/b\u003e([\u003ci\u003ex\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/quadratic.js#L71 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.x()](#linear_x).\n\n\u003ca name=\"quad_y\" href=\"#quad_y\"\u003e#\u003c/a\u003e \u003ci\u003equad\u003c/i\u003e.\u003cb\u003ey\u003c/b\u003e([\u003ci\u003ey\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/quadratic.js#L75 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.y()](#linear_y).\n\n\u003ca name=\"quad_domain\" href=\"#quad_domain\"\u003e#\u003c/a\u003e \u003ci\u003equad\u003c/i\u003e.\u003cb\u003edomain\u003c/b\u003e([\u003ci\u003edomain\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/quadratic.js#L67 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.domain()](#linear_domain).\n\n\u003ca name=\"regressionPoly\" href=\"#regressionPoly\"\u003e#\u003c/a\u003e d3.\u003cb\u003eregressionPoly\u003c/b\u003e() · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/polynomial.js \"Source\"), [Example](https://observablehq.com/@harrystevens/polynomial-regression \"Example\")\n\nCreates a new polynomial regression generator with default [\u003cem\u003ex\u003c/em\u003e-](#poly_x) and [\u003cem\u003ey\u003c/em\u003e-](#poly_y) accessors, a null [domain](#poly_domain), and an [order](#poly_order) of 3. This implementation was adapted from [regression-js](https://github.com/Tom-Alexander/regression-js/).\n\n[\u003cimg alt=\"Polynomial regression\" src=\"https://raw.githubusercontent.com/harrystevens/d3-regression/master/img/polynomial.png\" width=\"250\"\u003e](https://observablehq.com/@harrystevens/polynomial-regression)\n\n\u003ca name=\"_poly\" href=\"#_poly\"\u003e#\u003c/a\u003e \u003ci\u003epoly\u003c/i\u003e(\u003ci\u003edata\u003c/i\u003e) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/polynomial.js#L13 \"Source\")\n\nComputes the polynomial regression, which takes the form \u003cem\u003ey\u003c/em\u003e = \u003cem\u003ea\u003csub\u003en\u003c/sub\u003ex\u003csup\u003en\u003c/sup\u003e\u003c/em\u003e + ... + \u003cem\u003ea\u003c/em\u003e\u003csub\u003e1\u003c/sub\u003e\u003cem\u003ex\u003c/em\u003e + \u003cem\u003ea\u003c/em\u003e\u003csub\u003e0\u003c/sub\u003e, for the specified *data* points, ignoring points with invalid values (null, undefined, NaN, Infinity).\n\nReturns a smooth line represented as an array of points, where each point is an array of two numbers representing the point's coordinates.\n\nAlso returns three properties: \u003cem\u003ecoefficients\u003c/em\u003e, an array representing the equation's coefficients with the intercept as the first item and nth degree coefficient as the last item; \u003cem\u003erSquared\u003c/em\u003e, representing the coefficient of determination; and \u003cem\u003epredict\u003c/em\u003e, a function that outputs a \u003cem\u003ey\u003c/em\u003e-coordinate given an input \u003cem\u003ex\u003c/em\u003e-coordinate.\n\n\u003ca name=\"poly_x\" href=\"#poly_x\"\u003e#\u003c/a\u003e \u003ci\u003epoly\u003c/i\u003e.\u003cb\u003ex\u003c/b\u003e([\u003ci\u003ex\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/polynomial.js#L92 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.x()](#linear_x).\n\n\u003ca name=\"poly_y\" href=\"#poly_y\"\u003e#\u003c/a\u003e \u003ci\u003epoly\u003c/i\u003e.\u003cb\u003ey\u003c/b\u003e([\u003ci\u003ey\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/polynomial.js#L96 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.y()](#linear_y).\n\n\u003ca name=\"poly_domain\" href=\"#poly_domain\"\u003e#\u003c/a\u003e \u003ci\u003epoly\u003c/i\u003e.\u003cb\u003edomain\u003c/b\u003e([\u003ci\u003edomain\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/polynomial.js#L88 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.domain()](#linear_domain).\n\n\u003ca name=\"poly_order\" href=\"#poly_order\"\u003e#\u003c/a\u003e \u003ci\u003epoly\u003c/i\u003e.\u003cb\u003eorder\u003c/b\u003e([\u003ci\u003eorder\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/polynomial.js#L100 \"Source\")\n\nIf \u003cem\u003eorder\u003c/em\u003e is specified, sets the regression's order to the specified number. For example, if \u003cem\u003eorder\u003c/em\u003e is set to 4, the regression generator will perform a fourth-degree polynomial regression. Likewise, if \u003cem\u003eorder\u003c/em\u003e is set to 2, the regression generator will perform a quadratic regression. Be careful about attempting to fit your data with higher order polynomials; though the regression line will fit your data with a high determination coefficient, it may have little predictive power for data outside of your domain.\n\nIf \u003cem\u003eorder\u003c/em\u003e is not specified, returns the regression generator's current \u003cem\u003eorder\u003c/em\u003e, which defaults to 3.\n\n\u003ca name=\"regressionPow\" href=\"#regressionPow\"\u003e#\u003c/a\u003e d3.\u003cb\u003eregressionPow\u003c/b\u003e() · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/power.js \"Source\"), [Example](https://observablehq.com/@harrystevens/power-law-regression \"Example\")\n\nCreates a new power law regression generator with default [\u003cem\u003ex\u003c/em\u003e-](#pow_x) and [\u003cem\u003ey\u003c/em\u003e-](#pow_y) accessors and a null [domain](#pow_domain).\n\n[\u003cimg alt=\"Power law regression\" src=\"https://raw.githubusercontent.com/harrystevens/d3-regression/master/img/power.png\" width=\"250\"\u003e](https://observablehq.com/@harrystevens/power-law-regression)\n\n\u003ca name=\"_pow\" href=\"#_pow\"\u003e#\u003c/a\u003e \u003ci\u003epow\u003c/i\u003e(\u003ci\u003edata\u003c/i\u003e) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/power.js#L10 \"Source\")\n\nComputes the power law regression, which takes the form \u003cem\u003ey\u003c/em\u003e = \u003cem\u003ea\u003c/em\u003e\u003cem\u003ex\u003c/em\u003e\u003csup\u003e\u003cem\u003eb\u003c/em\u003e\u003c/sup\u003e, for the specified *data* points, ignoring points with invalid values (null, undefined, NaN, Infinity).\n\nReturns a smooth line represented as an array of points, where each point is an array of two numbers representing the point's coordinates.\n\nAlso returns properties \u003cem\u003ea\u003c/em\u003e and \u003cem\u003eb\u003c/em\u003e, representing the equation's coefficients, and \u003cem\u003erSquared\u003c/em\u003e, representing the coefficient of determination. Lastly, returns a \u003cem\u003epredict\u003c/em\u003e property, which is a function that outputs a \u003cem\u003ey\u003c/em\u003e-coordinate given an input \u003cem\u003ex\u003c/em\u003e-coordinate.\n\n\u003ca name=\"pow_x\" href=\"#pow_x\"\u003e#\u003c/a\u003e \u003ci\u003epow\u003c/i\u003e.\u003cb\u003ex\u003c/b\u003e([\u003ci\u003ex\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/power.js#L54 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.x()](#linear_x).\n\n\u003ca name=\"pow_y\" href=\"#pow_y\"\u003e#\u003c/a\u003e \u003ci\u003epow\u003c/i\u003e.\u003cb\u003ey\u003c/b\u003e([\u003ci\u003ey\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/power.js#L58 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.y()](#linear_y).\n\n\u003ca name=\"pow_domain\" href=\"#pow_domain\"\u003e#\u003c/a\u003e \u003ci\u003epow\u003c/i\u003e.\u003cb\u003edomain\u003c/b\u003e([\u003ci\u003edomain\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/power.js#L50 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.domain()](#linear_domain).\n\n\u003ca name=\"regressionLoess\" href=\"#regressionLoess\"\u003e#\u003c/a\u003e d3.\u003cb\u003eregressionLoess\u003c/b\u003e() · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/loess.js \"Source\"), [Example](https://observablehq.com/@harrystevens/loess-regression \"Example\")\n\nCreates a new [LOESS regression](https://en.wikipedia.org/wiki/Local_regression) generator with default [\u003cem\u003ex\u003c/em\u003e-](#loess_x) and [\u003cem\u003ey\u003c/em\u003e-](#loess_y) accessors and a [bandwidth](#loess_bandwidth) of .3. This implementation was adapted from [science.js](https://github.com/jasondavies/science.js).\n\n[\u003cimg alt=\"LOESS regression\" src=\"https://raw.githubusercontent.com/harrystevens/d3-regression/master/img/loess.png\" width=\"250\"\u003e](https://observablehq.com/@harrystevens/loess-regression)\n\n\u003ca name=\"_loess\" href=\"#_loess\"\u003e#\u003c/a\u003e \u003ci\u003eloess\u003c/i\u003e(\u003ci\u003edata\u003c/i\u003e) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/loess.js#L14 \"Source\")\n\nComputes the LOESS regression for the specified *data* points, ignoring points with invalid values (null, undefined, NaN, Infinity).\n\nReturns a line represented as an array of \u003cem\u003en\u003c/em\u003e points, where each point is an array of two numbers representing the point's coordinates.\n\n\u003ca name=\"loess_x\" href=\"#loess_x\"\u003e#\u003c/a\u003e \u003ci\u003eloess\u003c/i\u003e.\u003cb\u003ex\u003c/b\u003e([\u003ci\u003ex\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/loess.js#L81 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.x()](#linear_x).\n\n\u003ca name=\"loess_y\" href=\"#loess_y\"\u003e#\u003c/a\u003e \u003ci\u003eloess\u003c/i\u003e.\u003cb\u003ey\u003c/b\u003e([\u003ci\u003ey\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/loess.js#L85 \"Source\")\n\nSee [\u003cem\u003elinear\u003c/em\u003e.y()](#linear_y).\n\n\u003ca name=\"loess_bandwidth\" href=\"#loess_bandwidth\"\u003e#\u003c/a\u003e \u003ci\u003eloess\u003c/i\u003e.\u003cb\u003ebandwidth\u003c/b\u003e([\u003ci\u003ebandwidth\u003c/i\u003e]) · [Source](https://github.com/harrystevens/d3-regression/blob/master/src/loess.js#L77 \"Source\")\n\nIf \u003cem\u003ebandwidth\u003c/em\u003e is specified, sets the LOESS regression's bandwidth, or smoothing parameter, to the specific number between 0 and 1. The bandwidth represents the share of the total data points that are used to calculate each local fit. Higher bandwidths produce smoother lines, and vice versa. If \u003cem\u003ebandwidth\u003c/em\u003e is not specified, returns a copy of the regression generator’s current bandwidth, which defaults to .3.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharrystevens%2Fd3-regression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharrystevens%2Fd3-regression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharrystevens%2Fd3-regression/lists"}