ols#
- swordfish.function.ols()#
Return the result of an ordinary-least-squares regression of Y on X.
Note that null values in X and Y are treated as 0 in calculations.
- Parameters:
Y (Constant) – A vector indicating the dependent variable.
X (Constant) – A vector/matrix/table/tuple indicating the independent variable(s).
intercept (Constant, optional) – A Boolean variable indicating whether the regression includes the intercept. If it is true, the system automatically adds a column of 1’s to X to generate the intercept. The default value is true.
mode (Constant, optional) –
An integer indicating the contents in the output. It can be:
0 (default): a vector of the coefficient estimates.
1: a table with coefficient estimates, standard error, t-statistics, and p-values.
2: a dictionary with the following keys: ANOVA, RegressionStat, Coefficient and Residual.
method (Constant, optional) –
A string indicating the method for the ordinary-least-squares regression problem.
When set to “default” (by default), ols solves the problem by constructing coefficient matrices and inverse matrices.
When set to “svd”, ols solves the problem by using singular value decomposition.
usePinv (Constant, optional) –
A Boolean value indicating whether to use pseudo-inverse method to calculate inverse of a matrix.
true (default): computing the pseudo-inverse of the matrix. It must be true for singular matrices.
false: computing the inverse of the matrix, which is only applicable to non-singular matrices.