From wdunlap at tibco.com  Sun Aug 30 01:07:39 2009
From: wdunlap at tibco.com (William Dunlap)
Date: Sat, 29 Aug 2009 16:07:39 -0700
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: <77EB52C6DD32BA4D87471DCD70C8D70001B72E05@NA-PA-VBE03.na.tibco.com>


> -----Original Message-----
> From: r-devel-bounces at r-project.org 
> [mailto:r-devel-bounces at r-project.org] On Behalf Of claus.henry at gmx.de
> Sent: Saturday, August 29, 2009 12:35 AM
> To: r-devel at stat.math.ethz.ch
> Cc: R-bugs at r-project.org
> Subject: [Rd] round off errors? (PR#13918)
> 
> 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(nam
> es(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.

With the argument
   test = data.frame(x = gl(2, 3), y = gl(3, 2))
minet version 2.0.0 (Date: 2009-08-19) returns diagonals more than 1 and
minet version 1.6.0 (Date: 2007) returns diagonals of 1.  This happens in
both R 2.9.1 and 2.9.2.  I would suspect changes in minet rather than R
are the problem.  Mail to the Maintainer listed in packageDescription("minet").

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com 

> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 



[Rd] round off errors? (PR#13918)
William Dunlap