本页对应的英文页面已更新,但尚未翻译。 若要查看最新内容,请点击此处访问英文页面。

多元线性回归

具有多个预测变量的线性回归

为了提高在中低维数据集上的准确度,可以使用 fitlm 拟合线性回归模型。

为了减少在高维数据集上的计算时间,可以使用 fitrlinear 拟合线性回归模型。

App

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

函数

全部展开

创建 LinearModel 对象

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

创建 CompactLinearModel 对象

compactCompact linear regression model

添加或删除线性模型中的项

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

预测响应

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

计算线性模型

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

可视化线性模型和汇总统计量

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

创建对象

fitrlinearFit linear regression model to high-dimensional data

使用 RegressionLinear 对象

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

使用 RegressionPartitionedLinear 对象

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

拟合和计算线性回归

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

准备数据

x2fxConvert predictor matrix to design matrix
dummyvarCreate dummy variables

交互式工具

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.

Linear Regression Using Tables

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

Linear 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.

偏最小二乘回归和主成分回归

此示例说明如何应用偏最小二乘回归 (PLSR) 和主成分回归 (PCR),并讨论这两种方法的有效性。当存在大量预测变量并且它们高度相关甚至共线时,PLSR 和 PCR 都可以作为建模响应变量的方法。这两种方法都将新的预测变量(称为成分)构建为原始预测变量的线性组合,但它们构建这些成分的方式不同。PCR 创建成分来解释在预测变量中观察到的变异性,而根本不考虑响应变量。而 PLSR 会考虑响应变量,因此常使模型能够拟合具有更少成分的响应变量。从实际应用上来说,这能否最终转化为更简约的模型要视情况而定。

Choose a Regression Function

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

Analyze Time Series Data

This example shows how to visualize and analyze time series data using a timeseries object and the regress function.

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.