95% confidence interval on a linear regression with polyfit?
68 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jesse
el 8 de Sept. de 2014
Editada: Chad Greene
el 6 de Ag. de 2018
Greetings once again all,
Pardon the title line, but if it shows confusion on my end, it's because I am!
I am trying to find a 95% confidence interval on my data set of 15 values. I did use polyfit to receive the slope and intercept, so I take it the next steps are the standard error and the t-test/Student's T-distribution (???).
But, there are so many functions and methods out there (I've done a search) it's confusing to me as I am doing this for the first time.
I do have some code already, and I'd like to get this nailed down and understand the concepts behind it.
[p2,S2] = polyfit(Data1,Data2(:,3),1);
slope_p2 = p2(1);
intercept_p2= p2(2);
Just stuck on what to do after this. I see suggestions for lscov, polyconf, fitlm, and the list goes on.
Any suggestions and teaching points would be very helpful. And I do have the statistics toolbox if that helps.
Thanks!
0 comentarios
Respuesta aceptada
Star Strider
el 8 de Sept. de 2014
Editada: Star Strider
el 8 de Sept. de 2014
If you want to do a linear regression and you have the Statistics Toolbox, my choice would be the regress function. If you ask it, you can get the regression coefficients and their confidence intervals, and the confidence intervals on the fit, as well as other statistics. All that information is in the documentation, so I won’t repeat it here.
If you want to stay with polyfit and polyval, asking polyval for ‘delta’ produces what appear from the documentation as standard errors of the estimate for various estimated values of y. You can calculate the 95% confidence intervals using the inverse t-statistic with n-2 degrees of freedom, n being the number of data pairs. Multiply each ‘delta’ by the same t-score.
If you want the 95% confidence limits on the parameter estimates calculated by polyfit, the File Exchange function polyparci can provide them.
8 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!