113 return round($this->_slope,$dp);
121 return round($this->_slopeSE,$dp);
129 return round($this->_intersect,$dp);
137 return round($this->_intersectSE,$dp);
145 return round($this->_goodnessOfFit,$dp);
153 return round($this->_goodnessOfFit * 100,$dp);
155 return $this->_goodnessOfFit * 100;
161 return round($this->_stdevOfResiduals,$dp);
169 return round($this->_SSRegression,$dp);
177 return round($this->_SSResiduals,$dp);
185 return round($this->_DFResiduals,$dp);
193 return round($this->_F,$dp);
201 return round($this->_covariance,$dp);
209 return round($this->_correlation,$dp);
221 $SSres = $SScov = $SScor = $SStot = $SSsex = 0.0;
222 foreach($this->_xValues as $xKey => $xValue) {
223 $bestFitY = $this->_yBestFitValues[$xKey] = $this->
getValueOfYForX($xValue);
225 $SSres += ($this->_yValues[$xKey] - $bestFitY) * ($this->_yValues[$xKey] - $bestFitY);
227 $SStot += ($this->_yValues[$xKey] - $meanY) * ($this->_yValues[$xKey] - $meanY);
229 $SStot += $this->_yValues[$xKey] * $this->_yValues[$xKey];
231 $SScov += ($this->_xValues[$xKey] - $meanX) * ($this->_yValues[$xKey] - $meanY);
233 $SSsex += ($this->_xValues[$xKey] - $meanX) * ($this->_xValues[$xKey] - $meanX);
235 $SSsex += $this->_xValues[$xKey] * $this->_xValues[$xKey];
239 $this->_SSResiduals = $SSres;
240 $this->_DFResiduals = $this->_valueCount - 1 - $const;
242 if ($this->_DFResiduals == 0.0) {
243 $this->_stdevOfResiduals = 0.0;
245 $this->_stdevOfResiduals = sqrt($SSres / $this->_DFResiduals);
247 if (($SStot == 0.0) || ($SSres == $SStot)) {
248 $this->_goodnessOfFit = 1;
250 $this->_goodnessOfFit = 1 - ($SSres / $SStot);
253 $this->_SSRegression = $this->_goodnessOfFit * $SStot;
255 $this->_correlation = ($this->_valueCount * $sumXY - $sumX * $sumY) / sqrt(($this->_valueCount * $sumX2 - pow($sumX,2)) * ($this->_valueCount * $sumY2 - pow($sumY,2)));
256 $this->_slopeSE = $this->_stdevOfResiduals / sqrt($SSsex);
257 $this->_intersectSE = $this->_stdevOfResiduals * sqrt(1 / ($this->_valueCount - ($sumX * $sumX) / $sumX2));
258 if ($this->_SSResiduals != 0.0) {
259 if ($this->_DFResiduals == 0.0) {
265 if ($this->_DFResiduals == 0.0) {
276 $x_sum = array_sum($xValues);
277 $y_sum = array_sum($yValues);
280 $mBase = $mDivisor = $xx_sum = $xy_sum = $yy_sum = 0.0;
282 $xy_sum += $xValues[$i] * $yValues[$i];
283 $xx_sum += $xValues[$i] * $xValues[$i];
284 $yy_sum += $yValues[$i] * $yValues[$i];
287 $mBase += ($xValues[$i] - $meanX) * ($yValues[$i] - $meanY);
288 $mDivisor += ($xValues[$i] - $meanX) * ($xValues[$i] - $meanX);
290 $mBase += $xValues[$i] * $yValues[$i];
291 $mDivisor += $xValues[$i] * $xValues[$i];
297 $this->_slope = $mBase / $mDivisor;
302 $this->_intersect = $meanY - ($this->_slope * $meanX);
304 $this->_intersect = 0;
313 $nY = count($yValues);
314 $nX = count($xValues);
318 $xValues = range(1,$nY);
320 } elseif ($nY != $nX) {
322 $this->_error = True;
326 $this->_valueCount = $nY;
327 $this->_xValues = $xValues;
328 $this->_yValues = $yValues;