Skip to content
Prev 8536 / 29559 Next

Problem with moran.test function

On Wed, 16 Jun 2010, Michael Haenlein wrote:

            
Well, Moran's I is -Inf, and the analytical variance is NA, so something 
is not right. The problem could lie in x, Network, or the lag of x (when 
x and Network are OK but their combination is unhappy). Can you run 
moran.test() under debug() and check which values lead the value of I to 
go to -Inf? Is this what is going on:

data(columbus)
set.seed(1)
x <- log(rpois(n=49, 2))
x
moran.test(x, nb2listw(col.gal.nb))

where the current spdep release fails reporting:

Error in lag.listw(listw, z, zero.policy = zero.policy, NAOK = NAOK) :
   Variable contains non-finite values

which was a fix introduced four weeks ago, changed to a test on |Inf| from 
a test on NA:

https://r-forge.r-project.org/scm/viewvc.php/pkg/src/lagw.c?root=spdep&r1=244&r2=282

If you update spdep, you'll pick up the improvement (made thanks to a bug 
report by Matias Mayor Fernandez), and if this is the case, the problem is 
in the x.

Hope this helps,

Roger