0

At the risk of this being a somewhat vague question, I am going ahead and ask it anyways:

I am running a multivariate regression in R with two outcome variables and would like to assess the homogeneity of covariance matrices, but, alas, the Kullback test throws an error:

Error in cov(Y[X == lev.X[k], ]) : 
  supply both 'x' and 'y' or a matrix-like 'x'

Now, both x and y are matrices, so I really don't know what to do and would appreciate any kind of input.

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

I hope that helps illustrate the problem.

Primesty
  • 107
  • 1
  • 10
  • You should provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Show some sample input and how you are calling the function. – MrFlick Apr 28 '16 at 22:48
  • I added some more information. – Primesty Apr 28 '16 at 22:55
  • Is this the `Kullback` function from the `asbio` package? `psych` doesn't seem to have one. Also it would be better to `dput()` data to make it reproducible. What you've posted is difficult to load back into R to test. – MrFlick Apr 28 '16 at 23:00
  • Sorry about that - it is from the _asbio_ package... – Primesty Apr 28 '16 at 23:24
  • With dput() would I just upload a file? – Primesty Apr 28 '16 at 23:25
  • how can i use scipy to get the generator of a probability distribution with min KL divergence in python? – yishairasowsky May 18 '21 at 16:24

0 Answers0