GHK: GHK simulator

Description Usage Arguments Details Note Author(s) References Examples

View source: R/GHK.R

Description

Simulates m samples of the n-dimensional zero mean Truncated Normal MVTN(mu=0, Sigma, a, b) via the Geweke-Hajivassiliou-Keane (GHK) sampler. The GHK simulation method is EXACT, in comparison to the rtmvnorm() function in the tmvtnorm R package which has the arguement algorithm taking values c("rejection", "gibbs", "gibbsR"). The methods "gibbs" and "gibbsR" are very fast but only provide an approximate method, rather than an exact draw from an n-dimensional zero mean Truncated Normal MVTN(mu=0, Sigma, a, b). ################################################################################### ## GHK Simulator to exactly generate MVTN Samples ## Simulates n samples of the m-dimensional Truncated Normal ## MVTN( 0, Sigma, a, b) ## Zero Mean of MV Normal distn ## Sigma is the Covariance Matrix (m x m) of multivariate Normal distribution ## a is the lower truncation (m x 1 vector) ## b is the upper truncation (m x 1 vector) ## ## Arguements to be used: ## n - desired number of samples ## Sigma (Cov matrix) ## a (lower truncation) - which can be set to -Inf vector for right Truncation ## b (upper truncation) - which can be set to +Inf vector for left Truncation ## ## Requires: (no packages) m, Sigma, a, b, ## Output: m random samples from n-dimensional TN(0, Sigma, a b) distribution.

Usage

1
GHK(m, Sigma, a, b)

Arguments

m

m is the number of samples generated

mu=0

mu is set to be a vector of zeros of length n

Sigma

Sigma is the Covariance Matrix (n x n) of multivariate Normal distribution

a

a is the lower truncation (n x 1 vector)

b

b is the upper truncation (n x 1 vector)

Details

The generation of random numbers from a truncated multivariate normal distribution is done using the GHK simulator. The m samples are output into m columns. Each column is one sample from the MV TN(mu=0, Sigma, a, b).

Note

The function rtmvnorm() is used from the mvtnorm R Package.

Author(s)

Hannah Lennon

References

http://www.hss.caltech.edu/~mshum/gradio/ghk_desc.pdf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# A 2-dimensional example
Sigma  <- toeplitz(c(1, 0.5))
a <- c(-1, -2)
b <- c( 1,  1)
GHK(3, Sigma, a, b)

# Test to
cbind(a, GHK(5, Sigma, c(-1, -2), c(1, 1)), b)

# compare to approximate draw
# library(tmvtnorm)
# t(rtmvnorm(3, mean=c(0,0), Sigma, a, b))


# A 300-dimensional example
# d = 300
# Sigma  <- toeplitz(c(0.9^(1:d)))
# a <- rep(-2, times=d)
# b <- rep( 1, times=d)
# system.time(GHK(d, Sigma, a, b))

# compare to approximate draw
# library(tmvtnorm)
# system.time(t(rtmvnorm(d, mean=rep(0,times=d), Sigma, a, b ,algorithm="gibbsR")))

hlennon/copulaIVTS documentation built on Dec. 20, 2021, 4:45 p.m.