jarod_v6 <jarod_v6 <at> libero.it> writes:>
> I have that problem:
> this is file : PBS.txt
> Time RFU
> 0.0000 27.3021
> 0.0800 26.1565
....> rm(list=ls())
> print("ls()")
> #carica Dati con file di testo
>
> b <-read.table("PBS.txt", sep="\t", header= TRUE)
> print("b")
> b
> nlmod1 <- nls(RFU ~ A + (B+c*Time)/(1+exp(k*(e-Time))),
> data = b,
> start = list(A = 1, c = 1, B = 1, k =1, e = 1),
> trace = TRUE))
Thanks for providing a self-running example. There are two reasons for the lack
of success. First, your starting values were totally off (the curve was rising
strongly). Always plot the curve with the starting values together with the data
to be fitted, to be sure, that your are at least coming close. Note that your
data level off at around 22, so having A=22 is a good first choice.
With the starting values shown below, the iteration starts quite well, but ends
in a "step factor reduced ..." error. This almost always means: you
want to much
from your data. The algorithm cannot decide, what combination of the FIVE
coefficients you ask to be estimated is the right one. You have a very smooth
curve with little "personality", so I would never use more than 2 or 3
coefficients to fit these. Or, less polite: your model is nonsense; try a
simpler one, for example as shown below. And in case you are sure that your
model is "the only truth": if you have a whole set of curves, for
example from a
series of pharmacological tests, you might try nlme; it may work, but not from
the beginning.
In case you should argue that software XX does give results (I know a few
packages that do): these are wrong. If you are lucky, the software gives you the
standard error of the coefficients, possibly in the order of 10^7, which should
make you think it over.
Dieter
b <-read.table("PBS.txt", sep="\t", header= TRUE)
print("b")
b
A = 22
c = -0.1
B = 10
k = -2
e = 0
Time = seq(0,2,by=0.1)
plot(b$Time,b$RFU)
lines(Time, A + (B+c*Time)/(1+exp(k*(e-Time))))
nlmod1 <- nls(RFU ~ A + (B+c*Time)/(1+exp(k*(e-Time))),
data = b,start = list(A = A, c = c, B = B, k =k, e = e),
trace = TRUE)
nlmod2 <- nls(RFU ~A - B*exp(k*Time),
data = b,start = list(A = A, B = B, k =k),
trace = TRUE)
lines(b$Time,predict(nlmod2),col="red")