pcmvtruncnorm {condTruncMVN} | R Documentation |
CDF for the Conditional Truncated Multivariate Normal
Description
Computes the distribution function for a conditional truncated multivariate normal random variate Y|X.
Usage
pcmvtruncnorm(
lowerY,
upperY,
mean,
sigma,
lower,
upper,
dependent.ind,
given.ind,
X.given,
...
)
Arguments
lowerY |
the vector of lower limits for Y|X. Passed to tmvtnorm:: |
upperY |
the vector of upper limits for Y|X. Must be greater than lowerY. Passed to tmvtnorm:: |
mean |
the mean vector for Z of length of n |
sigma |
the symmetric and positive-definite covariance matrix of dimension n x n of Z. |
lower |
a vector of lower bounds of length n that truncate Z |
upper |
a vector of upper bounds of length n that truncate Z |
dependent.ind |
a vector of integers denoting the indices of dependent variable Y. |
given.ind |
a vector of integers denoting the indices of conditioning variable X. If specified as integer vector of length zero or left unspecified, the unconditional density is returned. |
X.given |
a vector of reals denoting the conditioning value of X. This should be of the same length as |
... |
Additional arguments passed to tmvtnorm:: |
Details
Calculates the probability that Y|X is between lowerY
and upperY
. Z = (X, Y) is the fully joint multivariate normal distribution with mean equal mean and covariance matrix sigma, truncated between lower and upper. See the vignette for more information.
Note
For one-dimension conditionals Y|X, this function uses the ptruncnorm() function in the truncnorm package. Otherwise, this function uses tmvtnorm::ptmvnorm
().
Examples
# Example 1: Let X2,X3,X5|X2,X4 ~ N_3(1, Sigma)
# truncated between -10 and 10.
d <- 5
rho <- 0.9
Sigma <- matrix(0, nrow = d, ncol = d)
Sigma <- rho^abs(row(Sigma) - col(Sigma))
# Find P(-0.5 < X2,X3,X5 < 0 | X2,X4)
pcmvtruncnorm(rep(-0.5, 3), rep(0, 3),
mean = rep(1, d),
sigma = Sigma,
lower = rep(-10, d),
upper = rep(10, d),
dependent.ind = c(2, 3, 5),
given.ind = c(1, 4), X.given = c(1, -1)
)
# Example 2: Let X1| X2 = 1, X3 = -1, X4 = 1, X5 = -1 ~ N(1, Sigma) truncated
# between -10 and 10. Find P(-0.5 < X1 < 0 | X2 = 1, X3 = -1, X4 = 1, X5 = -1).
pcmvtruncnorm(-0.5, 0,
mean = rep(1, d),
sigma = Sigma,
lower = rep(-10, d),
upper = rep(10, d),
dependent.ind = 1,
given.ind = 2:5, X.given = c(1, -1, 1, -1)
)