[R] Transformation of variables in double integral in order to evaluate it in R
hahania
c.chanialidis.1 at research.gla.ac.uk
Tue Feb 21 22:53:16 CET 2012
I am wondering if i got this thing right
I have a function of two variables ( lambda and nu) and three
hyperparameters(a,b,c)
library(compoisson)
# function for finding inverse of k
invk <- function(x,a=1,b=1,c=1){
if (b/c<=log(factorial(floor(a/c)))+(a/c-floor(a/c))*log(floor(a/c)+1))
stop("Invalid arguments, please try again (not with the same values).")
x[1]^{a-1}*exp(-x[2]*b)*com.compute.z(x[1]),x[2])^{-c}
}
My goal is to integrate over lambda and nu (they both take values from 0 to
infinity )
After plotting its surface on the xy plane for different ranges of lambda
and nu ( and different values of the hyperpameters)
and trying to compute it with
library(cubature)
adaptIntegrate(function(x,a=1,b=1,c=1)invk(x, a=1,b=1,c=1), lowerLimit =
c(0, 0), upperLimit = c(1,1000))
i have no problem at all and i can find that, but when i go and change the
upper limit from 1 to something bigger than that (even 1.1) i dont get
results becasue the result take too long. The thing is though that the upper
limits both have to be 1000 (or big numbers generally since i have to
integrate for the two variables from 0 to infinity)
NOW
I thought it would help me to transform the variables from x[1] and x[2]
(which represent lambda and nu) to log(x[1]) and log(x[2]) so i did the
tranformation in the function invk. As a result i dont have a problem
computing over any limits i want.
But my question is am I integrating with regards to log(x[1]) and log(x[2])
as i should? Or do i have to do sth more?
--
View this message in context: http://r.789695.n4.nabble.com/Transformation-of-variables-in-double-integral-in-order-to-evaluate-it-in-R-tp4408445p4408445.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list