Applied Spatial Statistics: Problem Set # 1

Michael Patterson

date()
## [1] "Tue Feb 12 13:45:49 2013"

Due Date: February 13, 2013

Total Points: 40

Use the Columbus, OH crime data from “http://geodacenter.org/downloads/data-files/columbus.zip”.

  1. Read the data into R and create a choropleth map of the CRIME variable using the ssplot method.
suppressMessages(require(maptools))
## Warning: package 'maptools' was built under R version 2.15.2
## Warning: package 'sp' was built under R version 2.15.2
suppressMessages(require(RColorBrewer))
## Warning: package 'RColorBrewer' was built under R version 2.15.2
tmp = download.file("http://geodacenter.org/downloads/data-files/columbus.zip", 
    "columbus.zip", mode = "wb")
unzip("columbus.zip")
columbus = readShapeSpatial("columbus.shp", proj4string = CRS("+proj=longlat +ellps=clrk66"))
rng = seq(0, 70, 10)
colors = brewer.pal(8, "Oranges")
spplot(columbus, "CRIME", col.regions = colors, at = rng, main = "Crimes per 1000 Households", 
    pretty = TRUE)

plot of chunk unnamed-chunk-2

  1. Compute Moran's I for the CRIME variable.
suppressMessages(require(spdep))
## Warning: package 'spdep' was built under R version 2.15.2
## Warning: package 'deldir' was built under R version 2.15.2
## Warning: package 'coda' was built under R version 2.15.2
columbus = readShapeSpatial("columbus")
columbus.nb = poly2nb(columbus)
columbus.wts = nb2listw(columbus.nb)
moran.test(columbus$CRIME, columbus.wts)
## 
##  Moran's I test under randomisation
## 
## data:  columbus$CRIME  
## weights: columbus.wts  
##  
## Moran I statistic standard deviate = 5.589, p-value = 1.139e-08
## alternative hypothesis: greater 
## sample estimates:
## Moran I statistic       Expectation          Variance 
##          0.500189         -0.020833          0.008689
  1. Create a Moran's scatter plot using the CRIME variable. Label the axes and include the regression line.
suppressMessages(require(ggplot2))
crime = columbus$CRIME
Wcrime = lag.listw(columbus.wts, crime)

dat = data.frame(crime = crime, Wcrime = Wcrime)
ggplot(dat, aes(x = crime, y = Wcrime)) + geom_point() + geom_smooth(method = "lm") + 
    xlab("Crimes per 1000 Households") + ylab("Spatial Lag of Crimes")

plot of chunk unnamed-chunk-4

  1. Check the value of Moran's I by finding the slope of the regression line.
lm(Wcrime ~ crime, data = dat)
## 
## Call:
## lm(formula = Wcrime ~ crime, data = dat)
## 
## Coefficients:
## (Intercept)        crime  
##        17.5          0.5