How can i develop a Regression line with a confidence level bracket around this line?

4 ビュー (過去 30 日間)
I have a data set of temperature and energy use.
Temp Energy
I wanted to draw a scatter plot (which i could),and find a confidence level regression line over this scatter plot - any help? I want to see the shaded bracket around the regression line. I have just started with matlab, any help would be golden.

採用された回答

Star Strider
Star Strider 2016 年 9 月 29 日
I would use the polyfit and polyval functions for the regression, and the File Exchange contribution polypredci for the confidence intervals on the regression.
When you download polypredci, put it in your MATLAB user directory. That will allow you to use it as you would use any other function. On Windows computers, this is:
C:\Users\YourUserName\Documents\MATLAB\
  4 件のコメント
Tushar Agarwal
Tushar Agarwal 2016 年 10 月 1 日
Turn out I am still having an error with polypredci, as it curves the regression lines by the time it reaches the x and y axis. This is not correct for my analysis of the gas pump. The lines should be completely straight upto the two axis
Is there another method to draw a regression line with a confidence bracket around it? Answers are much appreciated. Thank you
Star Strider
Star Strider 2016 年 10 月 1 日
That is the accepted way to draw confidence intervals on the regression, because the uncertainty in the prediction increases with increasing distance from the mean of the x and y values. The built-in MATLAB routines in the Statistics and Machine Learning Toolbox and all the other statistics packages do the same. More data will make them straighter. (The ‘delta’ values calculated by polyval do the same, although I’ve never been able to figure out exactly what those are.)
How do you want to calculate the confidence intervals? One way might be to take ±1.96 times the standard error (standard deviation divided by the square root of the number of data points) of the y-data and draw lines parallel to the slope at those distances. This was the standard way to draw them back before computers made the precise computation of the confidence intervals easy.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by