Nonlinear Regression

Nonlinear regression refers to a regression wherein the dependent (response) variable depends in a nonlinear way on the regression coefficients. The dependence on the independent (predictor) variable is irrelevant when you're trying to decide whether or not a linear or nonlinear fit is required. A fit of the form

is nonlinear because b appears in the exponent but the form

is linear even though sin(x) and cos(x) are nonlinear functions because y varies only linearly with the coefficients a and b.

If for some reason we suspected the pump calibration curve varied in an exponential form like the one above then we can pass such a form to the FIT function along with a starting guess for the coefficients. Before you check out the code, keep in mind two very important features of nonlinear fits:

Here's a simple example using the exponential form given above:

fobj = fit(k', Y', 'a*exp(b*x)', 'Start', [1 1])

fobj =

    General model:

     fobj(x) = a*exp(b*x)

     Coefficients (with 95% confidence bounds):

       a =       1.813  (0.4084, 3.217)

       b =      0.3831  (0.2045, 0.5616)

errorbar(k, Y, eY, eY, ek, ek, 'ko')

hold on

plot(fobj, 'r')

hold off

axis square

xlabel('Knob Setting')

ylabel('Discharge Rate (mL/s)')

legend('data', 'fit', 'Location', 'Northwest')