dataFrame.columns.stat — regression()
Description
The regression() method of the stat object fits a regression model between two selected columns.
Signature
dataFrame.columns(...columnNames).stat.regression({ model: 'linear' })Arguments
...columnNames( string[] )- The name of the columns from which to compute the regression.
options(object)- Regression model options.
Option
model(string)- The regression model used to estimate the relationship.
linear(default)theilSensiegelRepeatedMedian
Returns
regression(number)- A regression model object containing the estimated parameters.
slope(number)- The estimated slope coefficient.
intercept(number)- The estimated intercept coefficient.
Notes
- The method requires exactly two selected numeric columns.
- The first selected column is interpreted as the predictor variable.
- The second selected column is interpreted as the response variable.
- The
linearmodel uses ordinary least squares regression. - The
theilSenmodel provides a robust estimate of the slope based on pairwise slopes. - The
siegelRepeatedMedianmodel provides a highly robust estimate resistant to outliers. - The fitted model can be expressed as:
y = mx + b - Robust regression models are generally less sensitive to outliers than ordinary least squares regression.
Example
// evaluate the regression between the values of 2 columns of the dataFrame
var regression = dataFrame.columns('groupA', 'groupB').stat.regression();
// log the regression details
notebook.log(regression);