Home > Technology peripherals > AI > body text

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

王林
Release: 2024-01-22 18:30:21
forward
1357 people have browsed it

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
Copy after login
多元线性回归概念分析 多元线性回归模型

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)
Copy after login

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!

Related labels:
source:163.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!