我试图通过使用库MASS
和函数dmvnorm
在R中使用多元正态分布。
我有矢量:
Y = c(26.385112, 17.108580, 11.907650, 4.737202)
Mu = c(31.19789, 30.33983, 29.48177, 28.62371)
协方差矩阵:
> Sigma
[,1] [,2] [,3] [,4]
[1,] 10.861298 -3.910141 -9.40906 -14.90798
[2,] -3.910141 24.890056 35.14521 54.67289
[3,] -9.409060 35.145213 88.97201 124.25376
[4,] -14.907979 54.672890 124.25376 203.10715
> dput(Sigma)
structure(c(10.8612978825767, -3.91014077427266, -9.4090596651869,
-14.9079785561011, -3.91014077427266, 24.8900558453267, 35.1452129330559,
54.6728897867201, -9.4090596651869, 35.1452129330559, 88.9720052972337,
124.253758129541, -14.9079785561011, 54.6728897867201, 124.253758129541,
203.107146238298), .Dim = c(4L, 4L))
所以,当我应用dmvnorm
时,我只得到一个密度,假定每个值给出4个密度。
dmvnorm(Y,mean=Mu,Sigma)
[1] 2.756653e-07
或者,我错了吗?如果没有,你能帮帮我吗?