[R] Multiple Integrals

2016-01-06 Thread Luísa Freitas
Dear R-helpers, I'm looking for a quick way to calculate triple integrals. I have tried something like this example: f <- function(x,y,z) dnorm(x)*dnorm(y)*dnorm(z) llim <- -Inf ulim <- Inf integrate(function(z) { sapply(z,function(z) { integrate(function(y) { sapply(y, functio

Re: [R] Multiple Integrals

2015-08-30 Thread David Winsemius
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

Re: [R] Multiple Integrals

2015-08-29 Thread Jeff Newmiller
X4 is being subtracted, not added. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.

Re: [R] Multiple Integrals

2015-08-29 Thread David Winsemius
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 >

Re: [R] Multiple Integrals

2015-08-29 Thread Spencer Graves
On 8/29/2015 4:00 PM, Charles C. Berry wrote: On Sat, 29 Aug 2015, Shant Ch 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'

Re: [R] Multiple Integrals

2015-08-29 Thread Shant Ch via R-help
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. Shant

Re: [R] Multiple Integrals

2015-08-29 Thread Bert Gunter
Well, it's trivial to simulate, and for n=25, for example, I get a mean of 6.875. Depending on your needs, you can choose a much larger sample to make it more precise, or, as Chuck suggested, try numerical integration. Cheers, Bert Bert Gunter "Data is not information. Information is not kn

Re: [R] Multiple Integrals

2015-08-29 Thread Charles C. Berry
On Sat, 29 Aug 2015, Shant Ch 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 distr

Re: [R] Multiple Integrals

2015-08-29 Thread Charles C. Berry
On Fri, 28 Aug 2015, Shant Ch via R-help wrote: Hello all, For a study I want to find E|X1/3+X2/3+X3/3-X4| for variables following lognormal distribution. To get the value we need to use four integrals. So far, so good. This is the code which I is used   fx<-function(x){     dln

[R] Multiple Integrals

2015-08-28 Thread Shant Ch via R-help
Hello all, For a study I want to find E|X1/3+X2/3+X3/3-X4| for variables following lognormal distribution. To get the value we need to use four integrals. This is the code which I is used   fx<-function(x){     dlnorm(x,meanlog=2.185,sdlog=0.562)   } U31<-integrate(function(y1) { sap