2
votes

I would like to solve an equation as below, where the X is the only unknown variable and function f() is a multi-variate Student t distribution. More precisely, I have a multi k-dimensional integral for a student density function, which gives us a probability as a result, and I know that this probability is given as q. The lower bound for all integral is -Inf and I know the last k-1 dimension's upper bound (as given), the only unknown variable is the first integral's upper bound. It should have an solution for a variable and one equation. I tried to solve it in R. I did Dynamic Conditional Correlation to have a correlation matrix in order to specify my t-distribution. So plug this correlation matrix into my multi t distribution "dmvt", and use the "adaptIntegral" function from "cubature" package to construct a function as an argument to the command "uniroot" to solve the upper bound on the first integral. But I have some difficulties to achieve what I want to get. (I hope my question is clear) I have provided my codes before, somebody told me that there is problem, but cannot find why there is an issue there. Many thanks in advance for your help.

I now how to deal with it with one dimension integral, but I don't know how a multi-dimension integral equation can be solved in R? (e.g. for 2 dimension case)

\int_{-\infty}^{X}
    \int_{-\infty}^{Y_{1}} \cdots
       \int_{-\infty}^{Y_{k}}
           f(x,y_{1},\cdots y_{k})
      d_{x}d_{y_{1},}\cdots d_{y_{k}} = q

This code fails:

require(cubature) 
require(mvtnorm) 
corr <- matrix(c(1,0.8,0.8,1),2,2)
f <- function(x){ dmvt(x,sigma=corr,df=3) } 
g <- function(y) adaptIntegrate(f, 
                  lowerLimit = c( -Inf, -Inf), 
                  upperLimit = c(y, -0.1023071))$integral-0.0001    
uniroot( g, c(-2, 2)) 
1
Packages R2Cuba or cubature may be helpful.Carl Witthoft
... also the mvtnorm package ...Ben Bolker
Thanks for both of you...I did try what you mentioned...But the result is kind of strange....The code :require(cubature) require(mvtnorm) f <- function(x){ dmvt(x,df=3) } g <- function(y) adaptIntegrate(f, lowerLimit = c( -Inf, -Inf), upperLimit = c(y, -0.1023071))$integral-0.0001 uniroot( g, c(-2, 2))Zhili
(I edited your question, and other people have taken care of closing and deleting your duplicate questions ...)Ben Bolker
Since the only answer clearly explains why adaptIntegrate was the wrong approach and offered a tested alternative, then you should explain why you have not check-marked that answer.IRTFM

1 Answers

2
votes

Since mvtnorm includes a pmvt function that computes the CDF of the multivariate t distribution, you don't need to do the integral by brute force. (mvtnorm also includes a quantile function qmvt, but only for "equicoordinate" values.)

So:

library(mvtnorm)
g <- function(y1_upr,y2_upr=-0.123071,target=1e-4,df=3) {
    pmvt(upper=c(y1_upr,y2_upr),df=df)-target
}
uniroot(g,c(-10000,0))
## $root
## [1] -17.55139
## 
## $f.root
## [1] -1.699876e-11
## attr(,"error")
## [1] 1e-15
## attr(,"msg")
## [1] "Normal Completion"
## 
## $iter
## [1] 18
## 
## $estim.prec
## [1] 6.103516e-05
## 

Double-check:

pmvt(upper=c(-17.55139,-0.123071),df=3)
## [1] 1e-04
## attr(,"error")
## [1] 1e-15
## attr(,"msg")
## [1] "Normal Completion"