r_truncated_multivariate_normal: Simulate from a truncated multivariate normal distribution

Description Usage Arguments Value Examples

View source: R/r_truncated_multivariate_normal.R

Description

Simulate S in R^M and Z in R^d given S in (alpha,beta]$, where S = X + gamma^T Z with X ~ Normal(0,I_N) and Z ~ Normal(0,Gamma^T Gamma).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
r_truncated_multivariate_normal(
  n = 1,
  alpha,
  beta,
  gamma,
  Gamma,
  which = "Z",
  eps = 1e-12,
  maxit = 100
)

Arguments

n

Number of samples. Default: n=1.

alpha

Vector of lower bounds for S component.

beta

Vector of upper bounds for S component.

gamma

Matrix of linear transformations on Z component.

Gamma

Cholesky factor for variance on Z component.

which

Text string ("S"/"Z"/"SZ"/"all") deciding which componts are return. Default: which="Z".

eps

Convergence criteria for coupling from the past. Default: eps=1e-12.

maxit

Maximal number of steps in Gibbs sampler. Default: maxit=100.

Value

Simulations either as a matrix (if which="S" or "Z"), or as a list of matrices (if which="SZ").

Examples

1
r_truncated_multivariate_normal(n=10,alpha=rep(-1,5),beta=rep(1,5),gamma=matrix(rnorm(10),2,5),Gamma=matrix(c(1,1,0,1),2,2))

bomarkussen/probit documentation built on April 3, 2021, 7:38 p.m.