On 2010-07-09 4:31, Ralf B wrote:
I am trying to calculate a Kullback-Leibler divergence from two
vectors with integers but get NA as a result when trying to calulate
the measure. Why?
x<- cbind(stuff$X, morestuff$X)
x[1:5,]
[,1] [,2]
[1,] 293 938
[2,] 293 942
[3,] 297 949
[4,] 290 956
[5,] 294 959
KLdiv(x)
[,1] [,2]
[1,] 0 NA
[2,] NA 0
I assume that you're using KLdiv() from pkg flexmix.
(You should always indicate any add-on packages used.)
I have no problem with KLdiv on the above 5-by-2 matrix
(R 2.11.1pat, flexmix 2.2-7).
Perhaps one of the following may be the case:
1. your R and/or flexmix is outdated;
2. dependencies were not installed (modeltools?)
3. there's something weird about your x[,]
-Peter Ehlers
Best,
Ralf
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.