[R] nls - find good starting values

Bill.Venables at csiro.au Bill.Venables at csiro.au
Tue Jul 14 09:56:33 CEST 2009


It is not at all clear what you are trying to do.

Fitting a gaussian distribution is the simplest problem in all of statistics: the sample mean and sample variance (divisor n) are the mle's of the two parameters involved.  No non-linear regresson is required.

If what you are really trying to do is fit a (normalized?) gaussian probability density function as a form of non-linear regression, i.e. by least squares, that is an entirely different problem.  I'm a bit stumped as to how this form of non-linear regresion should arise, particularly with equal variance both for values near the mode as well as in the tails, but stranger things have happened, I suppose.  What I would do is, if you response values are non-negative, take logs and regress using a quadratic regression model, and then identify the approximate mean and variance parameters, which should then be reasonable starting values for the non-linear regression.  Negative responses will pose a problem, of course.

Bill Venables.
________________________________________
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of Antje [niederlein-rstat at yahoo.de]
Sent: 14 July 2009 17:21
To: r-help at stat.math.ethz.ch
Subject: [R] nls - find good starting values

Hi there,

it might be a very simple question and I'd be glad to even get a link to
some useful documentation...
I have several data sets, I'd like to fit to a gaussian distribution.
I've tried to give an estimate of the mean and the sd of this
distribution but still, I run into problems if these estimates are not
close enough.

For example, nls() breaks with this message:
singular gradient matrix at initial parameter estimates

I don't know how to avoid these bad start values because their estimate
is automated. Better start values are often quite close.

I was wondering whether there is any way to test several start-values as
long as nls does not succeed.
I would do it with a while construct but maybe there is another approach?

Any hint is very welcome!

Ciao,
Antje

______________________________________________
R-help at r-project.org 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.




More information about the R-help mailing list