Main Content

Confidence and Prediction Bounds

About Confidence and Prediction Bounds

Curve Fitting Toolbox™ software lets you calculate confidence bounds for the fitted coefficients, and prediction bounds for new observations or for the fitted function. Additionally, for prediction bounds, you can calculate simultaneous bounds, which take into account all predictor values, or you can calculate nonsimultaneous bounds, which take into account only individual predictor values. The coefficient confidence bounds are presented numerically, while the prediction bounds are displayed graphically and are also available numerically.

The available confidence and prediction bounds are summarized below.

Types of Confidence and Prediction Bounds

Interval Type

Description

Fitted coefficients

Confidence bounds for the fitted coefficients

New observation

Prediction bounds for a new observation (response value)

New function

Prediction bounds for a new function value

Note

Prediction bounds are also often described as confidence bounds because you are calculating a confidence interval for a predicted response.

Confidence and prediction bounds define the lower and upper values of the associated interval, and define the width of the interval. The width of the interval indicates how uncertain you are about the fitted coefficients, the predicted observation, or the predicted fit. For example, a very wide interval for the fitted coefficients can indicate that you should use more data when fitting before you can say anything very definite about the coefficients.

The bounds are defined with a level of certainty that you specify. The level of certainty is often 95%, but it can be any value such as 90%, 99%, 99.9%, and so on. For example, you might want to take a 5% chance of being incorrect about predicting a new observation. Therefore, you would calculate a 95% prediction interval. This interval indicates that you have a 95% chance that the new observation is actually contained within the lower and upper prediction bounds.

Confidence Bounds on Coefficients

The confidence bounds for fitted coefficients are given by

C = b ± t S

wherebare the coefficients produced by the fit,tdepends on the confidence level, and is computed using the inverse of Student'stcumulative distribution function, andSis a vector of the diagonal elements from the estimated covariance matrix of the coefficient estimates, (XTX)–1s2. In a linear fit,Xis the design matrix, while for a nonlinear fitXis the Jacobian of the fitted values with respect to the coefficients.XTis the transpose ofX, ands2is the mean squared error.

The confidence bounds are displayed in theResultspane in the Curve Fitting app using the following format.

p1 = 1.275 (1.113, 1.437)

The fitted value for the coefficientp1is 1.275, the lower bound is 1.113, the upper bound is 1.437, and the interval width is 0.324. By default, the confidence level for the bounds is 95%.

You can calculate confidence intervals at the command line with theconfintfunction.

Prediction Bounds on Fits

As mentioned previously, you can calculate prediction bounds for the fitted curve. The prediction is based on an existing fit to the data. Additionally, the bounds can be simultaneous and measure the confidence for all predictor values, or they can be nonsimultaneous and measure the confidence only for a single predetermined predictor value. If you are predicting a new observation, nonsimultaneous bounds measure the confidence that the new observation lies within the interval given a single predictor value. Simultaneous bounds measure the confidence that a new observation lies within the interval regardless of the predictor value.

Bound Type Observation Functional
Simultaneous

y ± f s 2 + x S x T

y ± f x S x T

Nonsimultaneous

y ± t s 2 + x S x T

y ± t x S x T

Where:

  • s2is the mean squared error

  • tdepends on the confidence level, and is computed using the inverse of Student'stcumulative distribution function

  • fdepends on the confidence level, and is computed using the inverse of theFcumulative distribution function.

  • Sisthe covariance matrix of the coefficient estimates, (XTX)–1s2.

  • xis a row vector of the design matrix or Jacobian evaluated at a specified predictor value.

You can graphically display prediction bounds using Curve Fitting app. With Curve Fitting app, you can display nonsimultaneous prediction bounds for new observations withTools>Prediction Bounds. By default, the confidence level for the bounds is 95%. You can change this level to any value withTools>Prediction Bounds>Custom.

您可以显示数值prediction bounds of any type at the command line with thepredintfunction.

理解与每个相关的数量type of prediction interval, recall that the data, fit, and residuals are related through the formula

data=fit+residuals

where the fit and residuals terms are estimates of terms in the formula

data=model+random error

Suppose you plan to take a new observation at the predictor valuexn+1. Call the new observationyn+1(xn+1) and the associated errorεn+1. Then

yn+1(xn+1) =f(xn+1) +εn+1

wheref(xn+1) is the true but unknown function you want to estimate atxn+1. The likely values for the new observation or for the estimated function are provided by the nonsimultaneous prediction bounds.

If instead you want the likely value of the new observation to be associated with any predictor value, the previous equation becomes

yn+1(x) =f(x) +ε

The likely values for this new observation or for the estimated function are provided by the simultaneous prediction bounds.

The types of prediction bounds are summarized below.

Types of Prediction Bounds

Type of Bound

Simultaneous or Non-simultaneous

Associated Equation

Observation

Non-simultaneous

yn+1(xn+1)

Simultaneous

yn+1(x), for allx

Function

Non-simultaneous

f(xn+1)

Simultaneous

f(x), for allx

The nonsimultaneous and simultaneous prediction bounds for a new observation and the fitted function are shown below. Each graph contains three curves: the fit, the lower confidence bounds, and the upper confidence bounds. The fit is a single-term exponential to generated data and the bounds reflect a 95% confidence level. Note that the intervals associated with a new observation are wider than the fitted function intervals because of the additional uncertainty in predicting a new response value (the curve plus random errors).

Compute Prediction Intervals

Compute and plot observation and functional prediction intervals for a fit to noisy data.

Generate noisy data with an exponential trend.

x = (0:0.2:5)'; y = 2*exp(-0.2*x) + 0.5*randn(size(x));

Fit a curve to the data using a single-term exponential.

fitresult = fit(x,y,'exp1');

Compute 95% observation and functional prediction intervals, both simultaneous and nonsimultaneous. Non-simultaneous bounds are for individual elements of x; simultaneous bounds are for all elements of x.

侯=前dint(fitresult,x,0.95,'observation','off'); p12 = predint(fitresult,x,0.95,'observation','on'); p21 = predint(fitresult,x,0.95,'functional','off'); p22 = predint(fitresult,x,0.95,'functional','on');

Plot the data, fit, and prediction intervals. Observation bounds are wider than functional bounds because they measure the uncertainty of predicting the fitted curve plus the random variation in the new observation.

subplot(2,2,1) plot(fitresult,x,y), holdon, plot(x,p11,'m--'), xlim([0 5]), ylim([-1 5]) title('Nonsimultaneous Observation Bounds','FontSize',9) legendoffsubplot(2,2,2) plot(fitresult,x,y), holdon, plot(x,p12,'m--'), xlim([0 5]), ylim([-1 5]) title('Simultaneous Observation Bounds','FontSize',9) legendoffsubplot(2,2,3) plot(fitresult,x,y), holdon, plot(x,p21,'m--'), xlim([0 5]), ylim([-1 5]) title('Nonsimultaneous Functional Bounds','FontSize',9) legendoff次要情节(2,2,4)情节(fitresult, x, y)on, plot(x,p22,'m--'), xlim([0 5]), ylim([-1 5]) title('Simultaneous Functional Bounds','FontSize',9) legend({'Data','Fitted curve','Prediction intervals'},...'FontSize',8,'Location','northeast')