Sei sulla pagina 1di 1

20/04/2011 Nonlinear regression - MATLAB

nlinfit
Nonlinear regression

Syntax
Products & Services Solutions Academ ia Support User Com m unity Com pany
beta = nlinfit(X,y,fun,beta0)
[beta,r,J,COVB,mse] = nlinfit(X,y,fun,beta0)
[...] = nlinfit(X,y,fun,beta0,options)

Description
beta = nlinfit(X,y,fun,beta0) returns a vector beta of coefficient estimates for a nonlinear regression of the responses in y on the predictors in X using the
model specified by fun. X is an n-by-p matrix of p predictors at each of n observations. y is an n-by-1 vector of observed responses. fun is a function handle to a
function of the form:
yhat = modelfun(b,X)

where b is a coefficient vector. beta0 is a vector containing initial values for the coefficients. beta is the same length as beta0.

[beta,r,J,COVB,mse] = nlinfit(X,y,fun,beta0) returns the fitted coefficients beta, the residuals r, the Jacobian J of fun, the estimated covariance matrix COVB
for the fitted coefficients, and an estimate mse of the variance of the error term. You can use these outputs with nlpredci to produce error estimates on predictions,
and with nlparci to produce error estimates on the estimated coefficients. If you use the robust fitting option (see below), you must use COVB and may need mse as
input to nlpredci or nlparci to insure that the confidence intervals take the robust fit properly into account.

[...] = nlinfit(X,y,fun,beta0,options) specifies control parameters for the algorithm used in nlinfit. options is a structure created by a call to statset.
Applicable statset parameters are:

'DerivStep' — Relative difference used in finite difference gradient calculation. May be a scalar, or a vector the same size as beta0. The default is eps^(1/3).

'Display' — Level of display output during estimation. The choices are

'off' (default) — Displays no information

'final' — Displays information after the final iteration

'iter' — Displays information at each iteration

'FunValCheck' — C heck for invalid values, such as NaN or Inf, from the objective function. Values are 'off' or 'on' (the default).

'MaxIter' — Maximum number of iterations allowed. The default is 100.

'Robust' — Invoke robust fitting option. Values are 'off' (the default) or 'on'.

'TolFun' — Termination tolerance on the residual sum of squares. The defaults is 1e-8.

'TolX' — Termination tolerance on the estimated coefficients beta. The default is 1e-8.

'Tune' — The tuning constant used in robust fitting to normalize the residuals before applying the weight function. The value is a positive scalar, with the default
value dependent on the weight function. This parameter is required if the weight function is specified as a function handle.
'WgtFun' — A weight function for robust fitting. Valid only when 'Robust' is 'on'. It can be 'bisquare' (the default), 'andrews', 'cauchy', 'fair', 'huber',
'logistic', 'talwar', or 'welsch'. It can also be a function handle that accepts a normalized residual as input and returns the robust weights as output.

nlinfit treats NaNs in y or modelfun(beta0,X) as missing data and ignores the corresponding rows.

nlintool is a graphical user interface to nlinfit.

Algorithms
nlinfit uses the Levenberg-Marquardt algorithm [1] for nonlinear least squares to compute non-robust fits.

For robust fits, nlinfit uses an algorithm [2] that iteratively refits a weighted nonlinear regression, where the weights at each iteration are based on each
observation's residual from the previous iteration. These weights serve to downweight points that are outliers so that their influence on the fit is decreased. Iterations
continue until the weights converge. The computation of weights is identical to the iterative reweighting scheme used by robustfit for fitting a robust linear model,
and in particular, the possible weighting functions and their tuning parameters are the same. The nonlinear regression at each iteration is a weighted version of the L-M
algorithm that nlinfit uses for non-robust fits.

Examples
The data in reaction.mat are partial pressures of three chemical reactants and the corresponding reaction rates. The function hougen implements the nonlinear
Hougen-Watson model for reaction rates. The following fits the model to the data:
load reaction

beta = nlinfit(reactants,rate,@hougen,beta)
beta =
1.2526
0.0628
0.0400
0.1124
1.1914
References
[1] Seber, G. A. F., and C . J. Wild. Nonlinear Regression. Hoboken, NJ: Wiley-Interscience, 2003.

[2] DuMouchel, W. H., and F. L. O'Brien. "Integrating a Robust Option into a Multiple Regression C omputing Environment." Computer Science and Statistics:
Proceedings of the 21st Symposium on the Interface. Alexandria, VA: American Statistical Association, 1989.

[3] Holland, P. W., and R. E. Welsch. "Robust Regression Using Iteratively Reweighted Least-Squares." Communications in Statistics: Theory and Methods, A6, 1977,
pp. 813–827.

See Also
nlintool | nlparci | nlpredci

© 1984-2011- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS

mathworks.com/help/…/nlinfit.html 1/1

Potrebbero piacerti anche