Applied Spatial Statistics: Problem Set # 1

Brendan Mulholland

date()
## [1] "Wed Feb 13 14:04:44 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, "Purples")
spplot(Columbus, "CRIME", col.regions = colors, at = rng, main = "Crime in Columbus", 
    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))
## Warning: package 'ggplot2' was built under R version 2.15.2
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("Crime in Columbus") + ylab("Spatial Lag in 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