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

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Jan 16 11:02:10 CET 2007


On Tue, 16 Jan 2007, Turner, Heather wrote:

> 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.

nls is able to handle unequal variances since 2.3.0: from the help

  weights: an optional numeric vector of (fixed) weights.  When present,
           the objective function is weighted least squares.


>
> The examples on ?nls may be enough to get you started,
>
> Heather
>
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] 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
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list