[R] KLdiv produces NA. Why?

Peter Ehlers ehlers at ucalgary.ca
Fri Jul 9 15:32:27 CEST 2010


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
>



More information about the R-help mailing list