#
# compute variogram for the midwest ozone field day 16
# (BTW this looks a bit strange!)
#
data( ozone2)
good<- !is.na(ozone2$y[16,])
x<- ozone2$lon.lat[good,]
y<- ozone2$y[16,good]
look<-vgram( x,y, N=15, lon.lat=TRUE) # locations are in lon/lat so use right
#distance
# take a look:
plot(look, pch=19)
#lines(look$centers, look$stats["mean",], col=4)
brk<- seq( 0, 250,, (25 + 1) ) # will give 25 bins.
## or some boxplot bin summaries using base R graphics
look<-vgram( x,y, N=45, lon.lat=TRUE)
bplot.xy( look$d, look$vgram,
breaks=look$breaks, outline=FALSE,
xlim=c( 0,250), xlab="miles",
ylim=c( 0, 2000), ylab="Variogram")
lines( look$centers, look$stats[2,], type="b",
col="magenta", pch=16)
#
# compute equivalent covariogram, but leave out the boxplots
#
look<-vgram( x,y, N=15, lon.lat=TRUE, type="covariogram")
plot(look, breaks=brk, col=4)
#
# compute equivalent cross-covariogram of the data with itself
#(it should look almost exactly the same as the covariogram of
#the original data, except with a few more points in the
#smallest distance boxplot and points are double counted)
#
look = crossCoVGram(x, x, y, y, N=15, lon.lat=TRUE, type="cross-covariogram")
plot(look, breaks=brk, col=4)
Run the code above in your browser using DataLab