*! version 1.3 03 Jan 2019

Title

mvnormalden -- Multivariate Normal Density

Syntax

mvnormalden, [options]

Required
x(numlist) Vector of quantiles.

Optional
mean(numlist) Mean vector.

sigma(string) Covariance matrix.

logdensity Print the log of the density.

Description

mvnormalden evaluates the probability density function of a specified multivariate normal distribution at a given vector of quantiles.
Arbitrary quantiles, means, and covariance matrices are supported.

An official Stata command, lnmvnormalden, is available that provides similar functionality to mvnormalden.
It should in general be preferred; mvnormalden is provided within mvtnorm only for completeness.

Options

Required

x(numlist) A numlist (vector) of quantiles at which to evaluate the probability density function.

Optional

mean(numlist) A numlist (vector) giving the mean of the multivariate normal distribution under consideration.
If specified, its length must be equal to the length of option x.
If left unspecified, it will default internally to the zero vector of the correct length.

sigma(string) A string (matrix) giving the covariance matrix of the multivariate normal distribution under consideration.
If specified, It must be symmetric positive-definite, and its number of rows (equivalently columns) must be equal to the length of option x.
If left unspecified, it will default internally to the identity matrix of the correct dimension.

logdensity If specified, this indicates that the log of the density (rather than the density itself) should be printed.

Examples

/// Example 1: Without specifying mean or sigma

mvnormalden, x(0, 0, 0)

/// Example 2: Specifying mean and sigma

mat Sigma = (1, 0.5, 0.5 \ 0.5, 1, 0.5 \ 0.5, 0.5, 1)

mvnormalden, x(0, 0, 0) mean(0.5, 1, 1.5) sigma(Sigma)

/// Example 3: Requesting the log of the density with logdensity

mat Sigma = (1, 0.25 \ 0.25, 1)

mvnormalden, x(1, 1) mean(2, 2) sigma(Sigma) log

Stored results

mvnormalden stores the following in r():

scalars:

r(density) Computed density.

r(log_density) Log of the computed density.

Authors

Dr Michael J Grayling
Population Health Sciences Institute, Newcastle University, UK
Email: michael.grayling@newcastle.ac.uk

Prof Adrian P Mander
Centre for Trials Research, Cardiff University, Cardiff, UK

See also

References:

Grayling MJ, Mander AP (2018) Calculations involving the multivariate normal and multivariate t distributions with and without truncation. Stata J 18(4):826-43.

Tong YL (2012) The multivariate normal distribution. Springer-Verlag: New York, US.

Related commands:

mvtnorm (for an overview of the functionality provided by mvtnorm)

Multivariate normal distribution

drawnorm (an official Stata command for multivariate normal random deviates)
invmvnormal (mvtnorm command for multivariate normal quantiles)
lnmvnormalden (an official Stata command for multivariate normal densities)
mvnormalcv (an official Stata command for the multivariate normal distribution function)
mvnormalden (mvtnorm command for multivariate normal densities)
pmvnormal (mvtnorm command for the multivariate normal distribution function)
rmvnormal (mvtnorm command for multivariate normal random deviates)

Multivariate t distribution

invmvt (mvtnorm command for multivariate t quantiles)
mvtden (mvtnorm command for multivariate t densities)
mvt (mvtnorm command for the multivariate t distribution function)
rmvt (mvtnorm command for multivariate t random deviates)

Truncated multivariate normal distribution

invtmvnormal (mvtnorm command for truncated multivariate normal quantiles)
rtmvnormal (mvtnorm command for truncated multivariate normal random deviates)
tmvnormal (mvtnorm command for the truncated multivariate normal distribution function)
tmvnormalden (mvtnorm command for truncated multivariate normal densities)

Truncated multivariate t distribution

invtmvt (mvtnorm command for truncated multivariate t quantiles)
rtmvt (mvtnorm command for truncated multivariate t random deviates)
tmvt (mvtnorm command for the truncated multivariate t distribution function)
tmvtden (mvtnorm command for truncated multivariate t densities)