141            return round($this->slope, $dp);
 
  157            return round($this->slopeSE, $dp);
 
  173            return round($this->intersect, $dp);
 
  189            return round($this->intersectSE, $dp);
 
  205            return round($this->goodnessOfFit, $dp);
 
  221            return round($this->goodnessOfFit * 100, $dp);
 
  224        return $this->goodnessOfFit * 100;
 
  237            return round($this->stdevOfResiduals, $dp);
 
  251            return round($this->SSRegression, $dp);
 
  265            return round($this->SSResiduals, $dp);
 
  279            return round($this->DFResiduals, $dp);
 
  293            return round($this->f, $dp);
 
  307            return round($this->covariance, $dp);
 
  321            return round($this->correlation, $dp);
 
  337        $SSres = $SScov = $SScor = $SStot = $SSsex = 0.0;
 
  338        foreach ($this->xValues as $xKey => $xValue) {
 
  339            $bestFitY = $this->yBestFitValues[$xKey] = $this->
getValueOfYForX($xValue);
 
  341            $SSres += ($this->yValues[$xKey] - $bestFitY) * ($this->yValues[$xKey] - $bestFitY);
 
  342            if ($const === 
true) {
 
  343                $SStot += ($this->yValues[$xKey] - $meanY) * ($this->yValues[$xKey] - $meanY);
 
  345                $SStot += $this->yValues[$xKey] * $this->yValues[$xKey];
 
  347            $SScov += ($this->xValues[$xKey] - $meanX) * ($this->yValues[$xKey] - $meanY);
 
  348            if ($const === 
true) {
 
  349                $SSsex += ($this->xValues[$xKey] - $meanX) * ($this->xValues[$xKey] - $meanX);
 
  351                $SSsex += $this->xValues[$xKey] * $this->xValues[$xKey];
 
  355        $this->SSResiduals = $SSres;
 
  356        $this->DFResiduals = $this->valueCount - 1 - ($const === 
true ? 1 : 0);
 
  358        if ($this->DFResiduals == 0.0) {
 
  359            $this->stdevOfResiduals = 0.0;
 
  361            $this->stdevOfResiduals = sqrt($SSres / $this->DFResiduals);
 
  363        if (($SStot == 0.0) || ($SSres == $SStot)) {
 
  364            $this->goodnessOfFit = 1;
 
  366            $this->goodnessOfFit = 1 - ($SSres / $SStot);
 
  369        $this->SSRegression = $this->goodnessOfFit * $SStot;
 
  371        $this->correlation = ($this->valueCount * $sumXY - $sumX * $sumY) / sqrt(($this->valueCount * $sumX2 - $sumX ** 2) * ($this->valueCount * $sumY2 - $sumY ** 2));
 
  372        $this->slopeSE = $this->stdevOfResiduals / sqrt($SSsex);
 
  373        $this->intersectSE = $this->stdevOfResiduals * sqrt(1 / ($this->valueCount - ($sumX * $sumX) / $sumX2));
 
  374        if ($this->SSResiduals != 0.0) {
 
  375            if ($this->DFResiduals == 0.0) {
 
  381            if ($this->DFResiduals == 0.0) {
 
  414        $mBase = $mDivisor = 0.0;
 
  419            if ($const === 
true) {
 
  429        $this->slope = $mBase / $mDivisor;
 
  432        $this->intersect = ($const === 
true) ? $meanValueY - ($this->slope * $meanValueX) : 0.0;
 
  434        $this->
calculateGoodnessOfFit($sumValuesX, $sumValuesY, $sumSquaresX, $sumSquaresY, $xy_sum, $meanValueX, $meanValueY, $const);
 
  450        if ($xValueCount === 0) {
 
  452        } elseif ($yValueCount !== $xValueCount) {
 
  457        $this->valueCount = $yValueCount;
 
An exception for terminatinating execution or to throw for unit testing.
getIntersect($dp=0)
Return the Value of X where it intersects Y = 0.
getGoodnessOfFit($dp=0)
Return the goodness of fit for this regression.
getValueOfXForY($yValue)
Return the X-Value for a specified value of Y.
calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const)
__construct($yValues, $xValues=[])
Define the regression.
getGoodnessOfFitPercent($dp=0)
Return the goodness of fit for this regression.
getXValues()
Return the original set of X-Values.
getValueOfYForX($xValue)
Return the Y-Value for a specified value of X.
sumSquares(array $values)
getIntersectSE($dp=0)
Return the standard error of the Intersect.
leastSquareFit(array $yValues, array $xValues, bool $const)
getStdevOfResiduals($dp=0)
Return the standard deviation of the residuals for this regression.
getSlope($dp=0)
Return the Slope of the line.
getEquation($dp=0)
Return the Equation of the best-fit line.
getSlopeSE($dp=0)
Return the standard error of the Slope.
error($a_errmsg)
set error message @access public