*! version 1.1 03 Jan 2019

Title

rtmvnormal -- Truncated Multivariate Normal Random Deviates

Syntax

rtmvnormal, [options]

Required
lowertruncation(numlist miss) Vector of lower truncation points.

uppertruncation(numlist miss) Vector of upper truncation points.

Optional
n(#) Number of random deviates to generate.

mean(numlist) Mean vector.

sigma(string) Covariance matrix.

Description

rtmvnormal generates random deviates from a specified truncated multivariate normal distribution.
Arbitrary means, covariance matrices, and truncation points are supported.

It achieves the required generation using accept-reject sampling of random values generated from a corresponding multivariate normal distribution, using the method of rmvnormal.

Options

Required

lowertruncation(numlist miss) A numlist (vector) giving the lower truncation points for the truncated multivariate normal distribution under consideration.
Missing values are allowed, as . can be used to indicated a value is -Infinity.

uppertruncation(numlist miss) A numlist (vector) giving the upper truncation points for the truncated multivariate normal distribution under consideration.
Its length must be equal to the length of option lowertruncation, and the elements of uppertruncation must be strictly greater than the corresponding elements in lowertruncation.
Missing values are allowed, as . can be used to indicated a value is +Infinity.

Optional

n(#) An integer giving the number of random deviates to generate from the specified truncated multivariate normal distribution.
It must be greater than or equal to one.
It defaults to 1.

mean(numlist) A numlist (vector) giving the mean of the non-truncated multivariate normal distribution from which the truncated multivariate normal distribution under consideration is constructed.
If left unspecified, it will default internally to the zero vector of the correct length when sigma is specified, or the zero vector of length two when sigma is unspecified.

sigma(string) A string (matrix) giving the covariance matrix of the non-truncated multivariate normal distribution from which the truncated multivariate normal distribution under consideration is constructed.
If specified, it must be symmetric positive-definite, and if mean is also specified, its number of rows (equivalently columns) must be equal to the length of option mean.
If left unspecified, it will default internally to the identity matrix of the correct dimension when mean is specified, or the identity matrix of dimension two when mean is unspecified.

Examples

/// Example 1: Without specifying mean or sigma

rtmvnormal, lowertruncation(-2, -2, -2) uppertruncation(2, 2, 2) n(10)

/// Example 2: Specifying mean and sigma

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

rtmvnormal, lowertruncation(-2, -2, -2) uppertruncation(2, 2, 2) n(25) mean(1, 2, 3) sigma(Sigma)

Stored results

rtmvnormal stores the following in r():

matrices:

r(rtmvnormal) Generated random deviates.

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)