Skip to main content

Section 7.4 Homogeneous or spatially varying intensity?

Central to our exploratory point pattern analysis is the notion of intensity, that is the average number of points per area. A key question that concerns us is whether this intensity is homogeneous or uniform, or rather is spatially varying due, for example, to spatially varying risk factors. With spatstats you can produce a quick estimate of intensity for the whole study area if you assume a homogeneous distribution with intensity.ppp().
intensity.ppp(jitter_bur)
## [1] 2.92e-05
Metres are a small unit. So the value we get is very close to zero and hard to interpret. We can use the rescale() function (in spatstat package) to obtain the intensity per kilometres instead. The second argument is the number we multiply our original units by:
intensity.ppp(rescale(jitter_bur, 1000, "km"))
## [1] 29.2
We see this result that overall the intensity across our study space is about 29 burglaries per square kilometre. Does this sound right? Well, Manhattan has roughly 59.1 km\(^2\text{.}\) If we divide 1727 incidents by this area, we get around 29 burglaries per km\(^2\text{.}\) This estimate, let’s remember, assumes that the intensity is homogeneous across the study window.
If we suspect the point pattern is spatially varying, we can start exploring this. One approach is to use quadrat counting. A quadrat refers to a small area — a term taken from ecology where quadrats are used to sample local distribution of plants or animals. One could divide the window of observation into quadrats and count the number of points into each of these quadrats. If the quadrats have an equal area and the process is spatially homogeneous, then one would expect roughly the same number of incidents in each quadrat.
For producing this counting, we use the quadratcount() function (in spatstat). The nx and ny argument in this function control how many breaks you want alongside the X and Y coordinates to create the quadrats. So to create 6 quadrats from top to bottom of Manhattan, we will set them to 1 and 6, respectively. The configuration along the X and Y and the number of quadrats is something you will have to choose according to what is convenient to you. Then we just use standard plotting functions from R base.
q <- quadratcount(jitter_bur, nx = 1, ny = 6)
plot(q, main = "Quadrat Count")
The outline of Manhattan is divided, using five horizontal lines, into sections. Starting from the tip, the spacing of the lines is even. Numbers appear in each section, roughly corresponding to their area, except for the fourth from the top being smaller. The title ’Quadrat Count’ appears above.
Figure 7.4.1. Count of burglaries in quadrats
As you can see, with its irregular shape it is difficult to divide Manhattan in equally shaped and sized quadrats, and thus it is hard to assess if regions of equal area contain a similar number of points. Notice, however, how the third quadrat from the bottom seems to have less incidents than the ones that surround it. A good portion of this quadrat is taken by Central Park, where you would not expect a burglary.
Instead, we can use other forms of tessellation, like hexagons by using the hextess() function (in spatstat). This is similar to the binning we introduced in Chapter 4, only using different functions. The numeric argument sets the size of the hexagons, you will need to play along to find an adequate value for your own applications. Rather than printing the numbers inside these hexagons (if you have many, this will make it difficult to read in a plot), we can map a colour to the intensity (the number of points per hexagon):
hex <- hextess(jitter_bur, 200)
q_hex <- quadratcount(jitter_bur, tess = hex)
plot(intensity(q_hex, image = TRUE), main = "Intensity map")
A shaded map of Manhattan, labeled ’Intensity map’. A legend to the right matches a gradient from dark blue to yellow with numbers, from zero to small fractions represented in scientific notation. Most of Manhattan is blue, with red patches present all over, excluding Central Park. A few spots in the south and north reach orange and yellow intensities.
Figure 7.4.2. Intensity map of burglaries per hexagon
We can see more clearly now that areas of Manhattan, like Central Park, have understandably a very low intensity of burglaries, whereas others, like the Lower East Side and north of Washington Heights, have a higher intensity. So this map suggests to us that the process may not be homogeneous — hardly surprising when it comes to crime.
A key concept in spatial point pattern analysis is the idea of complete spatial randomness (CSR). When we look at a point pattern process, the first step in the process is to ask whether it has been generated in a random manner. Under CSR, points are (1) independent of each other (independence) and (2) have the same propensity to be found at any location (homogeneity).
We can generate data that conform to complete spatial randomness using the rpoispp() function (in spatstat). The r at the beginning is used to denote we are simulating data (you will see this is common in R), and we are using a Poisson point process, a good probability distribution for these purposes. Let’s generate 300 points in a random manner and save this in the object poisson_ppp:
set.seed(1) # Use this seed to ensure you get the same results as us
poisson_ppp <- rpoispp(300)
We can plot this, to see how it looks:
plot(poisson_ppp, main = "Complete Spatial Randomness")
A black square, with many small black circles spread out inside of it, titled ’Complete Spatial Randomness’. The circles form clusters and line-like shapes here and there, with many open spaces present.
Figure 7.4.3. Simulated complete spatial randomness
You will notice that the points in a homogeneous Poisson process are not ’uniformly spread’: there are empty gaps and clusters of points. This is very important. Random may look like what you may think non-random should look. There seem to be places with apparent "clustering" of points. Keep this in mind when observing maps of crime distributions. Run the previous command a few times. You will see the map generated is different each time.
In classical literature, the homogeneous Poisson process (CSR) is usually taken as the appropriate ’null’ model for a point pattern. Our basic task in analysing a point pattern is to find evidence against CSR. We can run a Chi Square test to check this in our data. So, for example, like we did above with Manhattan, we can split our area into quadrats.
q2 <- quadratcount(poisson_ppp, nx = 6, ny = 6)
plot(q2, main = "Quadrat Count")
A six by six grid with numbers in each cell, titled ’Quadrat Count’. The numbers range from two to fifteen, with no particular pattern.
Figure 7.4.4. Count of our random points in quadrats
These numbers are looking more even than they did with our burglaries, but to really put this to the test, we run the Chi Square test using the quadrat.test() function.
quadrat.test(poisson_ppp, nx = 6, ny = 6)
## 
##  Chi-squared test of CSR using quadrat counts
## 
## data:  poisson_ppp
## X2 = 44, df = 35, p-value = 0.3
## alternative hypothesis: two.sided
## 
## Quadrats: 6 by 6 grid of tiles
We can see this p-value is greater than the conventional alpha level of 0.05, and therefore we cannot reject the null hypothesis that our point patterns come from complete spatial randomness — which is great news, as they indeed do!
How about our burglaries? Let’s run the quadrat.test() function to tell us whether burglaries in Manhattan follow spatial randomness.
quadrat.test(jitter_bur, nx = 1, ny = 6)
## 
##  Chi-squared test of CSR using quadrat counts
## 
## data:  jitter_bur
## X2 = 238, df = 5, p-value <2e-16
## alternative hypothesis: two.sided
## 
## Quadrats: 6 tiles (irregular windows)
Observing the results, we see that the p value is well below conventional standards for rejection of the null hypothesis. Observing our data of burglary in Manhattan would be extremely rare if the null hypothesis of a homogeneous distribution was true. We can then conclude that the burglary data is not randomly distributed in the observed space. But no cop nor criminologist would really question this. They would rarely be surprised by your findings! We do know, through research, that crime is not randomly distributed in space.
Beware as well that this test would come out as significant if the point pattern violates the property of independence between the points. It is important to keep in mind that the null may be rejected either because the process is not homogeneous or because the points are not independent, but the test doesn’t tell us the reason for the rejection. Equally, the power depends on the size of the quadrats (and they are not too large or too small). And the areas are not of equal size here in any case. So the test in many applications will be of limited use.