I am trying to simulate draws from a multivariate normal using mvrnorm, and
am getting the following error message:
Error in mu + eS$vectors %*% diag(sqrt(pmax(ev, 0)), p) %*% t(X) :
non-conformable arrays
I do not understand why I am getting this message, since the vector of means
I am giving to the function is 13 by 1 and the variance matrix I am giving
to the function is 13 by 13...these matrices are therefore conformable,
right?
Is it possible that this is actually a problem with the
positive-definiteness of the variance matrix? The matrix I am attempting to
use has eigenvalues that are close to zero (but positive).
Here's a transcript of the commands I've tried:
> mvrnorm(n = 1000,B,V)
Error in mu + eS$vectors %*% diag(sqrt(pmax(ev, 0)), p) %*% t(X) :
non-conformable arrays
> mvrnorm(n = 1000,t(B),V)
Error in mu + eS$vectors %*% diag(sqrt(pmax(ev, 0)), p) %*% t(X) :
non-conformable arrays
> V
[,1] [,2] [,3] [,4] [,5]
[1,] 2.632324e+05 -1.286920e-01 -9.461830e-02 6.27173e-02 -2.625664e+00
[2,] -1.286920e-01 1.164268e+00 -7.496500e-03 4.95040e-03 -1.557751e-01
[3,] -9.461830e-02 -7.496500e-03 5.761000e-03 -6.66370e-03 6.366440e-02
[4,] 6.271730e-02 4.950400e-03 -6.663700e-03 8.23150e-03 -6.252150e-02
[5,] -2.625664e+00 -1.557751e-01 6.366440e-02 -6.25215e-02 1.753953e+02
[6,] 1.017806e+01 8.797900e-02 -1.028916e+01 9.75542e+00 -8.614497e+03
[7,] -1.286920e-01 1.164268e+00 -7.496500e-03 4.95040e-03 -1.557751e-01
[8,] 3.930000e-07 2.060000e-09 1.150000e-10 -1.39000e-10 5.550000e-09
[9,] -1.950000e-07 3.680000e-09 -2.050000e-11 8.86000e-12 -6.110000e-09
[10,] 4.530000e-07 4.610000e-10 9.250000e-12 -1.50000e-11 1.310000e-08
[11,] 1.170000e-06 -6.710000e-09 6.740000e-11 -1.68000e-10 -3.400000e-09
[12,] -9.600000e-07 3.970000e-09 -9.520000e-11 2.12000e-10 -3.430000e-10
[13,] -4.970000e-07 -2.070000e-10 -3.100000e-11 5.69000e-11 -2.270000e-09
[,6] [,7] [,8] [,9] [,10]
[1,] 1.017806e+01 -1.286920e-01 3.93000e-07 -1.95000e-07 4.53000e-07
[2,] 8.797900e-02 1.164268e+00 2.06000e-09 3.68000e-09 4.61000e-10
[3,] -1.028916e+01 -7.496500e-03 1.15000e-10 -2.05000e-11 9.25000e-12
[4,] 9.755420e+00 4.950400e-03 -1.39000e-10 8.86000e-12 -1.50000e-11
[5,] -8.614497e+03 -1.557751e-01 5.55000e-09 -6.11000e-09 1.31000e-08
[6,] 4.980406e+05 8.797900e-02 -4.67000e-07 3.50000e-07 -7.68000e-07
[7,] 8.797900e-02 1.164268e+00 2.06000e-09 3.68000e-09 4.61000e-10
[8,] -4.670000e-07 2.060000e-09 2.15049e-02 9.00950e-03 9.58560e-03
[9,] 3.500000e-07 3.680000e-09 9.00950e-03 1.58849e-02 1.65230e-03
[10,] -7.680000e-07 4.610000e-10 9.58560e-03 1.65230e-03 1.53024e-02
[11,] 5.610000e-07 -6.710000e-09 4.26370e-03 -9.08500e-04 6.03300e-03
[12,] -2.720000e-07 3.970000e-09 -3.98220e-03 4.55100e-04 -5.55290e-03
[13,] 9.530000e-08 -2.070000e-10 -1.38413e-02 -9.42850e-03 -1.12002e-02
[,11] [,12] [,13]
[1,] 1.17000e-06 -9.60000e-07 -4.97000e-07
[2,] -6.71000e-09 3.97000e-09 -2.07000e-10
[3,] 6.74000e-11 -9.52000e-11 -3.10000e-11
[4,] -1.68000e-10 2.12000e-10 5.69000e-11
[5,] -3.40000e-09 -3.43000e-10 -2.27000e-09
[6,] 5.61000e-07 -2.72000e-07 9.53000e-08
[7,] -6.71000e-09 3.97000e-09 -2.07000e-10
[8,] 4.26370e-03 -3.98220e-03 -1.38413e-02
[9,] -9.08500e-04 4.55100e-04 -9.42850e-03
[10,] 6.03300e-03 -5.55290e-03 -1.12002e-02
[11,] 9.29045e-02 -8.00488e-02 -2.21646e-02
[12,] -8.00488e-02 7.19209e-02 1.82813e-02
[13,] -2.21646e-02 1.82813e-02 1.76818e-02
> B
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] -22.02731 0.4982429 2.651566 -2.356899 31.65277 -3302.719 0.4982429
[,8] [,9] [,10] [,11] [,12] [,13]
[1,] 0.3675237 -0.2562356 0.4549983 4.901309 -4.464062 -0.0836918
> t(B)
[,1]
[1,] -22.0273100
[2,] 0.4982429
[3,] 2.6515660
[4,] -2.3568990
[5,] 31.6527700
[6,] -3302.7190000
[7,] 0.4982429
[8,] 0.3675237
[9,] -0.2562356
[10,] 0.4549983
[11,] 4.9013090
[12,] -4.4640620
[13,] -0.0836918
Thanks very much,
Stu Jordan
Princeton University
[[alternative HTML version deleted]]
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html