Re: [R] nonlinear regression: nls, gnls, gnm, other?

From: Turner, Heather <>
Date: Tue 16 Jan 2007 - 09:29:00 GMT

Hi Johann,

The current version of gnm is unable to fit this type of model, though a new version with more flexibility is soon to be released.

In any case, you probably want to use nls or gnls, depending on the assumptions that can be made about the model errors. For nls it is usual to assume that the errors are normally distributed with mean zero and constant variance, though the normal assumption is not strictly necessary. If you have reason to think the errors are correlated and/or have unequal variances, then gnls would be appropriate.

The examples on ?nls may be enough to get you started,


-----Original Message-----
[] On Behalf Of Johann Hibschman Sent: 16 January 2007 04:05
To: Turner, Heather; r-help
Subject: [R] nonlinear regression: nls, gnls, gnm, other?

Hi all,

I'm trying to fit a nonlinear (logistic-like) regression, and I'd like to get some recommendations for which package to use.

The expression I want to fit is something like:

y ~ A * exp(X * Beta1) / (1 + exp(-(x + X * Beta2 - xmid)/scal))

Basically, it's a logistic function, but I want to be able to modify the saturation amplitude by a few parameters (Beta1) and shift the inflection point around with a few other parameters (Beta2). I have a ton of data, but I often have trouble getting the routine to fit.
(I've been using nlin in SAS, which seems sloppier in terms of
accepted convergence.)

Now, from what I can tell, I can use nls, gnls, or gnm to fit something like this, but I can't tell which would be better, or if there's something else I should be trying. To do this right, though, I have to do a lot more reading, but I'd like to know where to start.

(I have more of a physics/computer background, so I immediately jump
to thinking of regression as minimizing some cost function across a multidimensional space and then start mumbling about simulated annealing or some such, but this isn't helping me much in interpreting the available literature.)

So, does anyone have any suggestions? I imagine I'm going to have to pick up a book, but should it be Pinheiro & Bates on nlme, Bates & Watts, the pdf manual to gnm, or what?

Thanks for any suggestions,

Johann mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue Jan 16 20:39:27 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 16 Jan 2007 - 10:30:29 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.