> mvrnorm(25, mu=rep(182,2), Sigma=diag(100,2))
Error in "%*%.default"(eS$vectors, diag(sqrt(max..: Number of columns of x
should be the same as number of rows of y
Dumped
Could someone tell me were I'm wrong.
Thanks in advance,
Marcello.
P.S. I've found the following function in help pages about rnorm:
rmultnorm <- function(n, mu, vmat, tol = 1e-07)
{
p <- ncol(vmat)
if(length(mu)!=p)
stop("mu vector is the wrong length")
if(max(abs(vmat - t(vmat))) > tol)
stop("vmat not symmetric")
vs <- svd(vmat)
vsqrt <- t(vs$v %*% (t(vs$u) * sqrt(vs$d)))
ans <- matrix(rnorm(n * p), nrow = n) %*% vsqrt
ans <- sweep(ans, 2, mu, "+")
dimnames(ans) <- list(NULL, dimnames(vmat)[[2]])
ans
}
This seems to work, but how much can I trust in it?
_____________________________________________
Marcello D'Orazio
Fac. of Economy, Univ. of Salerno
P.zza Guerrazzi, 1
82100 Benevento
ITALY
mark@mail.media.it