Y is the dependent variable. It is a vector.

X is the independent variable(s). X can be a matrix, table or tuple. When X is a matrix, if the number of rows is the same as the length of Y, each column of X is a factor; If the number of columns equals the length of Y, each row of X is a factor.

params is the regression estimator.

intercept (optional) is a Boolean variable indicating whether to include an intercept in the regression. The default value is true, meaning that the system automatically adds a column of "1" to X to generate the intercept.


Return the residuals from the least squares regression of Y on X.

  • For an in-memory table, the residuals can be obtained setting mode=2 in function ols or wls;

  • For a DFS table, the residuals can only be obtained with function residual.


x1=1 3 5 7 11 16 23
x2=2 8 11 34 56 54 100
y=0.1 4.2 5.6 8.8 22.1 35.6 77.2

params=ols(y, x1);
// output

params1=ols(y, (x1,x2),false);
// output

x=matrix(1 4 8 2 3, 1 4 2 3 8, 1 5 1 1 5);
p1=ols(1..5, x);
residual(1..5, x,p1);
// output