mtmvnorm.RdComputation 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.
Mean vector, default is rep(0, length = ncol(x)).
Covariance matrix, default is diag(ncol(x)).
Vector of lower truncation points,\
default is rep(-Inf, length = length(mean)).
Vector of upper truncation points,\
default is rep( Inf, length = length(mean)).
flag whether to compute the variance for users who are interested only in the mean.
Defaults to TRUE for backward compatibility.
Algorithm used for pmvnorm
Details for the moment calculation under double truncation and the derivation of the formula can be found in the Manjunath/Wilhelm (2009) working paper. If only a subset of variables are truncated, we calculate the truncated moments only for these and use the Johnson/Kotz formula for the remaining untruncated variables.
Mean vector of truncated variables
Covariance matrix of truncated variables
Tallis, G. M. (1961). The moment generating function of the truncated multinormal distribution. Journal of the Royal Statistical Society, Series B, 23, 223–229
Johnson, N./Kotz, S. (1970). Distributions in Statistics: Continuous Multivariate Distributions Wiley & Sons, pp. 70–73
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: https://www.ssrn.com/abstract=1472153
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)
#> $tmean
#> [1] -0.1523654 -0.1260814 -0.4047228
#>
#> $tvar
#> [,1] [,2] [,3]
#> [1,] 0.52250381 0.2205983 0.07755425
#> [2,] 0.22056486 0.5159841 0.03966102
#> [3,] 0.07764335 0.0397277 0.94676059
#>
# compare with simulated results
X <- rtmvnorm(n=1000, mean=mu, sigma=sigma, lower=a, upper=b)
colMeans(X)
#> [1] -0.1621463 -0.1131378 -0.3916306
cov(X)
#> [,1] [,2] [,3]
#> [1,] 0.52041810 0.20250396 0.08964462
#> [2,] 0.20250396 0.46615463 0.03078105
#> [3,] 0.08964462 0.03078105 0.94220838