Description Usage Arguments See Also Examples
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
.
1 2 3 4 5 |
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
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 | # 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")
|
Loading required package: mvtnorm
[1] 0.009999045
[1] 0.123279
[1] 0.02100965
[,1] [,2]
[1,] 1.2000002 3.7253580
[2,] -2.2144327 3.5010243
[3,] 2.6595635 1.3870690
[4,] 0.1716712 1.4252364
[5,] 3.5443766 0.4818144
[6,] 4.3348101 0.2178473
[7,] 1.5982459 0.3949418
[8,] 0.5691923 2.4658303
[9,] -0.8127347 2.6452715
[10,] 3.7410713 1.0753681
[,1]
[1,] 0.8694035
[2,] 0.4105557
[3,] 1.2604878
[4,] 1.6329019
[5,] 0.2163954
[6,] 1.8965768
[7,] -0.1548697
[8,] -0.4969254
[9,] 0.7036734
[10,] 0.1048095
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.