Re: [R] linear gradient in nls

From: Douglas Bates <bates_at_stat.wisc.edu>
Date: Fri 29 Sep 2006 - 20:09:29 GMT

On 9/29/06, H. Paul Benton <hpbenton@scripps.edu> wrote:
> Hello,
>
>
>
> I hope this doesn't turn into a statistics question but here I
> go. I am using the nls function with a Gaussian distribution, see coding
> below. When I run the nls I get an error back saying that I have a linear
> gradient. I then, of course am unable to do anything else. The data that I
> am using are intensity values from some mass spectrometry data. Is there
> something I can do to stop the linear gradient, and I dare to ask why am I
> getting a linear gradient. I apologies if I haven't supplied enough
> information or I have made some mistake in my coding. The coding below works
> on some of the data but not all.
>
>
>
> Thank you for your time,
>
>
>
> Paul Benton
>
>
>
> brseq <- seq(-4.0, 4.0, by=0.1)
>
> AB<- A[,1]/A[,2]
>
> lgAB<-log(AB)
>
> freq_AB <-hist(lgAB, type="o", breaks=brseq, plot=F
>
> freq.tab <- as.data.frame(cbind(brseq, freq_AB$counts)
>
> class(fo <- (x ~ (A/(sig*sqrt(2*pi)))* exp(-1*((bin-mu)^2/(2* sig^2)))))
>
> nls.AB <- nls(fo,data=freq.tab, start= list(A=0.1*len, mu=0.01, sig=0.5),
> trace=TRUE)

I think you mean "singular gradient" not "linear gradient". This generally indicates that there is not enough information in the data to estimate all the parameters that you are trying to estimate. I see that you have set trace = TRUE, which is a good start. Take a look at the progress of the parameter estimates during the iterations and look at your data plots to see if the estimates appear to be sensible.



R-help@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. Received on Sat Sep 30 06:14:21 2006

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 Fri 29 Sep 2006 - 21:30:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.