Statistics::LineFit

Statistics::LineFit module least squares line fit, weighted or unweighted.
Download

Statistics::LineFit Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Richard Anderson
  • Publisher web site:
  • http://search.cpan.org/~randerson/Statistics-LineFit-0.07/lib/Statistics/LineFit.pm

Statistics::LineFit Tags


Statistics::LineFit Description

Statistics::LineFit module least squares line fit, weighted or unweighted. Statistics::LineFit module least squares line fit, weighted or unweighted.SYNOPSIS use Statistics::LineFit; $lineFit = Statistics::LineFit->new(); $lineFit->setData (@xValues, @yValues) or die "Invalid data"; ($intercept, $slope) = $lineFit->coefficients(); defined $intercept or die "Can't fit line if x values are all equal"; $rSquared = $lineFit->rSquared(); $meanSquaredError = $lineFit->meanSqError(); $durbinWatson = $lineFit->durbinWatson(); $sigma = $lineFit->sigma(); ($tStatIntercept, $tStatSlope) = $lineFit->tStatistics(); @predictedYs = $lineFit->predictedYs(); @residuals = $lineFit->residuals(); (varianceIntercept, $varianceSlope) = $lineFit->varianceOfEstimates();The Statistics::LineFit module does weighted or unweighted least-squares line fitting to two-dimensional data (y = a + b * x). (This is also called linear regression.) In addition to the slope and y-intercept, the module can return the square of the correlation coefficient (R squared), the Durbin-Watson statistic, the mean squared error, sigma, the t statistics, the variance of the estimates of the slope and y-intercept, the predicted y values and the residuals of the y values. (See the METHODS section for a description of these statistics.)The module accepts input data in separate x and y arrays or a single 2-D array (an array of arrayrefs). The optional weights are input in a separate array. The module can optionally verify that the input data and weights are valid numbers. If weights are input, the line fit minimizes the weighted sum of the squared errors and the following statistics are weighted: the correlation coefficient, the Durbin-Watson statistic, the mean squared error, sigma and the t statistics.The module is state-oriented and caches its results. Once you call the setData() method, you can call the other methods in any order or call a method several times without invoking redundant calculations. After calling setData(), you can modify the input data or weights without affecting the module's results.The decision to use or not use weighting could be made using your a priori knowledge of the data or using supplemental data. If the data is sparse or contains non-random noise, weighting can degrade the solution. Weighting is a good option if some points are suspect or less relevant (e.g., older terms in a time series, points that are known to have more noise).Requirements:· Perl Requirements: · Perl


Statistics::LineFit Related Software