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.

1 2 3 4 5 6 |

`mean` |
Mean vector, default is |

`sigma` |
Covariance matrix, default is |

`lower` |
Vector of lower truncation points,\
default is |

`upper` |
Vector of upper truncation points,\
default is |

`doComputeVariance` |
flag whether to compute the variance for users who are interested only in the mean.
Defaults to |

`pmvnorm.algorithm` |
Algorithm used for |

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.

`tmean` |
Mean vector of truncated variables |

`tvar` |
Covariance matrix of truncated variables |

Stefan Wilhelm <Stefan.Wilhelm@financial.com>, Manjunath B G <bgmanjunath@gmail.com>

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: http://ssrn.com/abstract=1472153

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ```
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)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.