• a polynomial model, see lobster.fun(2,deg)
• a loess fit, see lobster.fun(3)
Often, though, there are already standard models for certain types of relationships that have been used successfully in the past. For example, if our model is supposed to describe radioactive decay it makes good sense to use a model of the form y=ae-bt+e, a model suggested from Physics. Our dataset also describes a specific kind of relationship, a growth model, and such a relationship is often modeled using the equation

where
b0 is the expected value of y at time t=0
b1 is a measure of the growth rate, and
b2 is the expected limit of y as t
∞
This is often called the logistic or autocatalytic model
How do we fit such a model, that is find "optimal" values of b0, b1 and b2? Sometimes it is possible use transformations to "linearize" the model, for example we have of course log(y)=log(a)-bt for the radioactive decay model. This is not possible, though, for the logistic model, so we have to find a different solution.
Previously we have always used the method of least squares to estimate the parameters in our models, that is we minimized the "figure of merit"

We can extend this easily to our problem by minimizing

where f is the function describing the model and b is the vector of parameters.
For the linear model minimizing RSS is a simple exercise in Calculus. Unfortunately in more complicated situations minimizing RSS can no longer be done explicitely but has to be done numerically. In R we have a function built in to do it for use, namely nls. It is used in lobster.fun(4) to fit the growth model to the lobster data.
By default nls uses the Newton-Raphson algorithm to find the minimum of RSS. Newton's algorithm is one of the most famous methods in numerical analysis. It works as follows:
Say f(x) is a real-valued function in
n, and we wish to find a minimum (or more generally an extremal point) of f. Let Df be the gradient of f, that is Dfi(x) = d/dxi(f(x)) and let H be the Hessian matrix defined by H(x)ij = d2/dxidxj(f(x)). Then we have
• pick a starting point x0
• find xn+1 = xn - H-1(xn) Df(xn)
The Newton-Raphson algorithm is a more sophisticated version of this method.
The hardest part for using the nls function is finding a good starting point x0. (b0=100? b2=500?)
As an alternative to using least squares we could also have used maximum likelihood.