Computes the equicoordinate quantile function of the truncated multivariate normal distribution for arbitrary correlation matrices based on an inversion of the algorithms by Genz and Bretz.
1 2 3 4 5 6 7 8 9 
p 
probability. 
interval 
a vector containing the endpoints of the interval to be
searched by 
tail 
specifies which quantiles should be computed.

P[x <= X <= x] = p
n 
index (1..n) to calculate marginal quantile for 
mean 
the mean vector of length n. 
sigma 
the covariance matrix of dimension n. Either 
lower 
Vector of lower truncation points,\
default is 
upper 
Vector of upper truncation points,\
default is 
... 
additional parameters to be passed to

Only equicoordinate quantiles are computed, i.e., the quantiles in each
dimension coincide. Currently, the distribution function is inverted by
using the uniroot
function which may result in limited accuracy of the
quantiles.
A list with four components: quantile
and f.quantile
give the location of the quantile and the value of the function
evaluated at that point. iter
and estim.prec
give the number
of iterations used and an approximate estimated precision from
uniroot
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27  # finite dimensional distribution of the Geometric Brownian Motion logreturns
# with truncation
# volatility p.a.
sigma=0.4
# risk free rate
r = 0.05
# n=3 points in time
T < c(0.5, 0.7, 1)
# covariance matrix of Geometric Brownian Motion returns
Sigma = sigma^2*outer(T,T,pmin)
# mean vector of the Geometric Brownian Motion returns
mu = (r  sigma^2/2) * T
# lower truncation vector a (a<=x<=b)
a = rep(Inf, 3)
# upper truncation vector b (a<=x<=b)
b = c(0, 0, Inf)
# quantile of the t_1 returns
qtmvnorm.marginal(p=0.95, interval = c(10, 10), tail = "lower.tail", n=1,
mean = mu, sigma = Sigma, lower=a, upper=b)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.