[R] KLdiv question

Ralf B ralf.bierig at gmail.com
Thu Jul 29 20:33:35 CEST 2010


I am having a data set that causes flexmix::KLdiv to produce NA as a
result and I was told that increasing the sensitivity of the 'esp'
value can be used to avoid a lot of values being set to a default
(which presumably causes the problem).

Now here my question.

When running KLdiv on a normal distribution:

a <- rnorm(50000)
b <- rnorm(50000)
mydata <- cbind(a,b)
KLdiv(mydata, esp=1e-4)
KLdiv(mydata, esp=1e-5)
KLdiv(mydata, esp=1e-6)
KLdiv(mydata, esp=1e-7)
KLdiv(mydata, esp=1e-8)
KLdiv(mydata, esp=1e-9)
KLdiv(mydata, esp=1e-10)
KLdiv(mydata, esp=1e-100)

the result is stable independent from the chosen esp accuracy.
However, when I run the data on a distribution such as values in a
given range, I get NA and the method seems not to work independently
of how high I choose the accuracy.


y1 <- sample(1:1280, 200000, replace=T)
y2 <- sample(1:1280, 200000, replace=T)
mydata2 <- cbind(y1,y2)
KLdiv(mydata2, esp=1e-4)
KLdiv(mydata2, esp=1e-5)
KLdiv(mydata2, esp=1e-6)
KLdiv(mydata2, esp=1e-7)
KLdiv(mydata2, esp=1e-8)
KLdiv(mydata2, esp=1e-9)
KLdiv(mydata2, esp=1e-10)
KLdiv(mydata2, esp=1e-100)

Am I doing something wrong here? Does KL have any distributional
assumptions that I violate?

Best,
Ralf



More information about the R-help mailing list