confint and predint bounds trouble

Hi, I'm having trouble understanding how confint and predint work. I thought that since predint takes into account the uncertanty of a predicted measurement, the predint bounds would be broader than the confint bounds (for the same confidence level, i.e. 95%). But whenever I fit simple data and I draw the confint bounds I find them broader than the predint bounds (for any type of bounds.). So what is it that I'm missing out?

 Accepted Answer

Tom Lane
Tom Lane on 31 May 2012
CONFINT returns confidence intervals for the parameters. So if you fit y=a+b*x, you get confidence intervals for a and b.
PREDINT returns confidence intervals for predicted values. So if you supply x values x1,x2,x3, you get confidence intervals for the three quantities a+b*x1, a+b*x2, and a+b*x3.
There are options that allow PREDINT to produce either of the two things you describe in your question. You can use those options to get confidence intervals for either the curve at x=x2, or a new observation y2 taken at x=x2.

3 Comments

Thanks for the answer Tom.
What I'm trying to do is to use the confidence intervals for a and b to calculate the confidence interval of the curve like this (using your example f(x)=a+b*x):
da and db are the uncertainties of a and b:
da = amax-a
db = bmax-b
where max comes from the maximum confidence interval.
Then, by error propagation:
dy = da + x * db
When I draw the curves f(x)+dy and f(x)-dy I find that they are not the curves given by PREDINT for the same range of x values.
So, the question would be, why is the propagated uncertainty bigger than the predicted by PREDINT ?
PS: I didn't get the difference between "the curve at x=x2, or a new observation y2 taken at x=x2"
I add the code for a "simple" plot (I'change the roles of a and b):
X_DATA = (1:10)';
Y_DATA = [5.1 7.2 8.8 12 13.1 14.7 16.9 19.2 21.3 22.6]';
f_line = @(a,b,x) a.*x+b;
confidence_level = 0.95;
fittype_line = fittype( f_line );
[fit_line,gof,output] = fit(X_DATA,Y_DATA,fittype_line,'StartPoint',[2 3])
coef = coeffvalues(fit_line);
a = coef(1);
b = coef(2);
confint_line = confint(fit_line,confidence_level);
plot(fit_line,X_DATA,Y_DATA,'ko');
hold on;
X = (-10:20)';
plot(X,predint(fit_line,X,confidence_level,'observation','off'),'m--');
% error propagation:
deltaa = confint_line(2,1)-a;
deltab = confint_line(2,2)-b;
delta = abs( X ).*deltaa + deltab;
plot(X, f_line(a,b,X)+delta,'g--');
plot(X, f_line(a,b,X)-delta,'g--');
xlim([-10 20])
hold off;
The variance of a*X+b is var(a)*x^2+var(b)+2*x*cov(a,b). So variances add if you take the covariances into account. You have tried to add confidence interval widths, which is kind of like trying to add standard deviations, and that doesn't work.
As for the other question, suppose the function is f(x). Suppose a new observation is ynew=f(xnew)+errornew. There are PREDINT options to control if you want the interval to provide 95% confidence for either f(xnew) or f(xnew)+errornew.
I knew I was doing something wrong, I just didn't know what it was.
Thank you very much Tom!

Sign in to comment.

More Answers (0)

Categories

Products

Community Treasure Hunt

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

Start Hunting!