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

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


Michael,             

            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,data=freq.tab, 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 freq.tab 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.  

            Cheers.  

            Paul Benton             

Research Technician

Mass Spectrometry

   o The

/

o Scripps

  \

   o Research

/

o Institute  

        [[alternative HTML version deleted]]



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 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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.