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

4 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Star Strider
Star Strider el 29 de Sept. de 2016
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 comentarios
Tushar Agarwal
Tushar Agarwal el 1 de Oct. de 2016
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 el 1 de Oct. de 2016
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.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by