linearcorrelation

0.1.0 • Public • Published

linearcorrelation

npm jsdeliver license code size

linearcorrelation is a tiny JavaScript library that performs linear regression and recovers residuals and normalized residuals.

1. Installation

In browser

<script src="https://cdn.jsdelivr.net/npm/linearcorrelation" charset="utf-8"></script>

In Observable

Last version

corr = require("linearcorrelation")

2. Functions

test()

the test function calculates indicators to measure the degree of association between two quantitative variables. The test returns the linear correlation (Pearson), the rank correlation (Spearman) and the number of missing data not taken into account in the calculations.

test(data, {x: "gdp", y:"co2" })

It is also possible to calculate the relation with the log of the variables

test(data, {x: "gdp", y:"co2", logx: true, logy: false })

lm()

The lm function calculates linear regression. It returns the regression line function and the coefficient of determination (rsquared). It also returns data with residuals and normalized residuals. As before, the parameters logx and logy can be used to transform variables into log.

lm(data, {x: "gdp", y:"co2", logx: true, logy: false })

3. Demo

A live demo is available on this Observable notebook: https://observablehq.com/@neocartocnrs/corr

Package Sidebar

Install

npm i linearcorrelation

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

12.4 kB

Total Files

18

Last publish

Collaborators

  • neocarto