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

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

# 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)
#> $mean #> [,1] #> [1,] -0.8 #> #> $sigma #> [,1] #> [1,] 0.6 #>
# We want the conditional distribution of X1 and X3 given X2=2 conditional_np(x=c(NA, 2, NA), mu=mu, Sigma=Sigma)
#> $mean #> [,1] #> [1,] 0 #> [2,] 1 #> #> $sigma #> [,1] [,2] #> [1,] 2 1 #> [2,] 1 2 #>