# How to efficiently simulate values from a multivariate normal given one of the components?

Suppose $X, Y_i$ for $i=1...n$ are standard normal variable but are also correlated so collectively they come from a multivariate normal distribution.

Now the complication is what if I want to generate the values of $Y_i$ given $X$? For case where $n=1$ it can be shown that $Y_1|X \sim \mathcal{N}(\rho X,1-\rho^2)$ where $\rho = \text{cov}(X,Y)$.

For large $n$ it's quite tricky to derive $Y_i|X$.

Is there a package in R that can do this simulation (via copula, multivariate normal or any other mean) already?

• The statement "the marginals are normal and the variables are correlated" doesn't imply you have multivariate normal, so the conclusion in the statement "$X,Y_i$ for $i=1,...,n$ are standard normal variable but are also correlated so collectively they come from a multivariate normal distribution." is not correct. You can state/assume multivariate normality but it doesn't follow from those conditions. – Glen_b -Reinstate Monica Aug 12 '15 at 6:56

Let $$(X, Y_1, \dots, Y_n) \sim \mathcal N\left( \begin{bmatrix}\mu_X\\\mu_Y\end{bmatrix}, \begin{bmatrix}\Sigma_X & \Sigma_{XY} \\ \Sigma_{XY}^T & \Sigma_Y\end{bmatrix} \right) .$$ Then $$(Y_1, \dots, Y_n \mid X = x) \sim \mathcal N\left( \mu_Y + \Sigma_{XY}^T \Sigma_X^{-1} (x - \mu_X), \Sigma_Y - \Sigma_{XY}^T \Sigma_X^{-1} \Sigma_{XY} \right) .$$
• What Dougal has written is correct. However, actually computing this in a numerically stable manner if $$\ \Sigma_X^{-1} \,$$ is ill-conditioned is extremely tricky business. – Mark L. Stone Aug 12 '15 at 14:49
• @MarkL.Stone In this particular case, $\Sigma_X$ is $1 \times 1$, so it's not an issue; but yes, in general some care is necessary. – Dougal Aug 12 '15 at 22:48