95% confidence interval on a linear regression with polyfit?

72 次查看(过去 30 天)
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!

采纳的回答

Star Strider
Star Strider 2014-9-8
编辑:Star Strider 2014-9-8
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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by