Confidence interval for linear regression
조회 수: 4 (최근 30일)
이전 댓글 표시
Hello, every body. I have a question here. I have a data set (attached excel file) I'm using the following code to estimate 95 and 99% confidence bound on poly fit. But it is not giving me the desired results because the real answer for this data gives confidence bound like hyperbolic form an example attached (in pdf) but this routine produces straight lines bounds. I have seen polyparci.m from the great star but couldn't follow it exactly (perhaps an example in same code would be beneficial). I'm interested in obtaining results similar to Figure on page 3 of attached pdf using equation given on the same page. I would really appreciate any help or guidance for this. Thank you in advance
fitresult = fit(x,y,'poly1');
p11 = predint(fitresult,x,0.95,'observation','off'); plot(fitresult,x,y), hold on, plot(x,p11,'m--'), xlim([3 6])
댓글 수: 0
채택된 답변
Star Strider
2016년 4월 13일
I appreciate the compliment! The polyparci function calculates the confidence intervals on the parameter estimates (for a linear model they would be the slope and intercept), not the fitted values. (The ‘delta’ output from polyval gives something, but I’ve not been able to decipher exactly what.)
See if this does what you want:
D = xlsread('amberly hadden test.xlsx');
x = D(:,1);
y = D(:,2);
[B,S] = polyfit(x, y, 1);
CI = polyparci(B,S);
fprintf(1, '\n\tParameter Estimates and Confidence Intervals:\n\t\t\t\t\t\tSlope\t\tIntercept')
fprintf(1, '\n\t\tUpper 95%%CI\t%.4f\t\t%.4f',CI(1,:))
fprintf(1, '\n\t\tParameter \t%.4f\t\t%.4f',B)
fprintf(1, '\n\t\tLower 95%%CI\t%.4f\t\t%.4f\n',CI(2,:))
I get this output:
Parameter Estimates and Confidence Intervals:
Slope Intercept
Upper 95% CI 1.2249 11586.5662
Parameter 1.2644 12624.5120
Lower 95% CI 1.3039 13662.4577
댓글 수: 6
Star Strider
2016년 4월 14일
My pleasure!
No worries, Amberly!
Answers was down to incorporate some upgrades, among which were to add the number of views a Question had, and the ability for those with 500 or more Reputation Points to ‘Unaccept’ an Answer after 7 days, and Accept another Answer. (The person who had the first accepted Answer retains the points from the original acceptance.) That’s a distinction without a difference for most people here.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!