# 多元线性回归

## App

 Regression Learner Train regression models to predict data using supervised machine learning

## 对象

 `LinearModel` Linear regression model `CompactLinearModel` Compact linear regression model `RegressionLinear` Linear regression model for high-dimensional data `RegressionPartitionedLinear` Cross-validated linear regression model for high-dimensional data

## 函数

#### 创建 `LinearModel` 对象

 `fitlm` 拟合线性回归模型 `stepwiselm` Perform stepwise regression

#### 创建 `CompactLinearModel` 对象

 `compact` Compact linear regression model

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

 `addTerms` Add terms to linear regression model `removeTerms` Remove terms from linear regression model `step` Improve linear regression model by adding or removing terms

#### 预测响应

 `feval` Predict responses of linear regression model using one input for each predictor `predict` Predict responses of linear regression model `random` Simulate responses with random noise for linear regression model

#### 计算线性模型

 `anova` Analysis of variance for linear regression model `coefCI` Confidence intervals of coefficient estimates of linear regression model `coefTest` Linear hypothesis test on linear regression model coefficients `dwtest` Durbin-Watson test with linear regression model object

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

 `plot` Scatter plot or added variable plot of linear regression model `plotAdded` Added variable plot of linear regression model `plotAdjustedResponse` Adjusted response plot of linear regression model `plotDiagnostics` Plot observation diagnostics of linear regression model `plotEffects` Plot main effects of predictors in linear regression model `plotInteraction` Plot interaction effects of two predictors in linear regression model `plotPartialDependence` Create partial dependence plot (PDP) and individual conditional expectation (ICE) plots `plotResiduals` Plot residuals of linear regression model `plotSlice` Plot of slices through fitted linear regression surface

#### 创建对象

 `fitrlinear` Fit linear regression model to high-dimensional data

#### 使用 `RegressionLinear` 对象

 `predict` Predict response of linear regression model `loss` Regression loss for linear regression models `plotPartialDependence` Create partial dependence plot (PDP) and individual conditional expectation (ICE) plots `selectModels` Select fitted regularized linear regression models

#### 使用 `RegressionPartitionedLinear` 对象

 `kfoldLoss` Regression loss for observations not used in training `kfoldPredict` Predict responses for observations not used for training

#### 拟合和计算线性回归

 `dwtest` Durbin-Watson test with residual inputs `invpred` Inverse prediction `linhyptest` Linear hypothesis test `plsregress` Partial least-squares regression `regress` 多元线性回归 `regstats` Regression diagnostics `relieff` Rank importance of predictors using ReliefF or RReliefF algorithm `robustfit` Fit robust linear regression `stepwisefit` Fit linear regression model using stepwise regression

#### 准备数据

 `x2fx` Convert predictor matrix to design matrix `dummyvar` Create dummy variables

#### 交互式工具

 `robustdemo` Interactive robust regression `rsmdemo` Interactive response surface demonstration `rstool` Interactive response surface modeling `stepwise` Interactive stepwise regression

## 主题

### 线性回归简介

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.

Stepwise Regression

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

Reduce Outlier Effects Using Robust Regression

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

Choose a Regression Function

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

Summary of Output and Diagnostic Statistics

Evaluate a fitted model by using model properties and object functions.

Wilkinson Notation

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

### 线性回归工作流

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

Analyze Time Series Data

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

Train Linear Regression Model

Train linear regression model using `fitlm` to analyze in-memory data and out-of-memory data.

### 偏最小二乘回归

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.