Learn R Programming

LaplacesDemon (version 16.1.0)

dist.Multivariate.Normal: Multivariate Normal Distribution

Description

These functions provide the density and random number generation for the multivariate normal distribution.

Usage

dmvn(x, mu, Sigma, log=FALSE) 
rmvn(n=1, mu, Sigma)

Arguments

x

This is data or parameters in the form of a vector of length \(k\) or a matrix with \(k\) columns.

n

This is the number of random draws.

mu

This is mean vector \(\mu\) with length \(k\) or matrix with \(k\) columns.

Sigma

This is the \(k \times k\) covariance matrix \(\Sigma\).

log

Logical. If log=TRUE, then the logarithm of the density is returned.

Value

dmvn gives the density and rmvn generates random deviates.

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))\)

  • Inventors: Robert Adrain (1808), Pierre-Simon Laplace (1812), and Francis Galton (1885)

  • 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: positive-definite \(k \times k\) covariance 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 a \(k \times k\) covariance matrix \(\Sigma\), which must be positive-definite.

The conjugate prior of the mean vector is another multivariate normal distribution. The conjugate prior of the covariance matrix is the inverse Wishart distribution (see dinvwishart).

When applicable, the alternative Cholesky parameterization should be preferred. For more information, see dmvnc.

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.

See Also

dinvwishart, dmatrixnorm, dmvnc, dmvnp, dnorm, dnormp, dnormv, plot.demonoid.ppc, plot.laplace.ppc, and plot.pmc.ppc.

Examples

Run this code
# NOT RUN {
library(LaplacesDemon)
x <- dmvn(c(1,2,3), c(0,1,2), diag(3))
X <- rmvn(1000, c(0,1,2), diag(3))
joint.density.plot(X[,1], X[,2], color=TRUE)
# }

Run the code above in your browser using DataLab