regress

Statistics

Multiple linear regression via least squares. Solves y = X*b using normal equations. X is a design matrix (include a column of ones for intercept). Returns { b, residuals, r2 } with coefficients, residuals, and R-squared.

Syntax

regress(y, X)

Examples

y = [1; 2; 3; 4; 5]; X = [[1, 1]; [1, 2]; [1, 3]; [1, 4]; [1, 5]]; regress(y, X)
▶ Run
result = regress([2, 4, 6], [[1, 1]; [1, 2]; [1, 3]]); result.b
▶ Run

See Also

Try SimLab — Free MATLAB® Alternative

466 functions. Runs in your browser. No install.

Open SimLab

Stay Updated

Get notified about new simulations and tools. We send 1-2 emails per month.