library(mvtnorm)
p <- 2
Sigma <- diag(p)
mu <- rep(0, p)
## bivariate normal distribution
z2 <- qmvt(0.975, mean = mu, sigma = Sigma, df = 1e3)$quantile
# compute integral
intDensTri(mu = mu, Sigma = Sigma, n=5, x.min=0, type = "fine")$value-1/2
intDensTri(mu = mu, Sigma = Sigma, n=30, x.min=0, type = "raw")$value-1/2
intDensTri(mu = mu, Sigma = Sigma, n=50, x.min=0, type = "raw")$value-1/2
intDensTri(mu = mu, Sigma = Sigma, df = 5, n=5, x.min=0, distribution = "pmvt")$value-1/2
res <- intDensTri(mu = mu, Sigma = Sigma, df = 5, n=10, x.min=0, distribution = "pmvt")
res$value-1/2
ggplot2::autoplot(res)
## trivariate normal distribution
if (FALSE) {
p <- 3
Sigma <- diag(p)
mu <- rep(0, p)
res2 <- intDensTri(mu = mu, Sigma = Sigma, n=5, x.min = 0, z.max = 10)
ggplot2::autoplot(res2)
ggplot2::autoplot(res2, coord.plot = c("x","z1"))
res2
}
#### when the distribution is far from 0
if (FALSE) {
eq1 <- intDensTri(mu = c(10,0), Sigma = diag(1,2),
x.min = 2, n=10)
eq1$value-1
ggplot2::autoplot(eq1)
eq2 <- intDensTri(mu = c(10,0,0), Sigma = diag(1,3),
x.min=2, z.max = 10, type = "raw",
n=10)
ggplot2::autoplot(eq2, coord.plot = c("y1","z1"))
eq2$value-1
## more variables
p <- 5
Sigma <- diag(p)
mu <- rep(0, p)
res2 <- intDensTri(mu = mu, Sigma = Sigma, n=5, x.min = 1, z.max = c(2,2))
res2$grid
}
Run the code above in your browser using DataLab