dcmvtruncnorm {condTruncMVN}R Documentation

Density of the Conditional Truncated Multivariate Normal

Description

Calculates the density of truncated conditional multivariate normal Y|X: f(Y = y | X = X.given). See the vignette for more information.

Usage

dcmvtruncnorm(
  y,
  mean,
  sigma,
  lower,
  upper,
  dependent.ind,
  given.ind,
  X.given,
  log = FALSE
)

Arguments

y

vector or matrix of quantiles of Y. If a matrix, each row is taken to be a quantile. This is the quantity that the density is calculated from.

mean

the mean vector for Z of length of n

sigma

the symmetric and positive-definite covariance matrix of dimension n x n of Z.

lower

a vector of lower bounds of length n that truncate Z

upper

a vector of upper bounds of length n that truncate Z

dependent.ind

a vector of integers denoting the indices of dependent variable Y.

given.ind

a vector of integers denoting the indices of conditioning variable X. If specified as integer vector of length zero or left unspecified, the unconditional density is returned.

X.given

a vector of reals denoting the conditioning value of X. This should be of the same length as given.ind

log

logical; if TRUE, densities d are given as log(d).

References

Horrace, W.C. 2005. Some results on the multivariate truncated normal distribution. Journal of Multivariate Analysis, 94, 209–221. https://surface.syr.edu/cgi/viewcontent.cgi?article=1149&context=ecn

Examples

# Example 1: X2,X3,X5|X2,X4 ~ N_3(1, Sigma)
# truncated between -10 and 10.
d <- 5
rho <- 0.9
Sigma <- matrix(0, nrow = d, ncol = d)
Sigma <- rho^abs(row(Sigma) - col(Sigma))

# Log-density of 0
dcmvtruncnorm(
  rep(0, 3),
  mean = rep(1, 5),
  sigma = Sigma,
  lower = rep(-10, 5),
  upper = rep(10, d),
  dependent.ind = c(2, 3, 5),
  given.ind = c(1, 4), X.given = c(1, -1),
  log = TRUE
)

[Package condTruncMVN version 0.0.2 Index]