| Contents | Index |
[ypred,delta] = nlpredci(modelfun,x,beta,resid,'covar',sigma)
[ypred,delta] = nlpredci(modelfun,x,beta,resid,'jacobian',J)
[...] = nlpredci(...,param1,val1,param2,val2,...)
[ypred,delta] = nlpredci(modelfun,x,beta,resid,'covar',sigma) returns predictions, ypred, and 95% confidence interval half-widths, delta, for the nonlinear regression model defined by modelfun, at input values x. modelfun is a function handle, specified using @, that accepts two arguments—a coefficient vector and the array x—and returns a vector of fitted y values. Before calling nlpredci, use nlinfit to fit modelfun by nonlinear least squares and get estimated coefficient values beta, residuals resid, and estimated coefficient covariance matrix sigma.
[ypred,delta] = nlpredci(modelfun,x,beta,resid,'jacobian',J) is an alternative syntax that also computes 95% confidence intervals. J is the Jacobian computed by nlinfit. If the 'robust' option is used with nlinfit, use the 'covar' input rather than the 'jacobian' input so that the required sigma parameter takes the robust fitting into account.
[...] = nlpredci(...,param1,val1,param2,val2,...) accepts optional parameter name/value pairs.
| Parameter | Value |
|---|---|
| 'alpha' | A value between 0 and 1 that specifies the confidence level as 100(1-alpha)%. Default is 0.05. |
| 'mse' | The mean squared error returned by nlinfit. This is required to predict new observations (see 'predopt') if the robust option is used with nlinfit; otherwise, the 'mse' is computed from the residuals and does not take the robust fitting into account. |
| 'predopt' | Either 'curve' (the default) to compute confidence intervals for the estimated curve (function value) at x, or 'observation' for prediction intervals for a new observation at x. If 'observation'is specified after using a robust option with nlinfit, the 'mse' parameter must be supplied to specify the robust estimate of the mean squared error. |
| 'simopt' | Either 'on' for simultaneous bounds, or 'off' (the default) for nonsimultaneous bounds. |
nlpredci treats NaNs in resid or J as missing values, and ignores the corresponding observations.
The confidence interval calculation is valid for systems where the length of resid exceeds the length of beta and J has full column rank at beta. When J is ill-conditioned, predictions and confidence intervals may be inaccurate.
Fit to exponential decay
Suppose you have data, and want to fit a model of the form
yi = a1 + a2exp(–a3xi) + εi.
Here the ai are the parameters you want to estimate, xi are the data points, the yi are the responses, and the εi are noise terms.
Write a function handle that represents the model:
mdl = @(a,x)(a(1) + a(2)*exp(-a(3)*x));
Generate synthetic data with parameters a = [1;3;2], with the x data points distributed exponentially with parameter 2, and normally distributed noise with standard deviation 0.1:
rng(9845,'twister') % for reproducibility a = [1;3;2]; x = exprnd(2,100,1); epsn = normrnd(0,0.1,100,1); y = mdl(a,x) + epsn;
Fit the model to data starting from the arbitrary guess a0 = [2;2;2]:
a0 = [2;2;2];
[ahat,r,J,cov,mse] = nlinfit(x,y,mdl,a0);
ahat
ahat =
1.0153
3.0229
2.1070Find the predicted response yhat together with a 95% confidence interval about yhat, for the mean of x:
[ypred dlt] = nlpredci(mdl,mean(x),ahat,r,'Covar',cov)
ypred =
1.0669
dlt =
0.0231The 95% confidence interval about ypred is:
[ypred-dlt,ypred+dlt]
ans =
1.0438 1.0900
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |