MATLAB: Estimate confidence intervals after regress!

regression confidence intervals

Hallo I did a linear regression using the command [B,BINT,R,RINT,STATS] = regress(Y,X)! How can estimate the confidence intervals??

Best Answer

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
Related Question