[R] automate curve drawing on nls() object

array chip arrayprofile at yahoo.com
Wed May 19 02:26:53 CEST 2010


Sorry that I forgot to attach the data file. 

Indeed, this is a much simpler way to do this.

Thanks


--- On Tue, 5/18/10, Ben Bolker <bolker at ufl.edu> wrote:

> From: Ben Bolker <bolker at ufl.edu>
> Subject: Re: [R] automate curve drawing on nls() object
> To: r-help at stat.math.ethz.ch
> Date: Tuesday, May 18, 2010, 7:33 PM
> 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"))
> 
> ______________________________________________
> 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