Main Content

nlparci

Nonlinear regression parameter confidence intervals

Syntax

ci = nlparci(beta,resid,'covar',sigma)
ci = nlparci(beta,resid,'jacobian',J)
ci = nlparci(...,'alpha',alpha)

Description

ci = nlparci(beta,resid,'covar',sigma)returns the 95% confidence intervalscifor the nonlinear least squares parameter estimatesbeta. Before callingnlparci, usenlinfitto fit a nonlinear regression model and get the coefficient estimatesbeta, residualsresid, and estimated coefficient covariance matrixsigma.

ci = nlparci(beta,resid,'jacobian',J)is an alternative syntax that also computes 95% confidence intervals.Jis the Jacobian computed bynlinfit. If the'robust'option is used withnlinfit, use the'covar'input rather than the'jacobian'input so that the requiredsigmaparameter takes the robust fitting into account.

ci = nlparci(...,'alpha',alpha)returns100(1-alpha)% confidence intervals.

nlparcitreatsNaNs inresidorJas missing values, and ignores the corresponding observations.

The confidence interval calculation is valid for systems where the length ofresidexceeds the length ofbetaandJhas full column rank. WhenJis ill-conditioned, confidence intervals may be inaccurate.

Examples

collapse all

Suppose you have data, and want to fit a model of the form

y i = a 1 + a 2 exp ( - a 3 x i ) + ϵ i .

a i are the parameters you want to estimate, x i are the data points, y i are the responses, and ε 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 parametersa = [1;3;2], with thexdata points distributed exponentially with parameter2, and normally distributed noise with standard deviation0.1:

rng(9845,'twister')% for reproducibilitya = [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 guessa0 = [2;2;2]:

a0 = [2;2;2]; [ahat,r,J,cov,mse] = nlinfit(x,y,mdl,a0); ahat
ahat =3×11.0153 3.0229 2.1070

Check whether[1;3;2]is in a 95% confidence interval using the Jacobian argument innlparci:

ci = nlparci(ahat,r,'Jacobian',J)
ci =3×20.9869 1.0438 2.9401 3.1058 1.9963 2.2177

You can obtain the same result using the covariance argument:

ci = nlparci(ahat,r,'covar',cov)
ci =3×20.9869 1.0438 2.9401 3.1058 1.9963 2.2177

版本历史

Introduced before R2006a

See Also

|