Re: [R] ggplot: stat_smooth() and nls method

2010-09-15 Thread Benoit Boulinguiez

great help, thanks a lot

Le 14/09/2010 21:44, Brian Diggs a écrit :

On 9/11/2010 7:52 AM, Benoit Boulinguiez wrote:

Hi all,

Does one of you know if there is any way to combine a nls method in
the stat_smooth of ggplot?

Regards


According to the documentation for predict.nls, it is unable to create 
standard errors for the predictions, so that has to be turned off in 
the stat_smooth call.  Also, the default formula isn't valid for nls 
and has to be overridden, and the start values can be passed.  I used 
geom_smooth rather than stat_smooth, but either work.



library(ggplot2)

DF - data.frame(x=1:20, y=rnorm(20))

ggplot(DF, aes(x=x, y=y)) +
  geom_smooth(method=nls, formula=y~b*x+c, se=FALSE, 
start=list(b=0,c=1)) +

  geom_point()

ggplot(DF, aes(x=x, y=y)) +
  geom_smooth(method=nls, formula=y~sin(b*x), se=FALSE, 
start=list(b=1)) +

  geom_point()



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


Re: [R] ggplot: stat_smooth() and nls method

2010-09-14 Thread Brian Diggs

On 9/11/2010 7:52 AM, Benoit Boulinguiez wrote:

Hi all,

Does one of you know if there is any way to combine a nls method in
the stat_smooth of ggplot?

Regards


According to the documentation for predict.nls, it is unable to create 
standard errors for the predictions, so that has to be turned off in the 
stat_smooth call.  Also, the default formula isn't valid for nls and has 
to be overridden, and the start values can be passed.  I used 
geom_smooth rather than stat_smooth, but either work.



library(ggplot2)

DF - data.frame(x=1:20, y=rnorm(20))

ggplot(DF, aes(x=x, y=y)) +
  geom_smooth(method=nls, formula=y~b*x+c, se=FALSE, 
start=list(b=0,c=1)) +

  geom_point()

ggplot(DF, aes(x=x, y=y)) +
  geom_smooth(method=nls, formula=y~sin(b*x), se=FALSE, 
start=list(b=1)) +

  geom_point()

--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health  Science University

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


[R] ggplot: stat_smooth() and nls method

2010-09-11 Thread Benoit Boulinguiez

Hi all,

Does one of you know if there is any way to combine a nls method in 
the stat_smooth of ggplot?


Regards

--
-
Benoit Boulinguiez
Ph.D student
Ecole de Chimie de Rennes (ENSCR) Bureau 1.20
Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes
Avenue du Général Leclerc
CS 50837
35708 Rennes CEDEX 7
Tel 33 (0)2 23 23 80 83
Fax 33 (0)2 23 23 81 20
http://www.ensc-rennes.fr/

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