fitlm
Fit a linear regression model.
📝Syntax
mdl = fitlm(X, y)
mdl = fitlm(X, y, modelspec)
mdl = fitlm(X, y, ..., Name, Value)
yfit = predict(mdl, Xnew)
📄Description

fitlm creates a LinearModel object from numeric predictors X and response y.

Supported model specifications include constant, linear, interactions, quadratic, purequadratic, and numeric term matrices. Name-value arguments include Intercept, PredictorNames, and ResponseName.

💡Examples
X = [1 2; 2 1; 3 4; 4 3; 5 6; 6 5];
y = 1 + 2 * X(:,1) - 3 * X(:,2);
mdl = fitlm(X, y);
yfit = predict(mdl, [7 8; 8 7])
🔗See Also
regressregstatsrobustfit
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub