[R-sig-Geo] Moran's I test for spatial autocorrelation - "spdep" package

Roger Bivand Roger.Bivand at nhh.no
Sat Nov 12 14:08:20 CET 2016


On Fri, 11 Nov 2016, Thayse Nery wrote:

> Dear all,
>
>
> I would like to use the Moran's I test for residual spatial 
> autocorrelation. My dataset is in the long format [70000 , 17] and 
> represents a time series of Land Use and Land Cover Changes. Since I 
> have identical x and y coordinates, I am having trouble in performing 
> the Moran's test using the "spdep" package. I am able to perform the 
> Moran's test if I consider only one year at time, but I need to perform 
> the analyse for the whole dataset. My dataframe is called trainData.

Exactly, the duplicate points are the problem, but the point to major 
flaws in your whole workflow. The repeated observations of land use over 
time are not independent of previous time periods, and the modelling 
exercise is inappropriate too.

Read up about balanced spatial panel models, and re-figure your data to 
suit.

Next, obviously you are working with a categorial response, for which 
Moran's I is most likely inappropriate. You certainly should never test 
your categorical current state as if it was continuous. You can use 
join-count statistics, and you may be able to use join-count statistics on 
transitions.

You do not have 70,000 observations, you have NxT=70,000 observations, 
where for us N and T are unknown. Since you are using point support (most 
likely highly inappropriate), we know nothing about your spatial entities, 
which are most likely either raster cells or areal units.

If you think in spatial panel terms, you can generate an NxT by NxT 
sparse weights matrix using a Kronecker product, then join-counts on your 
categories, transitions, or differences in category between training and 
test sets. If N is not too big, you may be able to find something in the 
Spatial Filtering literature. Look at the spatial discrete choice 
literature, but even there, you'll probably not find spatial panel 
discrete choice, see for example from 5 years ago:

http://pages.stern.nyu.edu/~wgreene/SpatialDiscreteChoiceModels.pdf

My reply to a question like yours:

https://stat.ethz.ch/pipermail/r-sig-geo/2013-October/019586.html

stands. Consider contacting the authors of:

http://w3.avignon.inra.fr/sew2012/slides/3_Diallo_Geniaux.pdf

to ask whether anything is published and whether they could join this 
thread.

If your data are raster cells, autocorrelation will be very strong because 
homogeneous land use/cover areas are divided between many neighbouring 
cells; if your data are the land use/cover areas, parts of the areas may 
change category over time. Your approach will have to vary depending on 
your actual support, and point support should be motivated (sampling LUC 
maps across time at points??).

Hope this clarifies,

Roger

PS. reply to yourself in-thread to your R-help posting giving the link to 
this thread:

https://stat.ethz.ch/pipermail/r-sig-geo/2016-November/025105.html

>
>
> Below are the steps I have done:
>
> xy <- as.matrix(trainData [, c(5:6)])
>
> neighb.k1 <- knn2nb(knearneigh(xy , k=2, longlat=FALSE))
> distance <- max(unlist(nbdists(neighb.k1, xy, longlat=FALSE)))
> summary(distance)
>
> # Error in  assign neighbors based on a specified distance, all values = 0
> #Because of this error I am not able to continue the analysis
> # Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
> #    0       0       0       0       0       0
>
> gc.nb <- dnearneigh(xy, 0, distance, longlat=FALSE)
>
> ### 2. Assign weights to the areas that are linked by by creating a spatial weights matrix
> MyData_neighb_w <- nb2listw(gc.nb, zero.policy=T) #
>
> ## 3. Run statistical test to examine spatial autocorrelation (Moran's I on the DV)
> DV_SpatialAut <- moran.test(trainData$currentState, listw=MyData_neighb_w)
>
> ### 4. Test the Spatial autocorrelation in residuals:
> ## 4.1. Run the Multinomial Logit Model
>
> FitVglm is the Model
>
> ## Calculate the weighted matrix for the residuals from multinomial logit model
> MyDataFinal2 <- MyDataFinal
> MyDataFinal2$mlmresid <- residuals(FitVgamx)
>
> lm.morantest(FitVgamx, resfun=MyData_neighb_w)
>
> Is it possible to test for residual spatial autocorrelation for a time 
> series data with identical x and y coordinates using the "spdep" 
> package?
>
> Thank you in advance for any help you can provide.
>
>
>
> Thayse Nery
>
> PhD. Student
> School of Agricultural and Resource Economics (M089)
> The University of Western Australia
>
> 	[[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, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: Roger.Bivand at nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412



More information about the R-sig-Geo mailing list