[R-sig-Geo] RE : question about autocov_dist function in "spdep" package

Roger Bivand Roger.Bivand at nhh.no
Wed Jun 30 18:52:08 CEST 2010


On Tue, 29 Jun 2010, Julien Beguin wrote:

> Thank you Roger for your fast response and Jenn for cc:ing your message 
> about autocov_dist in spdep. I am far to be a specialist in spatial 
> statistic and I know that autologistic models have been criticised in 
> inferential context (e.g. Dorman et al. ). Several authors (in ecology, 
> at least) also found it useful in prediction context (Betts et al.). I 
> guess that the debate might not be over...
>
> My objective is not to trust results of autologistic model without
> criticism but rather to compare them with other approaches (e.g. Moran 
> eigenvector, spatial regression, etc...).
>
> Sorry for my ignorance but what means:
>
> "general weights sum to zero". Is autocovariate term (not) calculated as 
> follows ? A = sum(wij*yj)/ sum(wij) where wij=1/euclidian distance 
> between i and j (for inverse distance). It is maybe a stupid question 
> but how could weights sum to zero?

No, it is A_i = sum_j(wij*yj)/ sum_j(wij)

So for some i, sum_j(wij) is zero, and A_1 = 0/0. If you are going to use 
general weigts, they should not sum to zero, but for some i, it is 
permitted. However, if you look at the code:

 		if (any(sapply(glist, function(x)
 			isTRUE(all.equal(sum(x), 0)))))
 			warning("zero sum general weights")

you will see that this is a warning, given properly when the condition is 
met. The code is the documentation here.

>
> Also, it is not false to say that I am asking to include a constant 
> vector of zeros, but only for points that have no neighbour in a single 
> region. Imagine a study area composed of 5 regions containing each N 
> presence/absence points with associated covariates. If I calculate the 
> autocovariate term for each region separately (with constant nbs) and 
> that for one region (not the others) the minimum distance between pair 
> of points < nbs value, it will crash for that region. It might be that 
> spatial autocorrelation vary from region to region, and that in a 
> specific region, A value based on a constant nbs among regions would be 
> zero (because of no neighbour) for that region.
>

What you said earlier was that you would encounter distance thresholds in 
data subsets for which no observations would have any neighbours. I have 
already explained that this is your problem.

Roger

> A GLMM with fixed factors: Y~ covariates + Autocovariate; and random 
> factors = 1|Region/Autocovariate could account for that, no?
>
> Thank you again for your time,
>
> Julien
> _______________________________________
> De : Roger Bivand [Roger.Bivand at nhh.no]
> Date d'envoi : 25 juin 2010 15:55
> À : Julien Beguin
> Cc : r-sig-geo at stat.math.ethz.ch
> Objet : Re: [R-sig-Geo] question about autocov_dist function in "spdep" package
>
> On Fri, 25 Jun 2010, Julien Beguin wrote:
>
>> Dear list member,
>>
>> I am using the autocov_dist function in spdep on binary point data set
>> to estimate the autocovariate to be used in autologistic regression
>> (session info at the end):
>>
>> coords<-as.matrix(cbind(datafile$X_COORD, datafile$Y_COORD))
>> ac1 <- autocov_dist(datafile$binary_variable, coords, nbs=400, type = "inverse", zero.policy=TRUE)
>>
>> It works fine with large value of nbs. When nbs value is below the neibhorhood distance of some pairs of point I get warnings because of empty neighbors:
>>
>>> Warning messages: 1: In autocov_dist(datafile$binary_variable, coords,
>>> nbs = 400, type = "inverse", :
>
>>> With value 400 some points have no neighbours
>>> 2: In nb2listw(nb, glist = gl, style = style, zero.policy = zero.policy) :
>>> zero sum general weights
>>
>> It seems, but I might be wrong, that points with no neighbour have an
>> autocov_dist value of zero. Since it is what I want, it is ok for me.
>
> No, the general weights sum to zero, as it says, you are using inverse.
>
>> But if I decrease nbs value below the smallest neighbourhood distance
>> among pairs of points in my data set, I get an error message:
>>
>>> Error in nb2listw(nb, glist = gl, style = style, zero.policy = zero.policy) :
>>>  No valid observations
>>> In addition: Warning messages:
>>> 1: In autocov_dist(datafile$binary_variable, coords, nbs = 100, type = "inverse",  :
>>> With value 100 some points have no neighbours
>>> 2: In nb2listw(nb, glist = gl, style = style, zero.policy = zero.policy) :
>>>  zero sum general weights
>>
>> My question is as follows: why do autocov_dist function require that at
>> least one neighbor pair exists? and why not returning zero value for all
>> points when no any point has a neighbor?
>>
>> This might appear to be a strange question but in my case I estimating
>> autocov_dist for different spatial block in which the minimum distance
>> between points vary from block to block, but still I would like a commun
>> nbs value for all block.
>
> It does indeed seem very strange, as you are asking to include a constant
> vector of zeros, which will alias the constant. The function itself is a
> really bad idea, and is included only to show (see Dormann et al 2007)
> that using it is inferior to all other methods examined there. Trying to
> include a second zero constant doesn't seem well-founded, to put it
> mildly.
>
> Hope this helps,
>
> Roger
>
>>
>> Thank you for your help,
>>
>> Julien Beguin
>> --------------------
>> Ph.D. student
>> Laval University
>> Québec, Canada
>>
>> SESSION INFO:
>>
>> R version 2.10.1 (2009-12-14)
>> i386-pc-mingw32
>> locale:
>> [1] LC_COLLATE=French_Canada.1252  LC_CTYPE=French_Canada.1252
>> [3] LC_MONETARY=French_Canada.1252 LC_NUMERIC=C
>> [5] LC_TIME=French_Canada.1252
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>> other attached packages:
>> [1] spdep_0.5-4         spam_0.20-3         coda_0.13-4
>> [4] deldir_0.0-12       maptools_0.7-29     foreign_0.8-40
>> [7] nlme_3.1-96         MASS_7.3-4          Matrix_0.999375-33
>> [10] lattice_0.17-26     boot_1.2-41         sp_0.9-60
>> [13] compositions_1.01-1 robustbase_0.5-0-1  tensorA_0.31
>> [16] rgl_0.91
>> loaded via a namespace (and not attached):
>> [1] grid_2.10.1  tools_2.10.1
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> --
> Roger Bivand
> Economic Geography Section, Department of Economics, Norwegian School of
> Economics and Business Administration, 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

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, 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