[R] Multiple Integrals

David Winsemius dwinsemius at comcast.net
Mon Aug 31 04:17:06 CEST 2015


On Aug 30, 2015, at 8:41 AM, Shant Ch via R-help wrote:

> Thank you very much to all for all your responses.
> 
> @Dr. Winsemius, E[f(X)] >=f(E(X)) if f is convex. Now we know |x| is convex function, so clearly in this scenario if we compute the expectation of the ((X1+X2+X3)/3-X4) and then take the absolute, then, we will get a lower bound of the expectation I want to find. 
> 
>      On Saturday, August 29, 2015 7:24 PM, David Winsemius <dwinsemius at comcast.net> wrote:

Using the adaptIntegrate function in package:cubature I seem to be getting convergence near  5.359359 as I extend the limits of integration. I don't think that `adaptIntegrate` can handle infinite range. Either than or the NaN it is returning is a signal of pathology that I don't understand.

> require(cubature)
> fx<-function(x){
+         dlnorm(x,meanlog=2.185,sdlog=0.562)
+       }
> I.4d <- function(x) {
+   x1 = x[1]; y1 <- x[3]
+   x2 = x[2]; y2 <- x[4];   abs(y1/3+y2/3+x1/3-x2)*fx(y1)*fx(y2)*fx(x1)*fx(x2)}
> 
> adaptIntegrate(I.4d, rep(0, 4), rep(1000, 4), maxEval=1000000)
$integral
[1] 5.359082

$error
[1] 0.001922979

$functionEvaluations
[1] 1000065

$returnCode
[1] 0

> I.4d <- function(x) {
+   x1 = x[1]; y1 <- x[3]
+   x2 = x[2]; y2 <- x[4];   abs(y1/3+y2/3+x1/3-x2)*fx(y1)*fx(y2)*fx(x1)*fx(x2)}
> 
> adaptIntegrate(I.4d, rep(0, 4), rep(100, 4), maxEval=1000000)
$integral
[1] 5.357679

$error
[1] 0.001820893

$functionEvaluations
[1] 1000065

$returnCode
[1] 0

> I.4d <- function(x) {
+   x1 = x[1]; y1 <- x[3]
+   x2 = x[2]; y2 <- x[4];   abs(y1/3+y2/3+x1/3-x2)*fx(y1)*fx(y2)*fx(x1)*fx(x2)}
> 
> adaptIntegrate(I.4d, rep(0, 4), rep(10000, 4), maxEval=1000000)
$integral
[1] 5.359359

$error
[1] 0.001871926

$functionEvaluations
[1] 1000065

$returnCode
[1] 0


Best;
David.

> 
> 
> 
> On Aug 29, 2015, at 11:35 AM, Shant Ch via R-help wrote:
> 
>> Hello Dr. Berry,
>> 
>> I know the theoretical side but note we are not talking about expectation of sums rather expectation of ABSOLUTE value of the function (X1/3+X2/3+X3/3-X4), i.e. E|X1/3+X2/3+X3/3-X4|  , I don't think this can be handled for log normal distribution by integrals by hand.
>> 
> 
> To Shnant Ch;
> 
> I admit to puzzlement (being a humble country doctor). Can you explain why there should be a difference between the absolute value of an expectation for a sum of values from a function, in this case dlnorm,  that is positive definite versus an expectation simply of the sum of such values?
> 
> -- 
> 
> David Winsemius
> Alameda, CA, USA
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list