冒着这是一个有点模糊的问题的风险,我还是继续问:
我在 R 中运行具有两个结果变量的多元回归,并想评估协方差矩阵的同质性,但是,唉,Kullback 测试会引发错误:
Error in cov(Y[X == lev.X[k], ]) :
supply both 'x' and 'y' or a matrix-like 'x'
现在,x 和 y 都是矩阵,所以我真的不知道该怎么做,并且会感谢任何类型的输入。
library(psych)
y <- cbind(health_demo.z$years.of.life.lost.to.communicable.diseases......2002, health_demo.z$years.of.life.lost.to.non.communicable.diseases......2002)
x <- as.matrix(health_demo.z$population.in.urban.areas....)
Kullback(y, x)
head(x)
[,1]
[1,] -0.6723010
[2,] 1.4475329
[3,] 1.3543534
[4,] 0.3526736
[5,] -1.6040962
[6,] 0.6089173
head(y)
[,1] [,2]
[1,] -0.5076484 0.3191182
[2,] -0.4722119 0.4345915
[3,] -0.9328864 0.8579938
[4,] -1.0037594 1.0889405
[5,] 1.0161210 -1.0280708
[6,] -0.8620134 0.5115738
我希望这有助于说明问题。