dist.Multivariate.Normal.Cholesky {LaplacesDemon} | R Documentation |
Multivariate Normal Distribution: Cholesky Parameterization
Description
These functions provide the density and random number generation for the multivariate normal distribution, given the Cholesky parameterization.
Usage
dmvnc(x, mu, U, log=FALSE)
rmvnc(n=1, mu, U)
Arguments
x |
This is data or parameters in the form of a vector of length
|
n |
This is the number of random draws. |
mu |
This is mean vector |
U |
This is the |
log |
Logical. If |
Details
Application: Continuous Multivariate
Density:
p(\theta) = \frac{1}{(2\pi)^{k/2}|\Sigma|^{1/2}} \exp(-\frac{1}{2}(\theta - \mu)'\Sigma^{-1}(\theta - \mu))
Inventor: Unknown (to me, anyway)
Notation 1:
\theta \sim \mathcal{MVN}(\mu, \Sigma)
Notation 2:
\theta \sim \mathcal{N}_k(\mu, \Sigma)
Notation 3:
p(\theta) = \mathcal{MVN}(\theta | \mu, \Sigma)
Notation 4:
p(\theta) = \mathcal{N}_k(\theta | \mu, \Sigma)
Parameter 1: location vector
\mu
Parameter 2:
k \times k
positive-definite matrix\Sigma
Mean:
E(\theta) = \mu
Variance:
var(\theta) = \Sigma
Mode:
mode(\theta) = \mu
The multivariate normal distribution, or multivariate Gaussian
distribution, is a multidimensional extension of the one-dimensional
or univariate normal (or Gaussian) distribution. A random vector is
considered to be multivariate normally distributed if every linear
combination of its components has a univariate normal distribution.
This distribution has a mean parameter vector \mu
of length
k
and an upper-triangular k \times k
matrix that is
Cholesky factor \textbf{U}
, as per the chol
function for Cholesky decomposition.
In practice, \textbf{U}
is fully unconstrained for proposals
when its diagonal is log-transformed. The diagonal is exponentiated
after a proposal and before other calculations. Overall, the Cholesky
parameterization is faster than the traditional parameterization.
Compared with dmvn
, dmvnc
must additionally
matrix-multiply the Cholesky back to the covariance matrix, but it
does not have to check for or correct the covariance matrix to
positive-definiteness, which overall is slower. Compared with
rmvn
, rmvnc
is faster because the Cholesky decomposition
has already been performed.
For models where the dependent variable, Y, is specified to be
distributed multivariate normal given the model, the Mardia test (see
plot.demonoid.ppc
, plot.laplace.ppc
, or
plot.pmc.ppc
) may be used to test the residuals.
Value
dmvnc
gives the density and
rmvnc
generates random deviates.
Author(s)
Statisticat, LLC. software@bayesian-inference.com
See Also
chol
,
dinvwishartc
,
dmvn
,
dmvnp
,
dmvnpc
,
dnorm
,
dnormp
,
dnormv
,
plot.demonoid.ppc
,
plot.laplace.ppc
, and
plot.pmc.ppc
.
Examples
library(LaplacesDemon)
Sigma <- diag(3)
U <- chol(Sigma)
x <- dmvnc(c(1,2,3), c(0,1,2), U)
X <- rmvnc(1000, c(0,1,2), U)
joint.density.plot(X[,1], X[,2], color=TRUE)