From: Huntsinger, Reid <reid_huntsinger_at_merck.com>

Date: Fri 29 Jul 2005 - 06:20:34 EST

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!

http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 29 06:29:31 2005

Date: Fri 29 Jul 2005 - 06:20:34 EST

In your example, f is a function, but

optimize(f,c(0,15),maximum=TRUE)$maximum is just a number (the point at
which f reaches its maximum value). I'm not sure what you want, but if you
had say

f <- function(x,y) x^3 + yx + 1

and defined

g <- function(y) optimize(f,c(0,5),maximum=TRUE,y)$maximum

then g(t) is the x-value at which the function f(x,t) (over x in (0,5)) reaches its maximum for this fixed t. That could then be integrated.

Reid Huntsinger

-----Original Message-----

From: r-help-bounces@stat.math.ethz.ch

[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Gregory Gentlemen
Sent: Thursday, July 28, 2005 3:58 PM

To: r-help@stat.math.ethz.ch

Subject: [R] using integrate with optimize nested in the integration

For instance consider this simple example for which I cannot get R to return the desired result:

However this is an approximation of : 15*(5^2/2 - 0)=187.5, not what I intended on getting. Its not identifying that f is a function of bhat ... any advice or ways I can get integrate to not treat this as a constant?

Any help is appreciated.

Gregoy Gentlemen

[[alternative HTML version deleted]]

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!

http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 29 06:29:31 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:34:07 EST
*