我有一个真实情况试图使用bindata::rmvdata
生成随机n x 5个随机多元二项式数,如下所示:
margprob<-c(0.01325, 0.31142, 0.10000, 0.02837, 0.01273)
x<-c(0.013, 0.004, 0.002, 0.000,
0.000, 0.004, 0.311, 0.069,
0.023, 0.010, 0.002, 0.069,
0.100, 0.022, 0.010, 0.000,
0.023, 0.022, 0.028, 0.008,
0.000, 0.010, 0.010, 0.008,
0.013)
commonprob<-matrix(x, 5, 5, byrow=T)
res<-rmvbin(10000, commonprob=commonprob)
Error in commonprob2sigma(commonprob, simulvals) :
Extrapolation occurred ... margprob and commonprob not compatible?
然后我意识到这是由于sigma矩阵中的一对NA:
> sigma
[,1] [,2] [,3] [,4] [,5]
[1,] 1.00000 0.02671 0.1559 -0.5812 -0.4207
[2,] 0.02671 1.00000 0.5291 0.6024 0.6064
[3,] 0.15591 0.52908 1.0000 0.8325 0.8712
[4,] -0.58118 0.60240 0.8325 1.0000 NA
[5,] -0.42073 0.60644 0.8712 NA 1.0000
我的问题是,是否有解决方案来解决错误?