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

Roger Bivand Roger.Bivand at nhh.no
Sat Oct 13 15:23:57 CEST 2012


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