This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Multiple Linear Regression

Linear regression with multiple predictor variables

For greater accuracy on low-dimensional through medium-dimensional data sets, fit a linear regression model using fitlm.

For reduced computation time on high-dimensional data sets, fit a linear regression model using fitrlinear.


Regression LearnerTrain regression models to predict data using supervised machine learning


LinearModelLinear regression model
CompactLinearModelCompact linear regression model
RegressionLinearLinear regression model for high-dimensional data
RegressionPartitionedLinearCross-validated linear regression model for high-dimensional data


expand all

Create LinearModel Object

fitlmFit linear regression model
stepwiselm Fit linear regression model using stepwise regression

Create CompactLinearModel Object

compactCompact linear regression model

Add or Remove Terms from Linear Model

addTermsAdd terms to linear regression model
removeTermsRemove terms from linear regression model
stepImprove linear regression model by adding or removing terms

Predict Responses

fevalPredict responses of linear regression model using one input for each predictor
predictPredict responses of linear regression model
randomSimulate responses with random noise for linear regression model

Evaluate Linear Model

anovaAnalysis of variance for linear regression model
coefCIConfidence intervals of coefficient estimates of linear regression model
coefTestLinear hypothesis test on linear regression model coefficients
dwtestDurbin-Watson test with linear regression model object

Visualize Linear Model and Summary Statistics

plotScatter plot or added variable plot of linear regression model
plotAddedAdded variable plot of linear regression model
plotAdjustedResponseAdjusted response plot of linear regression model
plotDiagnosticsPlot observation diagnostics of linear regression model
plotEffectsPlot main effects of predictors in linear regression model
plotInteractionPlot interaction effects of two predictors in linear regression model
plotPartialDependenceCreate partial dependence plot (PDP) and individual conditional expectation (ICE) plots
plotResidualsPlot residuals of linear regression model
plotSlicePlot of slices through fitted linear regression surface

Create Object

fitrlinearFit linear regression model to high-dimensional data

Work with RegressionLinear Object

predictPredict response of linear regression model
lossRegression loss for linear regression models
plotPartialDependenceCreate partial dependence plot (PDP) and individual conditional expectation (ICE) plots
selectModelsSelect fitted regularized linear regression models

Work with RegressionPartitionedLinear Object

kfoldLossRegression loss for observations not used in training
kfoldPredictPredict responses for observations not used for training

Fit and Evaluate Linear Regression

dwtestDurbin-Watson test with residual inputs
invpredInverse prediction
linhyptestLinear hypothesis test
plsregressPartial least-squares regression
regressMultiple linear regression
regstatsRegression diagnostics
relieffRank importance of predictors using ReliefF or RReliefF algorithm
robustfitRobust regression
stepwisefitStepwise regression

Prepare Data

x2fxConvert predictor matrix to design matrix
dummyvarCreate dummy variables

Interactive Tools

robustdemoInteractive robust regression
rsmdemoInteractive response surface demonstration
rstoolInteractive response surface modeling
stepwiseInteractive stepwise regression


Linear Regression Workflow

Import and prepare data, fit a linear regression model, test and improve its quality, and share the model.

Interpret Linear Regression Results

Display and interpret linear regression output statistics.

Linear Regression with Interaction Effects

Construct and analyze a linear regression model with interaction effects and interpret the results.

Regression Using Tables

This example shows how to perform linear and stepwise regression analyses using tables.

Regression with Categorical Covariates

Perform a regression with categorical covariates using categorical arrays and fitlm.

What Is a Linear Regression Model?

Regression models describe the relationship between a dependent variable and one or more independent variables.

Linear Regression

Fit a linear regression model and examine the result.

Robust Regression — Reduce Outlier Effects

Fit a robust model that is less sensitive than ordinary least squares to large changes in small parts of the data.

Stepwise Regression

In stepwise regression, predictors are automatically added to or trimmed from a model.

Partial Least Squares

Partial least squares (PLS) constructs new predictor variables as linear combinations of the original predictor variables, while considering the observed response values, leading to a parsimonious model with reliable predictive power.

Partial Least Squares Regression and Principal Components Regression

This example shows how to apply Partial Least Squares Regression (PLSR) and Principal Components Regression (PCR), and discusses the effectiveness of the two methods.

Choose a Regression Function

Choose a regression function depending on the type of regression problem, and update legacy code using new fitting functions.

Time Series Regression of Airline Passenger Data

This example shows how to analyze time series data using Statistics and Machine Learning Toolbox™ features.

Wilkinson Notation

Wilkinson notation provides a way to describe regression and repeated measures models without specifying coefficient values.

Summary of Output and Diagnostic Statistics

Evaluate a fitted model by using model properties and object functions