From murdoch at stats.uwo.ca  Sat Aug 29 23:47:07 2009
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Sat, 29 Aug 2009 17:47:07 -0400
Subject: [Rd] round off errors? (PR#13918)
In-Reply-To: <20090829073511.11D28282EF4D@mail.pubhealth.ku.dk>
References: <20090829073511.11D28282EF4D@mail.pubhealth.ku.dk>
Message-ID: <4A99A1DB.8040504@stats.uwo.ca>

On 29/08/2009 3:35 AM, claus.henry at gmx.de wrote:
> Full_Name: Claus Pastor
> Version: 2.9.2
> OS: Windows XP
> Submission from: (NULL) (82.113.106.4)
> 
> 
> I use the following function to compute MutualInformation Matrix of factorial
> members of a dataframe. I use package minet for this:
> 
> my.MI = function(test) {
> ## die Diagonale gibt die Entropien, Teile durch entropy von y und du erh?lst
> den Zusammenhang
> ## kenne X und sage daraus y voraus
> 	require(minet)
> 	MI.matrix = matrix(0,nrow=length(test),ncol=length(test),dimnames=list(names(test),names(test)))
> 	for (i in 1:length(test)) {
> 		for (j in 1:length(test)) {
> 			temp = na.omit(test[,c(i,j)])
> 			MI = build.mim(temp)
> 			p.i = prop.table(table(temp[,1]))
> 			p.j = prop.table(table(temp[,2]))
> 			H.i = sum(-p.i*log(p.i))
> 			H.j = sum(-p.j*log(p.j))
> 			MI.matrix[i,j] = MI[1,2]/H.j
> 			MI.matrix[j,i] = MI[1,2]/H.i
> 		}
> 	}
> 	return(MI.matrix)
> }
> 
> 
> The function works well under R 2.8.
> 
> Under R2.9.2 it produces Mutual Information values (MI) of more than 1 (e.g.
> 1.000013) which are not allowed. MI is in [0:1]. I suppose there are rounding
> errors anywhere in the new R 2.9.2.

This is not a useful bug report:  you don't give the data that leads to 
the different values.

You should put together an example and work with the maintainer of the 
minet package to see if it's a bug in that package.  If it's not, then 
you should be able to put together an example that only involves the 
base R packages.

Duncan Murdoch



[Rd] round off errors? (PR#13918)
Duncan Murdoch