当前位置:网站首页>How to create a linear model prediction interval in R and visualize it

How to create a linear model prediction interval in R and visualize it

2022-06-24 18:38:00 Mrrunsen

Linear regression model can For two things :

(1) Quantify the relationship between one or more predictors and response variables .

(2) Use models to predict future values .

About (2), When we use regression models to predict future values , We usually predict The exact value as well as An interval containing a series of possible values Interested in . This interval is called Prediction interval .

for example , Suppose we use Learning time As a predictive variable , Test results As a response variable to fit a simple linear regression model . Using this model , We can predict a learning 6 Hours of students will receive 91 The test results of .

however , Due to the uncertainty of this forecast , We might create a prediction interval , It means learning 6 Hours of students have 95% The opportunity to get 85 To 97 Between the exam results . This range of values is called 95% The prediction interval , It is usually better for us than ​​ It's more useful just to know the exact predicted value .

How to be in R Create forecast interval in
To show how R Create forecast interval in , We're going to use the built-in mtcars Data sets , It contains information about several different car features :

First , We will fit a simple linear regression model , Use disp As a predictive variable , mpg As a response variable .

#fit simple linear regression model
model <- lm
原网站

版权声明
本文为[Mrrunsen]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206241324227620.html