Learn R Programming

tmvtnorm (version 0.8-3)

mtmvnorm: Computation of Mean Vector and Covariance Matrix For Truncated Multivariate Normal Distribution

Description

Computation of the first two moments, i.e. mean vector and covariance matrix for the Truncated Multivariate Normal Distribution based on the works of Tallis (1961), Lee (1979) and Leppard and Tallis (1989), but extended to the double-truncated case with general mean and general covariance matrix.

Usage

mtmvnorm(mean, sigma, lower, upper)

Arguments

mean
Mean vector, default is rep(0, length = ncol(x)).
sigma
Covariance matrix, default is diag(ncol(x)).
lower
Vector of lower truncation points,\ default is rep(-Inf, length = length(mean)).
upper
Vector of upper truncation points,\ default is rep( Inf, length = length(mean)).

Value

  • meanMean vector of truncated variables
  • covCovariance matrix of truncated variables

References

Tallis, G. M. (1961). The moment generating function of the truncated multinormal distribution. Journal of the Royal Statistical Society, Series B, 23, 223--229 Lee, L.-F. (1979). On the first and second moments of the truncated multi-normal distribution and a simple estimator. Economics Letters, 3, 165--169 Leppard, P. and Tallis, G. M. (1989). Evaluation of the Mean and Covariance of the Truncated Multinormal. Applied Statistics, 38, 543--553 Manjunath B G and Wilhelm, S. (2009). Moments Calculation For the Double Truncated Multivariate Normal Density. Working Paper. Available at SSRN: http://ssrn.com/abstract=1472153

Examples

Run this code
mu    <- c(0.5, 0.5, 0.5)
  sigma <- matrix(c(  1,  0.6, 0.3,
                    0.6,    1, 0.2,
                    0.3,  0.2,   2), 3, 3)
                    
  a  <- c(-Inf, -Inf, -Inf)
  b  <- c(1, 1, 1)

  # compute first and second moments
  mtmvnorm(mu, sigma, lower=a, upper=b)
  
  # compare with simulated results
  X <- rtmvnorm(n=1000, mean=mu, sigma=sigma, lower=a, upper=b)
  colMeans(X)
  cov(X)

Run the code above in your browser using DataLab