[R] Pseudo-Voigt fit

ppancoska@notes.cc.sunysb.edu ppancoska at notes.cc.sunysb.edu
Fri Sep 2 15:38:35 CEST 2005


Dear colleagues,
thank you very much for help.
I have got the most efficient message (?nls) from Bert Gunter and I took
off from there and now the routine is up and running with results validated
and doing exactly what SigmaPlot did.
It required intense "...reading the *#@%* manual...." as Spencer suggests
below, but it was worth of the effort! I am actually amazed how easily - in
many cases - one can find the right segment in the documentation even after
only partial reading of all those pages. But sometimes even the real
ingenuity of designers in naming all those functions cannot switch on that
intuition "radar" to navigate where one would like (or has to) be. Mea
maxima culpa....

Thanks again.


Petr P.

Dr. Petr Pancoska
Department of Pathology
SUNY Stony Brook, NY 11794
phone:          (631)-444-3030

******************************************************************************

This e- mail message, including any attachments,
is for the sole use of the intended recipient(s) and may
contain confidential and privileged information.
Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender
by e-mail and destroy all copies of the original.
******************************************************************************


                                                                           
             Spencer Graves                                                
             <spencer.graves at p                                             
             df.com>                                                    To 
                                       ppancoska at notes.cc.sunysb.edu       
             09/01/2005 10:17                                           cc 
             PM                        r-help at stat.math.ethz.ch            
                                                                   Subject 
                                       Re: [R] Pseudo-Voigt fit            
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




               I haven't seen a reply to this question, so I will attempt a
few
remarks in spite of some confusion about what you are asking.

               1.  The function to use for parameter estimation depends on
ths
structure of the data.  My all-around preference for many purposes is
for "optim", but I've used "nls", "fitdistr" (in the MASS package) and
others in different circumstances.

               2.  If you are doing nonlinear estimation with, e.g., optim,
I
suggest you request "hessian=TRUE".  The eigenvalues of the hessian will
tell you if it is ill conditioned.  If it is, you might consider
reparameterizing the model.

               3.  I try to avoid using reserved words like "c".  R can
often
determine what you want from the context, but there are exceptions.  I
try to avoid that problem by testing a name at a command prompt before I
use it.  If it returns, "object not found", I'm fine;  if not, I try
something different.

               4.  Following the posting guide!
"http://www.R-project.org/posting-guide.html" can on average increase
the likelihood that you will receive helpful suggestions quickly.  (I've
learned that people rarely respond to my incoherent screams;  when they
do, it's rarely helpful.  I've reluctantly learned that there is often
no substutute for reading the *#@%* manual.)

               I'd be shocked if this answered your question, but I hope it
is
helpful nonetheless.

               spencer graves

ppancoska at notes.cc.sunysb.edu wrote:

> Hi, I am sorry for this question, but I am trying to speed up an
> application....
> I will need to fit many x-y data sets (input from text files) to
> 4-parameter Pseudo-Voigt peak function.
> Until now I used SigmaPlot macro to do it (enclosed just in case...)
>
> peaksign(q) = if(total(q)>q[1], 1, -1)
> xatymin(q,r) = xatymax(q,max(r)-r)
> [Parameters]
> a = if(peaksign(y)>0, max(y), min(y)) ''Auto {{previous: 60.8286}}
> b = fwhm(x,abs(y))/2 ''Auto {{previous: 0.656637}}
> c = .5 ''Auto {{previous: 6.82973e-010}}
> x0 = if(peaksign(y)>0, xatymax(x,y), xatymin(x,y)) ''Auto {{previous:
> 3.19308}}
>
>
> [Equation]
> f = a*(c*(1/(1+((x-x0)/b)^2))+(1-c)*exp(-0.5*((x-x0)/b)^2))
>
> fit f to y
>
>  (manageable for ~100), but it looks like the next project would need to
> process ~1000 member sets.
>
> I am not as familiar with R to find the right info (although I can use R
in
> general).
>
> I am also nearly sure that there should be a solution to this task "out
> there" ready to be modified...
>
> Could you be so kind and direct me please to the right package or
web-site
> with examples?
>
> Thank you very much
>
>
>
> Dr. Petr Pancoska
> Department of Pathology
> SUNY Stony Brook, NY 11794
> phone:          (631)-444-3030
>
>
******************************************************************************

>
> This e- mail message, including any attachments,
> is for the sole use of the intended recipient(s) and may
> contain confidential and privileged information.
> Any unauthorized review, use, disclosure or distribution is prohibited.
> If you are not the intended recipient, please contact the sender
> by e-mail and destroy all copies of the original.
>
> ______________________________________________
> 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

--
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

spencer.graves at pdf.com
www.pdf.com <http://www.pdf.com>
Tel:  408-938-4420
Fax: 408-280-7915




More information about the R-help mailing list