conditional_np: Conditional distribution of a multivariate normal...

Description Usage Arguments Value Examples

Description

This function can be used to obtain the conditional distribution of any Np.

Usage

1
conditional_np(x, mu, Sigma)

Arguments

x

is a vector with the values that are known. For example, c(3, NA, 5, NA) means that we are interested in the conditional distribution of X2 and X4 when X1=3 and X3=5.

mu

is the mean vector of the Np.

Sigma

is the covariance matrix of the Np.

Value

a list with the mean and covariance matrix of the conditional distribution.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Consider a N3 normal distribution
mu <- c(3, -1, 1)
Sigma <- matrix(c(3, -1, 1,
                  -1, 1, 0,
                  1, 0, 2), ncol=3)
                  
# We want the conditional distribution of X2 given X1=2 and X3=0
conditional_np(x=c(2, NA, 0), mu=mu, Sigma=Sigma)

# We want the conditional distribution of X1 and X3 given X2=2
conditional_np(x=c(NA, 2, NA), mu=mu, Sigma=Sigma)

fhernanb/usefultools documentation built on May 10, 2019, 8:06 a.m.