Title: | Conditional Multivariate Normal Distribution |
---|---|
Description: | Computes conditional multivariate normal densities, probabilities, and random deviates. |
Authors: | Ravi Varadhan [aut, cre] |
Maintainer: | Ravi Varadhan <[email protected]> |
License: | GPL-2 |
Version: | 2020.1 |
Built: | 2024-10-30 04:15:04 UTC |
Source: | https://github.com/cran/condMVNorm |
These functions provide the density function and a random number
generator for the conditional multivariate normal
distribution, [Y given X], where Z = (X,Y) is the fully-joint multivariate normal distribution with mean equal to mean
and covariance matrix
sigma
.
dcmvnorm(x, mean, sigma, dependent.ind, given.ind, X.given, check.sigma=TRUE, log = FALSE) rcmvnorm(n, mean, sigma, dependent.ind, given.ind, X.given, check.sigma=TRUE, method=c("eigen", "svd", "chol"))
dcmvnorm(x, mean, sigma, dependent.ind, given.ind, X.given, check.sigma=TRUE, log = FALSE) rcmvnorm(n, mean, sigma, dependent.ind, given.ind, X.given, check.sigma=TRUE, method=c("eigen", "svd", "chol"))
x |
vector or matrix of quantiles of Y. If |
n |
number of random deviates. |
mean |
mean vector, which must be specified. |
sigma |
a symmetric, positive-definte matrix of dimension n x n, which must be specified. |
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 distribution is used. |
X.given |
a vector of reals denoting the conditioning value of X. This should be of the same length as |
check.sigma |
logical; if |
log |
logical; if |
method |
string specifying the matrix decomposition used to
determine the matrix root of |
pcmvnorm
, pmvnorm
, dmvnorm
, qmvnorm
# 10-dimensional multivariate normal distribution n <- 10 A <- matrix(rnorm(n^2), n, n) A <- A %*% t(A) # density of Z[c(2,5)] given Z[c(1,4,7,9)]=c(1,1,0,-1) dcmvnorm(x=c(1.2,-1), mean=rep(1,n), sigma=A, dependent.ind=c(2,5), given.ind=c(1,4,7,9), X.given=c(1,1,0,-1)) dcmvnorm(x=-1, mean=rep(1,n), sigma=A, dep=3, given=c(1,4,7,9,10), X=c(1,1,0,0,-1)) dcmvnorm(x=c(1.2,-1), mean=rep(1,n), sigma=A, dep=c(2,5), given=integer()) # gives an error since `x' and `dep' are incompatibe #dcmvnorm(x=-1, mean=rep(1,n), sigma=A, dep=c(2,3), # given=c(1,4,7,9,10), X=c(1,1,0,0,-1)) rcmvnorm(n=10, mean=rep(1,n), sigma=A, dep=c(2,5), given=c(1,4,7,9,10), X=c(1,1,0,0,-1), method="eigen") rcmvnorm(n=10, mean=rep(1,n), sigma=A, dep=3, given=c(1,4,7,9,10), X=c(1,1,0,0,-1), method="chol")
# 10-dimensional multivariate normal distribution n <- 10 A <- matrix(rnorm(n^2), n, n) A <- A %*% t(A) # density of Z[c(2,5)] given Z[c(1,4,7,9)]=c(1,1,0,-1) dcmvnorm(x=c(1.2,-1), mean=rep(1,n), sigma=A, dependent.ind=c(2,5), given.ind=c(1,4,7,9), X.given=c(1,1,0,-1)) dcmvnorm(x=-1, mean=rep(1,n), sigma=A, dep=3, given=c(1,4,7,9,10), X=c(1,1,0,0,-1)) dcmvnorm(x=c(1.2,-1), mean=rep(1,n), sigma=A, dep=c(2,5), given=integer()) # gives an error since `x' and `dep' are incompatibe #dcmvnorm(x=-1, mean=rep(1,n), sigma=A, dep=c(2,3), # given=c(1,4,7,9,10), X=c(1,1,0,0,-1)) rcmvnorm(n=10, mean=rep(1,n), sigma=A, dep=c(2,5), given=c(1,4,7,9,10), X=c(1,1,0,0,-1), method="eigen") rcmvnorm(n=10, mean=rep(1,n), sigma=A, dep=3, given=c(1,4,7,9,10), X=c(1,1,0,0,-1), method="chol")
These functions provide the conditional mean and variance-covariance matrix of [Y given X], where Z = (X,Y) is the fully-joint multivariate normal distribution with mean equal to mean
and covariance matrix sigma
.
condMVN(mean, sigma, dependent.ind, given.ind, X.given, check.sigma=TRUE)
condMVN(mean, sigma, dependent.ind, given.ind, X.given, check.sigma=TRUE)
mean |
mean vector, which must be specified. |
sigma |
a symmetric, positive-definte matrix of dimension n x n, which must be specified. |
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 |
check.sigma |
logical; if |
dcmvnorm
, pcmvnorm
, pmvnorm
, dmvnorm
, qmvnorm
# 10-dimensional multivariate normal distribution n <- 10 A <- matrix(rnorm(n^2), n, n) A <- A %*% t(A) condMVN(mean=rep(1,n), sigma=A, dependent=c(2,3,5), given=c(1,4,7,9), X.given=c(1,1,0,-1)) condMVN(mean=rep(1,n), sigma=A, dep=3, given=c(1,4,7,9), X=c(1,1,0,-1)) condMVN(mean=rep(1,n), sigma=A, dep=3, given=integer()) # or simply the following condMVN(mean=rep(1,n), sigma=A, dep=3)
# 10-dimensional multivariate normal distribution n <- 10 A <- matrix(rnorm(n^2), n, n) A <- A %*% t(A) condMVN(mean=rep(1,n), sigma=A, dependent=c(2,3,5), given=c(1,4,7,9), X.given=c(1,1,0,-1)) condMVN(mean=rep(1,n), sigma=A, dep=3, given=c(1,4,7,9), X=c(1,1,0,-1)) condMVN(mean=rep(1,n), sigma=A, dep=3, given=integer()) # or simply the following condMVN(mean=rep(1,n), sigma=A, dep=3)
Computes the distribution function of the conditional multivariate normal, [Y given X], where Z = (X,Y) is the fully-joint multivariate normal distribution with mean equal to mean
and covariance matrix sigma
.
pcmvnorm(lower=-Inf, upper=Inf, mean, sigma, dependent.ind, given.ind, X.given, check.sigma=TRUE, algorithm = GenzBretz(), ...)
pcmvnorm(lower=-Inf, upper=Inf, mean, sigma, dependent.ind, given.ind, X.given, check.sigma=TRUE, algorithm = GenzBretz(), ...)
lower |
the vector of lower limits of length n. |
upper |
the vector of upper limits of length n. |
mean |
the mean vector of length n. |
sigma |
a symmetric, positive-definte matrix, of dimension n x n, which must be specified. |
dependent.ind |
a vector of integers denoting the indices of the dependent variable Y. |
given.ind |
a vector of integers denoting the indices of the conditioning variable X. If specified as integer vector of length zero or left unspecified, the unconditional distribution is used. |
X.given |
a vector of reals denoting the conditioning value of X. This should be of the same length as |
check.sigma |
logical; if |
algorithm |
an object of class |
... |
additional parameters (currently given to |
This program involves the computation of multivariate normal probabilities with arbitrary correlation matrices.
The evaluated distribution function is returned with attributes
error |
estimated absolute error and |
msg |
status messages. |
n <- 10 A <- matrix(rnorm(n^2), n, n) A <- A %*% t(A) pcmvnorm(lower=-Inf, upper=1, mean=rep(1,n), sigma=A, dependent.ind=3, given.ind=c(1,4,7,9,10), X.given=c(1,1,0,0,-1)) pcmvnorm(lower=-Inf, upper=c(1,2), mean=rep(1,n), sigma=A, dep=c(2,5), given=c(1,4,7,9,10), X=c(1,1,0,0,-1)) pcmvnorm(lower=-Inf, upper=c(1,2), mean=rep(1,n), sigma=A, dep=c(2,5))
n <- 10 A <- matrix(rnorm(n^2), n, n) A <- A %*% t(A) pcmvnorm(lower=-Inf, upper=1, mean=rep(1,n), sigma=A, dependent.ind=3, given.ind=c(1,4,7,9,10), X.given=c(1,1,0,0,-1)) pcmvnorm(lower=-Inf, upper=c(1,2), mean=rep(1,n), sigma=A, dep=c(2,5), given=c(1,4,7,9,10), X=c(1,1,0,0,-1)) pcmvnorm(lower=-Inf, upper=c(1,2), mean=rep(1,n), sigma=A, dep=c(2,5))