PHPackages                             mnshankar/linear-regression - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mnshankar/linear-regression

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mnshankar/linear-regression
===========================

PHP package for computation of simple linear regression parameters

1.0(11y ago)2323.3k↓50%10[3 issues](https://github.com/mnshankar/linear-regression/issues)MITPHPPHP &gt;=5.3

Since Feb 24Pushed 9y ago5 watchersCompare

[ Source](https://github.com/mnshankar/linear-regression)[ Packagist](https://packagist.org/packages/mnshankar/linear-regression)[ RSS](/packages/mnshankar-linear-regression/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/c683a88c6a6d5b97803fc981693be0f285e7bbeb42e363059c2535b532a79824/68747470733a2f2f7472617669732d63692e6f72672f6d6e7368616e6b61722f6c696e6561722d72656772657373696f6e2e706e67)](https://travis-ci.org/mnshankar/linear-regression)

Simple Linear Regression
========================

[](#simple-linear-regression)

This package is used to compute simple linear regression parameters using PHP. It can be used to closely mimic the output of excel regression computation add-in. For a good how-to and intro if you are unfamiliar with this feature see [Excel-easy's regression example](http://www.excel-easy.com/examples/regression.html).

Installation
------------

[](#installation)

Add the LinearRegression package as a dependency to your composer.json file:

```
{
    "require": {
        "mnshankar/linear-regression": "1.0.*"
    }
}
```

Using the tool
--------------

[](#using-the-tool)

The unit tests (in the tests folder) contain a wealth of information regarding the API. Basically, you load up the X and Y columns (from arrays or a CSV) and run the compute() method to generate all the regression parameters :-)

```
$reg = new \mnshankar\LinearRegression\Regression();
$reg->setX($this->getXForTesting());
$reg->setY($this->getYForTesting());
$reg->compute();
```

Note: To account for the intercept, the first element of all X arrays is forced to be 1.

Please refer to the Excel workbook named "Regression\_Verification.xlsx" in the tests folder. The worksheet named "Calculated Values" contains all parameters generated by the excel add-in using data in the worksheet named "Raw Data".

The unit tests for regression computation `tests/RegressionTest.php` verifies that this same data is generated by the PHP package.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4101d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ec7d6db9c6a284d9ca1fb934910bb11c1eb3aaab1d9fc9daa5e92f98a43a37d6?d=identicon)[mnshankar](/maintainers/mnshankar)

---

Top Contributors

[![Dragonrun1](https://avatars.githubusercontent.com/u/1431541?v=4)](https://github.com/Dragonrun1 "Dragonrun1 (6 commits)")[![mnshankar](https://avatars.githubusercontent.com/u/2873887?v=4)](https://github.com/mnshankar "mnshankar (5 commits)")[![Mattie112](https://avatars.githubusercontent.com/u/662896?v=4)](https://github.com/Mattie112 "Mattie112 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mnshankar-linear-regression/health.svg)

```
[![Health](https://phpackages.com/badges/mnshankar-linear-regression/health.svg)](https://phpackages.com/packages/mnshankar-linear-regression)
```

###  Alternatives

[awes-io/table-builder

A component that allows creating responsive HTML tables or lists from data object

4726.1k4](/packages/awes-io-table-builder)[pingpong/oembed

Laravel 4 - Retrieve page info using oembed, opengraph, etc.

142.1k](/packages/pingpong-oembed)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
