Hi all,
?curve can also help.
sorry for the poor model adjust below

x<-c(1,3,10,25,80,162)
y<-c(2,7,12,17,22,27)
x2<-x^2
plot(y~x)

mymodel<-lm(y~x+x2)
coefs<-coef(mymodel)

curve(coefs[1]+coefs[2]*x+coefs[3]*x*x, col="red", lwd=2, add=T)

miltinho
brazil
===
On Thu, Feb 12, 2009 at 8:43 AM, lauramorg...@bluewin.ch
<lauramorg...@bluewin.ch> wrote:

> Thank you for the suggestion of using predict!
> If someone is interested here is the loop I used:
>
> seq(0,max(subset(dati, Fiume=="Laveggio")$Portata), length=100)->seqQ
>
> for(i in 1:35)
> {
>  jpeg(paste("result",i,".jpg"))
>
>  
> plot(subset(dati,Fiume=="Laveggio")$PTG.P~subset(dati,Fiume=="Laveggio")$Portata,
>       main=print(formList[[i]]), sub=print(summary(resultList[[i]])$sigma))
>  lines(seqQ, predict(resultList[[i]], list(Portata = seqQ)))
>  dev.off()
>  }
>
> ----Messaggio originale----
> Da: ssef...@gmail.com
> Data: 10.02.2009 18.15
> A: <lauramorg...@bluewin.ch>
> Copia: <r-help@r-project.org>
> Oggetto: Re: [R] plotting the result of a nonlinear regression
>
> ?predict
>
> On Tue, Feb 10, 2009 at 11:06 AM, lauramorg...@bluewin.ch
> <lauramorg...@bluewin.ch> wrote:
> > Hello,
> > to plot the result of a singular non linear regression (using nls) I
> usually use the function plotfit, for
> example:
> >
> > r.PTG.V<-nls(PTG.P~ fz1(Portata, a,b), data=dati, start=list(a=10, b=10),
> nls.control(maxiter=200),
> algorithm='port',
> > trace=TRUE, na.action=na.omit, lower=list(a=0, b=10), upper=list(a=100,
> b=100))
> > plotfit(r.PTG.V)
> >
> > I tried to use the function plotfit on the result of the following for
> loop but I got an error message:
> > for (i in 1:length(formList))
> > {
> >    resultList[[i]] <- nls(formList[[i]], data=subset(dati,
> Fiume=="Laveggio"), start=startList7[[i]],
> >    nls.control(maxiter=1000, warnOnly=TRUE), algorithm='port',
> na.action=na.omit,lower=lowerList7[[i]],
> >    upper=upperList7[[i]])
> > }
> > plotfit(resultList[[1]]
> >
> > "Error in diff(as.numeric(y[ord])) :
> >  (list) object cannot be coerced to type 'double'"
> >
> > Could somebody tell me what this error means? how can I fix this problem?
> > Any suggestion appreciated!!
> > Thanks,
> > Laura
> >
> > ______________________________________________
> > 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.
> >
>
>
>
> --
> Stephen Sefick
>
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>                                                                -K. Mullis
>
> ______________________________________________
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to