Home  >  Article  >  Technology peripherals  >  In-depth analysis of the concepts and applications of multiple linear regression models

In-depth analysis of the concepts and applications of multiple linear regression models

王林
王林forward
2024-01-22 18:30:211311browse

Multiple linear regression is the most common form of linear regression and is used to describe how a single response variable Y exhibits a linear relationship with multiple predictor variables.

Examples of applications where multiple regression can be used:

The selling price of a house can be affected by factors such as location, number of bedrooms and bathrooms, year of construction, lot size, and more.

2. The height of a child depends on the height of the mother, the height of the father, nutrition and environmental factors.

Multiple linear regression model parameters

Consider a multiple linear regression model with k independent predictor variables x1, x2..., xk and a response variable y.

多元线性回归概念分析 多元线性回归模型

Suppose we have n observations for k 1 variables, and n variables should be greater than k.

多元线性回归概念分析 多元线性回归模型

The basic goal of least squares regression is to fit the hyperplane into the (k 1)-dimensional space to minimize the sum of squared residuals .

多元线性回归概念分析 多元线性回归模型

#Before differentiating the model parameters, set them to zero and derive the least squares normal equation that the parameters must satisfy.

These equations are formulated with the help of vectors and matrices.

多元线性回归概念分析 多元线性回归模型

The linear regression model is written as follows:

多元线性回归概念分析 多元线性回归模型

Online In linear regression, least squares parameter estimation b

多元线性回归概念分析 多元线性回归模型

Imagine that the columns of changing. We wish to find the "best" b that minimizes the sum of squared residuals.

The smallest possible sum of squares is zero.

多元线性回归概念分析 多元线性回归模型

Here y is the estimated response vector.

The code implements multiple linear regression on the data set data2

data2 data set

多元线性回归概念分析 多元线性回归模型

dataset=read.csv('data2.csv')
dataset$State=factor(dataset$State,
levels=c('New York','California','Florida'),
labels=c(1,2,3))
dataset$State
多元线性回归概念分析 多元线性回归模型

library(caTools)
set.seed(123)
split=sample.split(dataset$Profit,SplitRatio=0.8)
training_set=subset(dataset,split==TRUE)
test_set=subset(dataset,split==FALSE)
regressor=lm(formula=Profit~.,
data=training_set)
y_pred=predict(regressor,newdata=test_set)

The above is the detailed content of In-depth analysis of the concepts and applications of multiple linear regression models. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:163.com. If there is any infringement, please contact admin@php.cn delete