[R] automate curve drawing on nls() object
Ben Bolker
bolker at ufl.edu
Wed May 19 01:33:20 CEST 2010
array chip <arrayprofile <at> yahoo.com> writes:
> Hi, I would like to use the curve() function to draw the
> predicted curve from an nls() object. for example:
>
Is there a reason you don't want to use plot() and predict() ???
> dd<-read.table("dd.txt",sep='\t',header=T,row.names=1)
note that this is not a reproducible example ...
> obj<-nls(y~c+(d-c)/(1+(x/e)^b),data=dd,start=list(b=-1, c=0, d=100, e=150))
> coef(obj)
> b c d e
> -1.1416422 0.6987028 102.8613176 135.9373131
> curve(0.699+(102.86-0.699)/(1+(x/135.94)^(-1.1416)),1,20000)
>
predframe <- data.frame(x=seq(1,20000,length.out=101))
predframe <- cbind(predframe,y=predict(obj,newdata=predframe))
with(predframe,plot(y~x,type="l"))
More information about the R-help
mailing list