Skip to content
Prev 43557 / 398506 Next

mvrnorm problem

Stuart V Jordan <sjordan at princeton.edu> writes:
You might, for at least two good reasons, have said that this is from
library(MASS). The point is that
Error in mu + eS$vectors %*% diag(sqrt(pmax(ev, 0)), p) %*% t(X) :
        non-conformable arrays
Error in mu + eS$vectors %*% diag(sqrt(pmax(ev, 0)), p) %*% t(X) :
        non-conformable arrays
[,1]       [,2]
 [1,]  0.5005327  1.1919216
 [2,]  2.8273925  2.7004788
 [3,]  2.6493970  1.1304274
....

and the docs quite clearly say that mu wants to be a vector, not a
matrix. 

Curiously enough, this works with rmvnorm from the mvtnorm package by
Genz, Bretz, and Hothorn, the difference being that this version adds
in the means with a sweep() operation, whereas mvrnorm just adds mu
(to the transpose of the ultimate result) and relies on recycling
rules. I.e. the point is that
Error in x + M : non-conformable arrays
Error in t(x) + M : non-conformable arrays
[,1] [,2]
[1,]    2    4
[2,]    4    6
[,1] [,2]
[1,]    2    4
[2,]    4    6