[R] Odp: An error in fitting a non linear regression
Petr PIKAL
petr.pikal at precheza.cz
Fri Feb 20 14:50:32 CET 2009
Hi
r-help-bounces at r-project.org napsal dne 20.02.2009 11:21:26:
>
> Hi
>
> I have a data set with two variables "q" and "depth" as follows:
>
> q<-c(tapply(weight[Soil=="Jy"], Depth[Soil=="Jy"], mean)). This commns
> returns 7 "q" values:
> 0.687900000 0.845550000 0.405416667 0.152766667 0.033100000 0.031400000
> 0.005183333
>
> The "depth" values are produced using this command whish "depth" shows
teh
> soil depth:
> depth <--c(5,15,25,35,45,55,65). This return these values for "depth":
> [1] -5 -15 -25 -35 -45 -55 -65
>
> I have uploaded the plot file in below:
>
>
>
> http://www.nabble.com/file/p22118160/plot.doc plot.doc
>
> Now I want to fit the following decaying exponential model to our data
> presented in the plot file such that depth is X and q is Y.
> nreg<-nls(q~a*exp(-b*depth), start=list(a=1, b=0.5)). This command
returns
> the following error:
> Error in nls(q ~ a * exp(-b * depth), start = list(a = 1, b = 0.5)) :
> singular gradient
With b=0.05 it will converge, however the model seems to be wrong.
depth <--c(5,15,25,35,45,55,65)
y<-c(0.687900000, 0.845550000, 0.405416667, 0.152766667, 0.033100000,
0.031400000,0.005183333)
plot(depth,y)
nreg<-nls(y~a*exp(-b*depth), start=list(a=1, b=0.05))
lines(depth, predict(nreg))
Regards
Petr
>
> However, if I use positive values of depth i.e.
> [1] 5 15 25 35 45 55 65
>
> then I recieve the following error:
> Error in numericDeriv(form[[3]], names(ind), env) :
> Missing value or an infinity produced when evaluating the model
>
> Notice that though in the plot depth is drawn on Y axis but in the
> regression model "depth" in independent. Plot shows the real world of
what
> happne to the crop root growth.
>
> Thank you.
> Saeed Ahmadi
>
> --
> View this message in context:
http://www.nabble.com/An-error-in-fitting-a-non-
> linear-regression-tp22118160p22118160.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list