Hello, everyone, I have a specific equation, When I draw it out, I found there is a max. value for it at about x=5. but I couldn't point it out by optimize(). Does anyone know why? Thanks! my code is: d50<-18.04 c<- -1.276 dm<-147 sm <- function (x) { 1/(1+(x/d50)^c)+(1-1/(1+(dm/d50)^c))*x/dm-(1/(1+((x-1)/d50)^c)+(1-1/(1+(dm/d50)^c))*(x-1)/dm) } curve(sm, 0,50) optimize(sm,c(0,50)) The optimize() only give min. value but not max.
If you read the help file for optimize, you will see that you need to set the argument maximum to TRUE. ?optimize optimize(sm, c(0, 50), maximum=TRUE) Jean On Thu, Oct 29, 2015 at 4:19 PM, Jianling Fan <fanjianling at gmail.com> wrote:> Hello, everyone, > > I have a specific equation, When I draw it out, I found there is a > max. value for it at about x=5. but I couldn't point it out by > optimize(). Does anyone know why? Thanks! > > my code is: > > d50<-18.04 > c<- -1.276 > dm<-147 > > sm <- function (x) { > > 1/(1+(x/d50)^c)+(1-1/(1+(dm/d50)^c))*x/dm-(1/(1+((x-1)/d50)^c)+(1-1/(1+(dm/d50)^c))*(x-1)/dm) > } > curve(sm, 0,50) > optimize(sm,c(0,50)) > > The optimize() only give min. value but not max. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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]]
Oops! Thanks a lot! Jean On 29 October 2015 at 15:45, Adams, Jean <jvadams at usgs.gov> wrote:> If you read the help file for optimize, you will see that you need to set > the argument maximum to TRUE. > > ?optimize > > optimize(sm, c(0, 50), maximum=TRUE) > > Jean > > On Thu, Oct 29, 2015 at 4:19 PM, Jianling Fan <fanjianling at gmail.com> wrote: >> >> Hello, everyone, >> >> I have a specific equation, When I draw it out, I found there is a >> max. value for it at about x=5. but I couldn't point it out by >> optimize(). Does anyone know why? Thanks! >> >> my code is: >> >> d50<-18.04 >> c<- -1.276 >> dm<-147 >> >> sm <- function (x) { >> >> 1/(1+(x/d50)^c)+(1-1/(1+(dm/d50)^c))*x/dm-(1/(1+((x-1)/d50)^c)+(1-1/(1+(dm/d50)^c))*(x-1)/dm) >> } >> curve(sm, 0,50) >> optimize(sm,c(0,50)) >> >> The optimize() only give min. value but not max. >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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. > >-- Jianling Fan ???