95% confidence interval on a linear regression with polyfit?

조회 수: 68 (최근 30일)
Jesse
Jesse 2014년 9월 8일
편집: Chad Greene 2018년 8월 6일
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
Jesse
Jesse 2014년 9월 17일
Awesome - standing by!
Jesse
Jesse 2014년 9월 17일
편집: Jesse 2014년 9월 17일
Ok Star Strider - response sent.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by