当前位置:网站首页>R language book learning 03 "in simple terms R language data analysis" - Chapter 7 linear regression model
R language book learning 03 "in simple terms R language data analysis" - Chapter 7 linear regression model
2022-06-11 21:52:00 【Deep bamboo breeze】
Be careful : Classic models and R Language codes have been learned in other books , Don't take too many notes .
1 Linear regression
1.1 Establish and draw map analysis data
library(e1071)
library(plyr)
library(ggplot2)In the book , First, the missing value is judged . Then the graph analysis is carried out .
Use boxplot() Package drawing box line diagram , Use ggplot2 Package drawing histogram , Use density() Calculate the density value of the data and use plot() Function drawing , Finally, I use ggplot2 Draw a scatter plot .
1.2 Build a linear model
1. The simple way to use it is to ggplot2 Used in the bag stat_smooth function , Such as stat_smooth(method="lm",col="red",size=1)
2. in addition , You can directly build a linear model and use summary Function to get details .
model<-lm(x~y+z,data=newdata)1.3 Perform graphic diagnostics

- The residual diagram is used to show the difference between the predicted results of the model and the real results .
- Use QQ Fig. check whether the data meet the assumption of normal distribution .
- The proportional position map is used to show the relationship between the normalized residuals and the predicted values .
- Residuals Leverage Graphs are used to measure the importance of data .
1.4 prediction model
In general Data sets account for 70%, Test set accounts for 30%. Because the sampling code is classic , So record .
set.seed(123)
trainingrowindex<-sample(1:nrow(newdata),0.7*nrow(newdata))
trainingData<-newdata[trainingrowindex, ]
testData<-newdata[-trainingrowindex, ]The model code
mod<-lm(x~y+z, data=traindata)
predict<-predict(mod,testdata)
summary(mod)1.5 summary
Linear regression is the most commonly used statistical model in regression models , Describes the linear relationship between data . To make the model more stable , Cross validation can be used for modeling , And then get more stable model results .
2 Logical regression
边栏推荐
猜你喜欢

RPA+低代码为何是加速财务数字化转型之利器?

华为设备配置HoVPN

行而不辍,未来可期|云扩科技入选上海市专精特新企业

Release of version 5.6 of rainbow, add multiple installation methods, and optimize the topology operation experience

How does the chief financial officer of RPA find the "super entrance" of digital transformation?

Leetcode-43- string multiplication

如何使用事物码 SAT 查找某个 SAPGUI 屏幕字段对应的后台存储数据库表的名称试读版

联调这夜,我把同事打了...

R语言书籍学习03 《深入浅出R语言数据分析》-第八章 逻辑回归模型 第九章 聚类模型

Leetcode-104- maximum depth of binary tree
随机推荐
建造者模式
Expérience 10 génération de courbes bezier - amélioration expérimentale - génération de courbes B - spline par point de contrôle
238.除自身以外数组的乘积
Leetcode-104- maximum depth of binary tree
Experiment 10 Bezier curve generation - experiment improvement - control point generation of B-spline curve
网络连接正常但百度网页打不开显示无法访问此网站解决方案
Leetcode - 第2天
Latex combat notes 3- macro package and control commands
bzoj3188 Upit
Redis Foundation
JVM | introduction
R语言书籍学习03 《深入浅出R语言数据分析》-第七章 线性回归模型
How does the chief financial officer of RPA find the "super entrance" of digital transformation?
Flutter series: detailed explanation of container layout commonly used in flutter
LeetCode-104-二叉树的最大深度
Leetcode-98- validate binary search tree
String copy function
Nmap进行主机探测出现网段IP全部存活情况分析
LabVIEW Arduino electronic weighing system (project Part-1)
Cdr2022 serial number coreldraw2022 green key