This question already has an answer here:

I have a multivariate normal distribution with parameters mean = 0 and a variance-covariance matrix K which is n-by-n. I'd like to generate a vector of values (length n) that represent the expected values of this MVN. Any advice on how to do this?


marked as duplicate by kjetil b halvorsen, mdewey, Juho Kokkala, Peter Flom Apr 22 '17 at 13:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    $\begingroup$ You write that the mean = 0. Therefore, the length n vector of zeros is the expected value of the MVN. Am I missing something? Is it perhaps the case that rather than generating the "expected values", you wish to generate random samples from the MVN distribution? $\endgroup$ – Mark L. Stone Dec 8 '15 at 19:28
  • $\begingroup$ Yes, I do mean random samples generated from the MVN distribution. In particular, I want n individuals, corresponding to each row/column in the K matrix. So if I have a matrix (1,.99,0,0; .99,1,0,0; 0,0,1,0; 0,0,0,1) I would want 4 individuals where individuals 1 and 2 are very closely tied to each other and independent from 3 and 4. $\endgroup$ – Jautis Dec 8 '15 at 19:45
  • 2
    $\begingroup$ R, MATLAB Statistics toolbox, and many statistics packages have built-in functions to generate random vectors from an MVN given its mean and covariance matrix. Alternatively, you can implement an approach specified in the "Drawing values from the distribution" section of en.wikipedia.org/wiki/Multivariate_normal_distribution . There are also many threads on this subject at the Cross Validated site. $\endgroup$ – Mark L. Stone Dec 8 '15 at 19:57
  • $\begingroup$ Thank you very much, that clears up a lot of confusion I was having! My final question would be how to get residuals from a model that includes a MVN random effect; it seems improper to just use the expectation and I've found it rather difficult to find good advice about this. $\endgroup$ – Jautis Dec 8 '15 at 20:51
  • 1
    $\begingroup$ I'm not sure what your final question is. Perhaps you should start a new thread and provide a more detailed account of your question. $\endgroup$ – Mark L. Stone Dec 8 '15 at 20:57