Re: [R] fitting a gaussian to some x,y data

From: H. Paul Benton <>
Date: Sat 30 Sep 2006 - 20:09:32 GMT


            I'm also playing with the nls function trying to get it to work with a Gaussian. My lines that I have at the moment and I hope will help you are  

class(fo <- (x ~ (A/(sig*sqrt(2*pi)))* exp(-1*((bin-mu)^2/(2* sig^2)))))

nls.AB <- nls(fo,, start= list(A=0.1*len, mu=0.01, sig=0.5), trace=TRUE)  

            So first I create the eq to put into the nls function, my var are the which is a list of some binned frequency into 0.1 units and the len is amount of features in the data. I'll say quickly that at the moment I am getting a 'singular gradient error'. I hope that this helps.  


            Paul Benton             

Research Technician

Mass Spectrometry

   o The


o Scripps


   o Research


o Institute  

        [[alternative HTML version deleted]] mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sun Oct 01 06:16:29 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 Sat 30 Sep 2006 - 20:30:26 GMT.

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