Plots of spatial statistics (Variograms)
As might be expected given the greater implicit structure of spatial data (in contrast to regular or aspatial data), single-number statistics that describe the data--the variance or standard deviation, for example--are less interpretable. However, insight can be gained by plotting multiple values of such statistics as a function of geographical location or distance. When viewed in conjunction with a map, such plots can reveal additional structure in the data.
Variograms (or semi-variograms)
The variogram displays the variances within groups of observations, plotted as a function of distance between the observations. For a number of reasons, the variogram has become the preferred method for displaying this tendency for nearby observations to be more alike than distant observations.
definition and characteristics of a variogram
The empirical variogram displays the variance among sets of pairs of points, summarized by increasing distances among points:
# gstat package variograms
library(gstat)
library(lattice)
trellis.device(color=TRUE, theme = "col.whitebg")
# construct x and y coordinates in kilometers
orstationc$y <- 110.*(orstationc$lat-42)
orstationc$x <- 110.*(orstationc$lon-(-125))*cos(orstationc$lat/
(360/(2*pi)))
plot(orstationc$x, orstationc$y)
# basic variogram
tann.vgm <- variogram(tann~1, loc= ~x+y, data=orstationc)
plot(tann.vgm)
The variogram cloud plot displays the individual point-pair contributions to the final variogram: When compared with the simple variogram it allows a subjective impression to be gained of whether the apparent pattern of spatial variation is related to systematic trends in the data or to a few unusual points.
# simple map to help interpret identified points
plot(orstationc$x, orstationc$y, type="n")
text(orstationc$x, orstationc$y, cex=0.75)
# variogram cloud plot
tann.vgm.cloud <- variogram(tann~1, loc= ~x+y, data=orstationc, cloud=T)
plot(tann.vgm.cloud, identify=TRUE)
The data for individual points can be listed by typing orstationc[n,], where n is the observation number identified by clicking.
The detrended variogram constructs a variogram for the residuals from a simple model that represents large-scale trends in the data:
# detrended variogram
tann.detrend.vgm <- variogram(tann~x+y, loc= ~x+y, data=orstationc)
plot(tann.detrend.vgm)
The directional empirical variogram constructs individual variograms arranged by direction:
# directional variogram
tann.dir.vgm <- variogram(tann~1, loc=~x+y, data=orstationc,
alpha=c(0,45,90,135))
plot(tann.dir.vgm)
Another implementation of variograms using the fields package
library(fields)
attach(orstationc)
loc <- cbind(lon, lat)
tann.vg <- vgram(loc, tann, N=12, dmax=300, lon.lat=T)
plot(tann.vg$d, tann.vg$vgram, ylab="gamma", xlab="distance")
lines(tann.vg$centers, tann.vg$stats["mean",], lwd=3, col="red")
plot(tann.vg$centers, tann.vg$stats["mean",], col="red")
brks <- seq(0, 300, 25)
# a boxplot version
bplot.xy(tann.vg$d, sqrt(tann.vg$vgram), breaks=brks, ylab="sqrt(VG)")