##### R-code for making Figure 7.1 to demonstrate the case pairs used ##### in the Knox test. set.seed(1) x = runif(5,0,1) y = runif(5,0,1) t = runif(5,0,1) install.packages("scatterplot3d") library("scatterplot3d") postscript("fig71.ps",width=4,height=4) scatterplot3d(x,y,t,type="p",pch=16,xlim=c(0,1),ylim=c(0,1),zlim=c(0,1),box=F, label.tick.marks=T,mar=c(3,3,3,2),mgp=c(1,1,0)) graphics.off() n = length(x) d1 = matrix(0,n,n) d2 = matrix(0,n,n) for(i in 1:(n-1)){ for(j in (i+1):n){ d1[i,j] = sqrt((x[i]-x[j])^2+(y[i]-y[j])^2) d2[i,j] = abs(t[i]-t[j]) } } install.packages("surveillance") library("surveillance") knoxtest=knox(ds=d1[d1>0],dt=d2[d2>0],eps.s=0.5,eps.t=0.2,simulate.p.value=T,B=120) knoxtest