Products & Services Industries Academia Support User Community Company

Learn more about Statistics Toolbox   

nlinfit - Nonlinear regression

Syntax

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 b, 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:

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.

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.

See Also

nlparci, nlpredci, nlintool

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

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