Linear Module

Simple linear regression using straight lines: f(x) = a + bx.

Functions and values

Function or value Description

predict coef x

Full Usage: predict coef x

Parameters:
    coef : Coefficients - vector of coefficients, sorted as [intercept;slope]
    x : float - x value of which the corresponding y value should be predicted

Returns: float predicted y value with given coefficients at X=x

Takes vector of [intercept; slope] and x value to predict the corresponding y value

Equal to OLS.Linear.Univariable.predict!

coef : Coefficients

vector of coefficients, sorted as [intercept;slope]

x : float

x value of which the corresponding y value should be predicted

Returns: float

predicted y value with given coefficients at X=x

Example

 
   // e.g. days since experiment start
   let xData = vector [|1. .. 100.|]
   // e.g. plant size in cm
   let yData = vector [|4.;7.;8.;9.;7.;11.; ...|]
   
   // Estimate the intercept and slope of a line, that fits the data.
   let coefficients = 
       LinearRegression.RobustRegression.Linear.theilEstimator xData yData
   
   // Predict the size on day 10.5
   LinearRegression.RobustRegression.Linear.predict coefficients 10.5

theilEstimator xData yData

Full Usage: theilEstimator xData yData

Parameters:
    xData : Vector<float> - vector of x values
    yData : Vector<float> - vector of y values

Returns: Coefficients vector of polynomial coefficients sorted as [intercept;constant;quadratic;...]

Calculates simple linear regression coefficients using theil's incomplete method in the form of [|intercept; slope;|]. Performs well if outlier corrupt the regression line.

Not robust if data count is low! http://195.134.76.37/applets/AppletTheil/Appl_Theil2.html

xData : Vector<float>

vector of x values

yData : Vector<float>

vector of y values

Returns: Coefficients

vector of polynomial coefficients sorted as [intercept;constant;quadratic;...]

Example

 
   // e.g. days since experiment start
   let xData = vector [|1. .. 100.|]
   // e.g. plant size in cm
   let yData = vector [|4.;7.;8.;9.;7.;11.; ...|]
   
   // Estimate the intercept and slope of a line, that fits the data.
   let coefficients = 
       LinearRegression.RobustRegression.Linear.theilEstimator xData yData

theilSenEstimator xData yData

Full Usage: theilSenEstimator xData yData

Parameters:
    xData : Vector<float> - vector of x values
    yData : Vector<float> - vector of y values

Returns: Coefficients vector of polynomial coefficients sorted as [intercept;constant;quadratic;...]

Calculates simple linear regression coefficients using the Theil-Sen estimator in the form of [|intercept; slope;|]. Performs well if outlier corrupt the regression line.

Not robust if data count is low!

xData : Vector<float>

vector of x values

yData : Vector<float>

vector of y values

Returns: Coefficients

vector of polynomial coefficients sorted as [intercept;constant;quadratic;...]

Example

 
   // e.g. days since experiment start
   let xData = vector [|1. .. 100.|]
   // e.g. plant size in cm
   let yData = vector [|4.;7.;8.;9.;7.;11.; ...|]
   
   // Estimate the intercept and slope of a line, that fits the data.
   let coefficients = 
       LinearRegression.RobustRegression.Linear.theilSenEstimator xData yData