Simple linear regression between 2 samples. Takes two vectors Y={yi} and X={xi} and returns (alpha, beta) such that Y = alpha + beta*X
Modulestatistics-linreg-0.3Haskell98
Statistics.LinearRegression
- 4 types
- 14 values
- Packagestatistics-linreg-0.3
- Exports18
- LanguageHaskell98
- LicenceMIT
- SourceLinearRegression.hs
Simple linear regression functions
3 declarationsSimple linear regression between 2 samples. Takes two vectors Y={yi} and X={xi} and returns (alpha, beta, r*r) such that Y = alpha + beta*X and where r is the Pearson product-moment correlation coefficient
Total Least Squares (TLS) linear regression. Assumes x-axis values (and not just y-axis values) are random variables and that both variables have similar distributions. interface is the same as linearRegression.
Related functions
2 declarationsPearson's product-moment correlation coefficient
Covariance of two samples
Estimated errors and distribution parameters
2 declarationsThe error (or residual) mean square of a sample w.r.t. an estimated regression line. This serves as an estimate for the variance of the sampled data. Accepts the regression parameters (alpha,beta) and the sample vectors X and Y.
The estimated distributions of the regression parameters (alpha and beta) assuming normal, identical distributions of Y, the sampled data. These can serve to get confidence intervals for the regression parameters. Accepts the regression parameters (alpha,beta) and the sample vectors X and Y. The distributions are StudnetT distributions centered at the estimated (alpha,beta) respectively, with parameter numbers n-2 (where n is the initial sample size) and with standard deviations that are extracted from the sampled data based on its MSE. See chapter 2 of reference [3] for details.
Robust linear regression
3 declarationsFinding a robust fit linear estimate between two samples. The procedure requires randomization and is based on the procedure described in the reference.
A wrapper that executes robustFit using a default random generator (meaning it is only pseudo-random)
Robust fit yielding also the R-square value of the "clean" dataset.
Related types
The robust fit algorithm used has various parameters that can be specified using the EstimationParameters record.
Constructors
EstimationParametersoutlierFraction :: !DoubleMaximal fraction of outliers expected in the sample (default 0.25)
shortIterationSteps :: !IntNumber of concentration steps to take for initial evaluation of a solution (default 3)
maxSubsetsNum :: !IntMaximal number of sampled subsets (pairs of points) to use as starting points (default 500)
groupSubsets :: !IntIf the initial sample is large, and thus gets subdivided, this is the number of candidate-estimations to take from each subgroup, on which complete convergence will be executed (default 10)
mediumSetSize :: !IntMaximal size of sample that can be analyzed without any sub-division (default 600)
largeSetSize :: !IntMaximal size of sample that does not require two-step sub-division (see reference article) (default 1500)
estimator :: EstimatorEstimator function to use (default linearRegression)
errorFunction :: ErrorFunctionErrorFunction to use (default linearRegressionError)
An ErrorFunction is a function that computes the error of a given point from an estimate. This module provides two error functions correspoinding to the two Estimator functions it defines:
Vertical distance squared via linearRegressionError that should be used with linearRegression
Total distance squared vie linearRegressionTLSError that should be used with linearRegressionTLS
An Estimator is a function that generates an estimated linear regression based on 2 samples. This module provides two estimator functions: linearRegression and linearRegressionTLS
An estimated linear relation between 2 samples is (alpha,beta) such that Y = alpha + beta*X.
Provided values
Default set of parameters to use (see reference for details).
linearRegression error function is the square of the vertical distance of a point from the line.
linearRegressionTLS error function is the square of the total distance of a point from the line.
Helper functions
Calculate the optimal (local minimum) estimate based on an initial estimate. The local minimum may not be the global (a.k.a. best) estimate but starting from enough different initial estimates should yield the global optimum eventually.
References
0 declarationsTwo Dimensional Euclidean Regression (Stein) http://www.dspcsp.com/pubs/euclreg.pdf
Computing LTS Regression For Large Data Sets (Rousseeuw and Driessen) http://agoras.ua.ac.be/abstract/Comlts99.htm
Applied linear statistical models (Kutner et al.)