# cmvnorm: Conditional Multivariate Normal Density and Random Deviates In condMVNorm: Conditional Multivariate Normal Distribution

## Description

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`.

## Usage

 ```1 2 3 4 5``` ```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")) ```

## Arguments

 `x` vector or matrix of quantiles of Y. If `x` is a matrix, each row is taken to be a quantile. `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 conditoning variable X. `X.given` a vector of reals denoting the conditioning value of X. When both `given.ind` and `X.given` are missing, the distribution of `Y` becomes `Z[dependent.ind]` `check.sigma` logical; if `TRUE`, the variance-covariance matrix is checked for appropriateness (symmetry, positive-definiteness). This could be set to FALSE if the user knows it is appropriate. `log` logical; if `TRUE`, densities d are given as log(d). `method` string specifying the matrix decomposition used to determine the matrix root of `sigma`. Possible methods are eigenvalue decomposition (`"eigen"`, default), singular value decomposition (`"svd"`), and Cholesky decomposition (`"chol"`). The Cholesky is typically fastest, not by much though.

`pcmvnorm`, `pmvnorm`, `dmvnorm`, `qmvnorm`

## Examples

 ``` 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``` ```# 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)) # 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") ```

### Example output

```Loading required package: mvtnorm
[1] 0.0107713
[1] 0.2015305
[1] 0.01439129
[,1]       [,2]
[1,] -0.88814858  2.5072793
[2,]  2.70908688  2.8084459
[3,]  4.22625209  3.3440151
[4,]  0.30349484  0.8166045
[5,]  0.04655676  2.5305519
[6,]  4.73486532 -0.4617487
[7,]  3.99160025  4.3062569
[8,]  1.33259647  2.5145424
[9,]  5.92979374  1.3411358
[10,]  2.81145901  6.8244006
[,1]
[1,] -0.6163202
[2,] -1.9986019
[3,] -1.5325207
[4,] -1.2097142
[5,]  0.1880000
[6,]  0.5213744
[7,]  0.6634217
[8,]  2.8479672
[9,]  0.5060431
[10,] -1.8740192
```

condMVNorm documentation built on May 29, 2017, 1:01 p.m.