Spatial Randomness Evaluation in R: Monte Carlo Test

[This article was first published on Misanthrope's Thoughts, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This post is a some kind of reply to this one.

So our goal is to determine whether our point process is random or not. We will use R and spatstat package in particular. Spatstat provides a very handy function for this, that uses K-function combined with Monte Carlo tests. I will spear you from burbling  about theory behind it – the necessary links were already provided. Lets get directly to action.

In this example I will test data about location of my “favourite” illegal dumps in St. Petersburg and Leningrad region.

# we will need: 
library(maptools) 
library(rgdal) 
library(spatstat)

# import data for analysis

S <- readShapePoints("custom_path/dump_centroids.shp", proj4string= CRS(“+proj=tmerc +lat_0=0 +lon_0=33 +k=1 +x_0=6500000 +y_0=0 +ellps=krass +towgs84=23.92,-141.27,-80.9,-0,0.35,0.82,-0.12 +units=m +no_defs”))

SP <- as(S, "SpatialPoints")
P <- as(SP, "ppp")

# perform the test itself with a 100 simulations

E <- envelope(P, Kest, nsim = 100)
plot(E, main = NULL)


And here is what we’ve got in the end, a fancy graph, which demonstrates that our data (Kobs) significantly deviates from a random process (Ktheo):



To leave a comment for the author, please follow the link and comment on their blog: Misanthrope's Thoughts.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)