looker/regression-js

Name: regression-js

Owner: looker

Description: A javascript library containing a collection of least squares fitting methods

Forked from: Tom-Alexander/regression-js

Created: 2017-06-26 22:24:14.0

Updated: 2017-06-26 22:24:15.0

Pushed: 2017-06-28 23:19:18.0

Homepage:

Size: 1565

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

regression.js

Build Status

regression.js is a JavaScript library containing a collection of least-squares fitting methods for finding a trend in a set of data. It currently contains methods for linear, exponential, logarithmic, power and polynomial trends.

Installation

The library can be installed from both bower and npm.

Usage

Most regressions require only two parameters - the regression method (linear, exponential, logarithmic, power or polynomial) and a data source. A third parameter can be used to define the degree of a polynomial when a polynomial regression is required. The regression method name is case-insensitive.

All models return an object with the following properties:

Regression Types

Linear regression

equation: [gradient, y-intercept] in the form y = mx + c

data = [[0,1],[32, 67] .... [12, 79]];
result = regression('linear', data);
slope = result.equation[0];
yIntercept = result.equation[1];
Linear regression through the origin

equation: [gradient] in the form y = mx

data = [[0,1],[32, 67] .... [12, 79]];
result = regression('linearThroughOrigin', data);
Exponential regression

equation: [a, b] in the form y = ae^bx

Logarithmic regression

equation: [a, b] in the form y = a + b ln x

Power law regression

equation: [a, b] in the form y = ax^b

Polynomial regression

equation: [a0, ... , an] in the form anx^n ... + a1x + a0

data = [[0,1],[32, 67] .... [12, 79]];
result = regression('polynomial', data, 4);
Lastvalue

Not exactly a regression. Uses the last value to fill the blanks when forecasting.

Filling the blanks and forecasting
data = [[0,1], [32, null] .... [12, 79]];

In any regression, if you use a null value for data, regression-js will fill it using the trend.

Development

Install packages: npm install

The project is built and controlled with grunt.

To prepare for release, run the default task, which:

To run tests, grunt test.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.