Re: [R] Starting estimates for nls Exponential Fit

2009-12-08 Thread Anto
I have tried the method proposed by Dave, and I must say it works very well. Not to yield starting estimates for an nls-fit, but as an independent method for calculating E (which is, by the way, the only paramater that I am actually interested in). The calculated values for E (Esp[3]) are on

Re: [R] Starting estimates for nls Exponential Fit

2009-12-08 Thread Christian Ritz
Hi Antoon, now that you mention trying out different methods, maybe you should consider fitting a sigmoidal curve to the entire dataset and not only the exponential part (which constitutes a very small dataset) as seems to have been the endeavour that initiated the posting to R-help. One

Re: [R] Starting estimates for nls Exponential Fit

2009-12-07 Thread Anto
Thanks everybody, This has been quite helpful, the problem remains tricky but at least now I've got a version of my script that handles all my reactions without error. The DEoptim solution produced good starting values for a lot of reactions, but sadly not for all. I now use scaled parameters

Re: [R] Starting estimates for nls Exponential Fit

2009-12-07 Thread dave fournier
I thought maybe my suggestion for reparameterizing this simple problem was ignored because I didn't supply R code for the problem. Here it is using optim for the optimization. It converges trivially with an initial value for E of 1000. As I stated before, there is nothing at all difficult about

Re: [R] Starting estimates for nls Exponential Fit

2009-12-07 Thread dave fournier
Thanks to Dennis Murphy who pointed out that ExponCycles is undefined. It is an R gotcha. I had shortened the name but R still remembered it so the script worked but only on my computer. This should fix that. ExponValues=c(2018.34,2012.54,2018.85,2023.52,2054.58,2132.61,2247.17,2468.32,27 78.47)

Re: [R] Starting estimates for nls Exponential Fit

2009-12-02 Thread Prof. John C Nash
Kate Mullen showed one approach to this problem by using DEOptim to get some good starting values. However, I believe that the real issue is scaling (Warning: well-ridden hobby-horse!). With appropriate scaling, as below, nls does fine. This isn't saying nls is perfect -- I've been trying to

Re: [R] Starting estimates for nls Exponential Fit

2009-12-02 Thread Katharine Mullen
You used starting values: pa - c(1,2,3) but both algorithms (port and Gauss-Newton) fail if you use the slightly different values: pa - c(1,2,3.5) Scaling does not fix the underlying sensitivity to starting values. pa[3] in particular cannot be above ~3.15 for GN and ~3.3 for port; both

Re: [R] Starting estimates for nls Exponential Fit

2009-12-02 Thread Prof. John C Nash
Kate is correct. The parameter scaling helps quite a bit, but not enough to render the problem nice so that many reasonable starting points will give useful results. Indeed, a run using all.methods=TRUE in our optimx package (on r-forge at http://r-forge.r-project.org/R/?group_id=395) gives

Re: [R] Starting estimates for nls Exponential Fit

2009-12-02 Thread dave fournier
Figuring out the best parameterization for this kind of model is a bit tricky until you get the hang of it. Let the function be y_t = y_0 + alpha * E^t where uppercase Y_t denotes an observed value and lower case y_t is a predicted value. Index the times by t_1 t_n WLOG assume that

[R] Starting estimates for nls Exponential Fit

2009-12-01 Thread Anto
Hello everyone, I have come across a bit of an odd problem: I am currently analysing data PCR reaction data of which part is behaving exponential. I would like to fit the exponential part to the following: y0 + alpha * E^t In which Y0 is the groundphase, alpha a fluorescence factor, E the

Re: [R] Starting estimates for nls Exponential Fit

2009-12-01 Thread Katharine Mullen
If you could reformulate your model as alpha * (y0 + E^t) then you could use nls with alg=plinear (alpha then would be eliminated from the nonlinear param and treated as conditionally linear) and this would help with convergence. Else you can try package DEoptim to get the starting values; the