Main Content

Multiple Linear Regression

Linear regression with multiple predictor variables

In a multiple linear regression model, the response variable depends on more than one predictor variable. You can perform multiple linear regression with or without the LinearModel object, or by using the Regression Learner app.

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.

Apps

Regression LearnerTrain regression models to predict data using supervised machine learning

Blocks

RegressionLinear PredictPredict responses using linear regression model (Since R2023a)
IncrementalRegressionLinear PredictPredict responses using incremental linear regression model (Since R2023b)
IncrementalRegressionLinear FitFit incremental linear regression model (Since R2023b)
Update MetricsUpdate performance metrics in incremental learning model given new data (Since R2023b)

Functions

expand all

Create LinearModel Object

fitlmFit linear regression model
stepwiselmPerform 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
partialDependenceCompute partial dependence (Since R2020b)

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

Gather Properties of Linear Model

gatherGather properties of Statistics and Machine Learning Toolbox object from GPU (Since R2020b)

Create Object

fitrlinearFit linear regression model to high-dimensional data

Work with RegressionLinear Object

predictPredict response of linear regression model
limeLocal interpretable model-agnostic explanations (LIME) (Since R2020b)
lossRegression loss for linear regression models
partialDependenceCompute partial dependence (Since R2020b)
plotPartialDependenceCreate partial dependence plot (PDP) and individual conditional expectation (ICE) plots
shapleyShapley values (Since R2021a)
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 (PLS) regression
regressMultiple linear regression
regstatsRegression diagnostics
relieffRank importance of predictors using ReliefF or RReliefF algorithm
robustfitFit robust linear regression
stepwisefitFit linear regression model using stepwise regression

Polynomial Curve Fitting

polyconfPolynomial confidence intervals
polyfitPolynomial curve fitting

Prepare Data

x2fxConvert predictor matrix to design matrix
dummyvarCreate dummy variables

Interactive Tools

polytoolInteractive polynomial fitting
robustdemoInteractive robust regression
rsmdemoInteractive response surface demonstration
rstoolInteractive response surface modeling
stepwiseInteractive stepwise regression

Objects

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

Topics

Introduction to Linear Regression

Linear Regression Workflows

Partial Least Squares Regression

  • 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
    Apply partial least squares regression (PLSR) and principal components regression (PCR), and explore the effectiveness of the two methods.