[R-sig-Geo] Error in Moran.test: In sqrt(VI) : NaNs

Roger Bivand Roger.Bivand at nhh.no
Thu Apr 5 12:50:11 CEST 2012


On Thu, 5 Apr 2012, Fabricio Vasselai wrote:

> Dear list,
>
> Maybe someone can shed some light on this error. I have a dataset with
> thousands of candidates with electoral support per city. I wrote a R script
> to calculate both Moran.test and Moran.MC (99999 iterations), and also
> Geary C test.
> The script run very fine, but at the end I have noticed that a few of my
> cases (candidates) didn't have a result to Moran.test's standard deviation
> and p-value. All estimates and values were normal for Moran.MC and Geary's
> C.
>
> The problem seems to be the following error:
>
> Moran's I test under randomisation

Under randomisation, the variance is formed in the usual way, but adjusted 
downward by a term multiplied by the kurtosis. It looks as though extreme 
values of kurtosis can generate this result (negative variance). If you 
try randomisation=FALSE, you assume normality, with randomisation=TRUE, 
the variance formula tries to adjust for departures from normality, but 
obviously here does not succeed. The kurtosis used is equivalent to:

library(e1071)
kurtosis(votoscandidato, type=1)+3

and it appears to tip when the kurtosis is greater than N. Next, the 
squared expectation is subtracted, which could push a marginally positive 
intermediate result negative. The conclusion is that your data have a 
distribution that is so non-normal (skew and kurtosis) that this 
analytical correction is being defeated.

A similar correction is made in geary.test(), but the term multipled by 
the kurtosis is itself smaller, so the test could also fail, but with even 
more severe kurtosis. The MC test is not failing because no analytical 
correction is used, not because of the number of iterations. However, I 
think that the test results in the presence of zero-inflation will be 
misleading, and that you may actually need to use the parametric bootstrap 
approach from DCluster, its accompanying article, and with reference to 
Waller & Gotway (2004).

Hope this clarifies,

Roger



>
> data:  votoscandidato
> weights: UF.listw.W
>
> Moran I statistic standard deviate = NaN, p-value = NA
> alternative hypothesis: two.sided
> sample estimates:
> Moran I statistic       Expectation          Variance
>     5.723951e-03     -2.409639e-03     -8.785771e-09
> Mensagens de aviso perdidas:1: In sqrt(VI) : NaNs produzidos2: In
> moran.test(x = votoscandidato, listw = UF.listw.W, zero.policy = TRUE,
> :
>  Out-of-range p-value: reconsider test arguments
>
>
>
>
>
> I checked the source data and those cases with such an error seem to
> be cases with a lot of zero votes in many of the cities. But the same
> problem does not affect Geary's C or Moran.MC (probably because of the
> high number of iterations).
>
>
>
> Maybe this is the problem? Any help or tips will very much appreciated.
>
>
>
> Best regards,
>
>
>
> FABRICIO
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list