[R] Starting estimates for nls Exponential Fit

Anto Alievens at iph.fgov.be
Tue Dec 1 15:22:15 CET 2009


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
efficiency of the reaction & t is time (in cycles)

I can get this to work for most of my reactions, but part fails the nls fit
(Convergence failure: iteration limit reached without convergence). This
mainly has to do with the starting estimates for the nls function. I have
used various 'smart' ways of calculating starting estimates (grid searches,
optim(), etc.) but however close the starting estimates are to the actual
values, nls still fails for many datasets.

The weirdest thing is, I have one set of starting estimates (alpha= 0.5 and
E=1.85) which are totaly arbitray and these DO work for, say 99% of the
datasets. I don't know why this is and I don't why my 'good estimates' do
not work. I am desperatly seeking a way of calculating working starting
estimates for my nls function. Can anybody give me a hand?

thanks,

Anto

R version 2.9.2

example dataset:

ExponValues
[1] 2018.34 2012.54 2018.85 2023.52 2054.58 2132.61 2247.17 2468.32 2778.47

ExponCycles
[1] 17 18 19 20 21 22 23 24 25


Example starting estimate calculation

Y0 <- ExponValues[1]									
E <-
weighted.mean((ExponValues-eY0)[-1][-1]/(ExponValues-eY0)[-1][-(length(ExponValues)-1)],(1-abs(seq(-1,1,length=(length(ExponValues)-2)))^3)^3)
alpha <- 
weighted.mean((ExponValues[-1]-ExponValues[-length(ExponValues)])/((E^ExponCycles[-1])-(E^ExponCycles[-length(ExponCycles)])),(1-abs(seq(-1,1,length=(length(ExponCycles)-1)))^3)^3)


Optional parameter optimisation:

Esp <-
optim(c(Y0=eY0,a=alpha,E=E),function(x){return(sum(abs(ExponValues-(x[1]+x[2]*x[3]^ExponCycles))))})$par


nls function:

Emodel<-try(nls(ExponValues ~ (Y0 + a*(E^ExponCycles)) , start= Esp,
algorithm="port"),silent=TRUE)
-- 
View this message in context: http://n4.nabble.com/Starting-estimates-for-nls-Exponential-Fit-tp932230p932230.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list