Estimate confidence intervals after regress!
조회 수: 1 (최근 30일)
이전 댓글 표시
Hallo I did a linear regression using the command [B,BINT,R,RINT,STATS] = regress(Y,X)! How can estimate the confidence intervals??
댓글 수: 0
채택된 답변
Star Strider
2017년 9월 26일
The ‘BINT’ matrix contains the parameter confidence intervals.
If you want both parameter and prediction confidence intervals, use fitlm:
x = (1:10)'; % Create Data
y = 1.5 + 2.3*x + 1.5*randn(size(x)); % Create Data
mdl = fitlm(x, y); % Fit Data
B = mdl.Coefficients.Estimate; % Coefficients
CI = coefCI(mdl); % Coefficient Confidence Intervals
[Ypred,YCI] = predict(mdl, x); % Fitted Regression Line & Confidence Intervals
figure(1)
plot(x, y, 'pg')
hold on
plot(x, Ypred,'-r', x, YCI, '--r')
hold off
grid
댓글 수: 2
Jasmin McInerney
2021년 11월 21일
Thank you!
This answer shows how you can plot the confidence intervals with the traditional plotting command and associated functionality wich is super helpful :)
summary from Star Strider's answer:
after you've created your linear regression model ...
CI = coefCI(mdl); % Coefficient Confidence Intervals
[Ypred,YCI] = predict(mdl, x); % Fitted Regression Line & Confidence Intervals
figure
plot(x, YCI, '--r') % Plotting the confidence intervals!!
Star Strider
2021년 11월 21일
My pleasure!
Be sure to plot ‘Ypred’ as well. That provides a context for the confidence intervals.
.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!