Estimate confidence intervals after regress!
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Panos Ale
am 26 Sep. 2017
Kommentiert: Star Strider
am 21 Nov. 2021
Hallo I did a linear regression using the command [B,BINT,R,RINT,STATS] = regress(Y,X)! How can estimate the confidence intervals??
0 Kommentare
Akzeptierte Antwort
Star Strider
am 26 Sep. 2017
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 Kommentare
Jasmin McInerney
am 21 Nov. 2021
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
am 21 Nov. 2021
My pleasure!
Be sure to plot ‘Ypred’ as well. That provides a context for the confidence intervals.
.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!