Christian Ritz pisze: > Hi Jarek, > > an alternative approach is to provide more precise starting values! > > It pays off to realise that it's possible to find quite good guesses > for some of the parameters in your model function: > > t ~ tr+ (ts-tr)/ ((1+ (a*h)^n)^(1-(1/n))) > > The parameters tr and ts correspond to the response t for h equal to > infinity and h=0. Therefore by looking at the plot of your data I > would set: > > tr = 0 > ts = 15000 > > The parameter n must be above 1 in order to achieve a decreasing > function. We will not think more about this at the moment. > > For n somewhat larger than 1 (in which case I would approximate the > exponent 1-(1/n) by 1) the parameter a is approximately equal to the > reciprocal of the h value resulting in a response halfway between tr > and ts. Therefore (again from looking at the plot) I would set a=10. > > Using the above starting values and simply increasing n in steps of 1 > eventually results in a useful model fit: > > ## Fails > tmp.m1<-nls(t ~ tr+ (ts-tr)/ ((1+ (a*h)^n)^(1-(1/n))), > data = tmp, start = list(a=10, n=1, tr=0, ts=15000)) > > ## Fails > tmp.m1<-nls(t ~ tr+ (ts-tr)/ ((1+ (a*h)^n)^(1-(1/n))), > data = tmp, start = list(a=10, n=2, tr=0, ts=15000)) > > ## Works!! > tmp.m1<-nls(t ~ tr+ (ts-tr)/ ((1+ (a*h)^n)^(1-(1/n))), > data = tmp, start = list(a=10, n=3, tr=0, ts=15000)) > > summary(tmp.m1) > > plot(t ~ h, data = tmp) > lines(tmp$h, predict(tmp.m1)) > > > I hope you can use this explanation?! > > Christian yes, I must only check if coefs are expected
but... fortunalty I found that my problem is solved by package HydroMe thanks again Jarek ______________________________________________ R-help@r-project.org 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.