Description Usage Arguments Details Value Author(s) References Examples
This function simulates an importance sample from the truncated multivariate
normal distribution with mean equal to mean
and covariance matrix
sigma
, lower and upper truncation points lower
and upper
.
1 2 |
nsamp |
Number of samples to generate |
k |
Dimension |
lower |
Vector of lower truncation points,
default is |
upper |
Vector of upper truncation points,
default is |
imod |
Logical vector indicating whether truncation bounds of a particular dimension should be applied on the modulus (absolute value) of that component. Defaults to FALSE for all components |
means |
Mean vector, default is 0 for all components |
sigma |
Covariance matrix, default is identity matrix |
The simulation of truncated multivariate normal is done using importance sampling (GHK simulator) that uses a Cholesky decomposition of the covariance matrix to convert the problem of covering the truncation region to a recursive sampling from certain univariate truncated normals. Importance sampling weights are simultaneously returned. The original GHK algorithm has been slightly modified to allow truncation of some or all components using absolute value (modulus).
A list with the following two components:
samp |
A matrix of nsamp rows and k columns containing the simulated samples |
wts |
A vector of length nsamp containing the importance sampling weights |
Samsiddhi Bhattacharjee <sb1@nibmg.ac.in>
Geweke, J. 1989. Bayesian inference in econometric models using Monte Carlo integration. Econometrica 57: 1317-1339.
Hajivassiliou, V., and D. McFadden. 1998. The method of simulated scores for the estimation of LDV models. Econometrica 66: 863-896.
Keane, M. P. 1994. A computationally practical simulation estimator for panel data. Econometrica 62: 95-116
1 2 3 4 5 6 7 8 9 10 11 12 | low <- rep(1, 5)
high <- rep(2, 5)
sig <- matrix(0.1, 5, 5)
diag(sig) <- 1
res <- tmvnsim(nsamp=1000, k=5, lower=low, upper=high, imod=rep(TRUE, 5)
, means=rep(0, 5), sigma=sig)
head(res$samp)
head(res$wts)
cat("Probability of the region:\n")
mean(res$wts)
cat("Mean of Z-bar conditonal on truncation region:\n")
sum(rowMeans(res$samp) * res$wts)/sum(res$wts)
|
[,1] [,2] [,3] [,4] [,5]
[1,] 1.272399 1.017948 1.370517 -1.267175 -1.517365
[2,] 1.192184 -1.378414 1.342807 -1.188081 -1.805635
[3,] 1.129769 1.432602 1.173278 -1.005373 -1.316869
[4,] -1.572752 -1.098437 -1.424302 -1.844209 -1.595444
[5,] -1.559555 -1.926798 1.610041 -1.460966 -1.212117
[6,] -1.426719 -1.647535 1.745440 -1.063096 -1.231312
[1] 0.001561832 0.001438937 0.001578507 0.001731992 0.001583103 0.001529062
Probability of the region:
[1] 0.001572083
Mean of Z-bar conditonal on truncation region:
[1] -0.03444908
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.