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 $this->_stdevOfResiduals = sqrt($SSres / $this->_DFResiduals);
243 if (($SStot == 0.0) || ($SSres == $SStot)) {
244 $this->_goodnessOfFit = 1;
246 $this->_goodnessOfFit = 1 - ($SSres / $SStot);
249 $this->_SSRegression = $this->_goodnessOfFit * $SStot;
251 $this->_correlation = ($this->_valueCount * $sumXY - $sumX * $sumY) / sqrt(($this->_valueCount * $sumX2 - pow($sumX,2)) * ($this->_valueCount * $sumY2 - pow($sumY,2)));
252 $this->_slopeSE = $this->_stdevOfResiduals / sqrt($SSsex);
253 $this->_intersectSE = $this->_stdevOfResiduals * sqrt(1 / ($this->_valueCount - ($sumX * $sumX) / $sumX2));
254 if ($this->_SSResiduals != 0.0) {
264 $x_sum = array_sum($xValues);
265 $y_sum = array_sum($yValues);
268 $mBase = $mDivisor = $xx_sum = $xy_sum = $yy_sum = 0.0;
270 $xy_sum += $xValues[$i] * $yValues[$i];
271 $xx_sum += $xValues[$i] * $xValues[$i];
272 $yy_sum += $yValues[$i] * $yValues[$i];
275 $mBase += ($xValues[$i] - $meanX) * ($yValues[$i] - $meanY);
276 $mDivisor += ($xValues[$i] - $meanX) * ($xValues[$i] - $meanX);
278 $mBase += $xValues[$i] * $yValues[$i];
279 $mDivisor += $xValues[$i] * $xValues[$i];
285 $this->_slope = $mBase / $mDivisor;
290 $this->_intersect = $meanY - ($this->_slope * $meanX);
292 $this->_intersect = 0;
301 $nY = count($yValues);
302 $nX = count($xValues);
306 $xValues = range(1,$nY);
310 $this->_error = True;
314 $this->_valueCount = $nY;
315 $this->_xValues = $xValues;
316 $this->_yValues = $yValues;