[R-sig-Geo] Plot local moran index "spdep"

Roger Bivand Roger.Bivand at nhh.no
Sun Oct 14 14:37:50 CEST 2012


On Sat, 13 Oct 2012, Jaime Burbano Girón wrote:

> Roger, again thanks.
>
> Evidently, how you say, a cloud point was plotted, I will try with hexbin
> package or the reduction of my data. However, I have two more questions
> taking advantage of your cordiality and expertise, hope I do not abuse of
> your generosity.
>
> I am also concerned about my model due to my spatial data type (raster
> grid), since until now I just had worked with geostatistics and lattices
> using information from municipalities (polygons). I want to perform a model
> for explain Net Primary Production as a function of Land Cover (4
> categories) and 3 Climatic variables. My idea is to include an additional
> covariate for explaining spatial structure.
>
> I have opted for include an eigenvector filtering function in concordance
> with the proposal of Dray S, Legendre P and Peres-Neto PR (2006), but I am
> not sure if this is the right option since also exists the semi-parametric
> spatial filtering approach from Tiefelsdorf M and Griffith DA. (2007), or
> something simpler like take the residuals of the regression between the
> study variable and geographical coordinates.

I think that you will face major difficulties in getting the eigenvectors 
of your (doubly centred) weights matrix. In addition, because the raster 
cells are very likely not well fitted to the underlying ecological units 
of NPP (which could be of all kinds of scales), you may run straight into 
the red herring controversy (is the observed spatial patterning scale or 
autocorrelation?). There are analytical ways of getting eigenvectors in 
the literature, but with your data size, you'll face major problems 
anyway. The issues are discussed in the Numerical Ecology with R book and 
partly in a forthcoming paper (possibly Dray et al.) in Ecological 
Monographs, but not really for large data sets.

Hope this helps,

Roger

>
> In the case in which including each of theme in the model, the assumptions
> of: independence, homoscedasticity and normality of residuals could be
> tested favorably, which of these could you recommend me to include?
>
> Finally, I have always experimented memory problems with r in time and
> capacity storage of virtual memory. The speed of processes have been
> recently managed by parallelizing its execution, however, I'm not sure if
> the allocation of big objects can be fixed just giving to the virtual
> memory a larger capacity than my RAM memory. I have a Intel Core i7-2670QM
> procesor of 2.2GHz with 8gb of RAM. It is OK if I set in R the memory limit
> to 10gb or a larger value?
>
> Roger, thanks in advance and my best regards.
>
> On Sat, Oct 13, 2012 at 8:23 AM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
>
>> On Fri, 12 Oct 2012, Jaime Burbano Girón wrote:
>>
>>  Roger thanks for your response.
>>>
>>> Also I am trying to plot my variable vs "spatial lag" ("moran.plot()") but
>>> I have some problems of memory.
>>>
>>> My data has 1 113 277 observations and R has not plotted the figure yet
>>> (since a couple of hours I ran the command line), do you think there is an
>>> error or it is possible to take all this time?
>>>
>>
>> Yes, a scatterplot of 1M points will alway take a very long time to plot,
>> and will almost certainly not be legible, the points will overplot one
>> another. If you need to visualise a high N scatterplot, see the hexbin
>> package - that is, simply lag the variable and plot the variable by its lag
>> using hexbin. However, I'm also certain that localmoran and a Moran
>> scatterplot will be meaningless unless you have demeaned the data first.
>> You need to model the data carefully, and then see whether any residual
>> spatial patterning remains. There must be lots of relevant covariates that
>> you are omitting.
>>
>> In addition, moran.plot() takes care to provide influence measures for the
>> linear relationship between the variable and its lag, pointing up outliers
>> that will also show up in the localmoran output. This necessarily takes
>> time, but is also used in the plot - and will be illegible in your case.
>>
>> We don't know your system resources, you didn't provide the output of
>> sessionInfo(); the slowness may also be caused by using virtual memory.
>>
>> Roger
>>
>>
>>> Again, thanks in advance.
>>>
>>> On Fri, Oct 12, 2012 at 8:43 AM, Roger Bivand <Roger.Bivand at nhh.no>
>>> wrote:
>>>
>>>  On Fri, 12 Oct 2012, Jaime Burbano Girón wrote:
>>>>
>>>>  Dear members of list,
>>>>
>>>>>
>>>>> I calculated a local moran index ("localmoran()") for my data (which
>>>>> come
>>>>> from a raster grid) with a queen spatial neighbor structure for
>>>>> construct
>>>>> the weights matrix.
>>>>>
>>>>> I would like to plot in a map the value of local moran index for each
>>>>> zone,
>>>>> however, I am not sure how to extract spatial information for each one
>>>>> of
>>>>> the values obtained of local moran index.
>>>>>
>>>>> My question is: if I am well in assume that the result of localmoran()
>>>>> function is in the same order that neighbor list, thus, I can assign
>>>>> coordinates of neighbors to each row of result matrix? something like:
>>>>>
>>>>> #Calculating neighbors
>>>>> kneig=knearneigh(cbind(data$x,****data$y),k=8)
>>>>>
>>>>> neig=knn2nb(neig)
>>>>>
>>>>> #Calculating weights for neighbors
>>>>> neiglist=nb2listw(neig,style="****W")
>>>>>
>>>>> #Spatial autocorrelation
>>>>> lmt=localmoran(data$z,****neiglist)
>>>>>
>>>>>
>>>>> #Data for plot local moran index
>>>>> data_map=cbind(lmt,data$x,****data$y)
>>>>>
>>>>>
>>>> Yes, in principle. It is possible to specify the region.id component in
>>>> the nb object, and check this against the IDs of data (or data$z) for
>>>> safety's sake, but here you should be OK. Note the structure of lmt.
>>>>
>>>> Roger
>>>>
>>>>
>>>>  Thanks in advance and best regards to all.
>>>>>
>>>>>         [[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<https://stat.ethz.ch/mailman/**listinfo/r-sig-geo>
>>>>> <https://**stat.ethz.ch/mailman/listinfo/**r-sig-geo<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
>>>>
>>>>
>>>
>>>
>>>
>>>
>> --
>> 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
>>
>
>
>
>

-- 
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