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.
The confidence bounds for fitted coefficients are given by
$$C=b\pm t\sqrt{S}$$
where b are the coefficients produced by the fit, t depends on the confidence level, and is computed using the inverse of Student's t cumulative distribution function, and S is a vector of the diagonal elements from the estimated covariance matrix of the coefficient estimates, (X^{T}X)^{–1}s^{2}. In a linear fit, X is the design matrix, while for a nonlinear fit X is the Jacobian of the fitted values with respect to the coefficients. X^{T} is the transpose of X, and s^{2} is the mean squared error.
The confidence bounds are displayed in the Results pane in the Curve Fitting app using the following format.
p1 = 1.275 (1.113, 1.437)
The fitted value for the coefficient p1
is
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
the confint
function.
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\pm f\sqrt{{s}^{2}+xS{x}^{T}}$$ |
$$y\pm f\sqrt{xS{x}^{T}}$$ |
Nonsimultaneous |
$$y\pm t\sqrt{{s}^{2}+xS{x}^{T}}$$ |
$$y\pm t\sqrt{xS{x}^{T}}$$ |
Where:
s^{2} is the mean squared error
t depends on the confidence level, and is computed using the inverse of Student's t cumulative distribution function
f depends on the confidence level, and is computed using the inverse of the F cumulative distribution function.
S is the covariance matrix of the coefficient estimates, (X^{T}X)^{–1}s^{2}.
x is 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 with Tools > Prediction Bounds. By default, the confidence level for the bounds is 95%. You can change this level to any value with Tools > Prediction Bounds > Custom.
You can display numerical prediction bounds of any type at the
command line with the predint
function.
To understand the quantities associated with each 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 value x_{n+1}. Call the new observation y_{n+1}(x_{n+1}) and the associated error ε_{n+1}. Then
y_{n+1}(x_{n+1}) = f(x_{n+1}) + ε_{n+1}
where f(x_{n+1}) is the true but unknown function you want to estimate at x_{n+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
y_{n+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 | y_{n+1}(x_{n+1}) |
Simultaneous | y_{n+1}(x), for all x | |
Function | Non-simultaneous | f(x_{n+1}) |
Simultaneous | f(x), for all x |
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 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.
p11 = predint(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), hold on, plot(x,p11,'m--'), xlim([0 5]), ylim([-1 5]) title('Nonsimultaneous Observation Bounds','FontSize',9) legend off subplot(2,2,2) plot(fitresult,x,y), hold on, plot(x,p12,'m--'), xlim([0 5]), ylim([-1 5]) title('Simultaneous Observation Bounds','FontSize',9) legend off subplot(2,2,3) plot(fitresult,x,y), hold on, plot(x,p21,'m--'), xlim([0 5]), ylim([-1 5]) title('Nonsimultaneous Functional Bounds','FontSize',9) legend off subplot(2,2,4) plot(fitresult,x,y), hold 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')