
Last chance! 50% off unlimited learning
Sale ends in
cover.design(R, nd, nruns = 1, nn = TRUE, num.nn = 100, fixed = NULL,
scale.type = "unscaled", R.center, R.scale, P = -20, Q = 20,
start = NULL, DIST = NULL, return.grid = TRUE, return.transform = TRUE)cover.design.S(...) # S version
cover.design.F(...) # FORTRAN version
user
.user
.OTHER DISTANCE FUNCTIONS: If the S version is used you can supply an S-function to be used as the distance metric. The expected calling sequence for this distance function is function( X1,X2){....} where X1 and X2 are matrices with coordinates as the rows. The returned value of this function should be the pairwise distance matrix. If nrow( X1)=m and nrow( X2)=n then the function should return an m by n matrix of all distances between these two sets of points. See the example for Manhattan distance below.
The candidate set and DIST function can be flexible and the last example below using sample correlation matrices is an example.
COVERAGE CRITERION: For nd design points in the set D and nc candidate points ci in the set C, the coverage criteria is defined as:
M(D,C) = [sum(ci in C) [sum(di in D) (dist(di,ci)**P]**(Q/P)]**(1/Q)
Where P, less than 0, and Q, greater than 0, are parameters. The algorithm used in "cover.design" to find the set of nd points in C that minimize this criterion is an iterative swapping algorithm which will be described briefly. The resulting design is referred to as a "coverage design" from among the class of space-filling designs. If fixed points are specified they are simply fixed in the design set and are not allowed to be swapped out.
ALGORITHM: An initial set of nd points is chosen randomly if no starting configuration is provided. The nc x nd distance matrix between the points in C and the points in D is computed, and raised to the power P. The "row sums" of this matrix are computed. Denote these as rs.i and the vector of row sums as rs. Using rs, M(D,C) is computed as:
[sum i (rs.i)**(Q/P)]**(1/Q)
Note that if point d.i is "swapped" for point c.j, one must only recompute 1 column of the original distance matrix, and 1 row. The row elements not in the ith column will be the same for all j and so only need computing when the first swapping occurs for each d.i . Denote the sum of these off-i elements as "newrow(i)". The index is i here since this is the same for all rows (j=1,...nc). Thus, for each swap, the row sums vector is updated as
rs(new) = rs(old) - column(i,old) + column(i,new)
And the jth element of rs(new) is replaced by:
rs(new)[j] = column(i,new)[k] + newrow(i)
Finally, M(D,C) is computed for this swap of the ith design point for the jth candidate point using [2]. The point in C that when swapped produces the minimum value of M(D,C) replaces d.i. This is done for all nd points in the design, and is iterated until M(D,C) does not change. When the nearest neighbor option is selected, then the points considered for swapping are limited to the num.nn nearest neighbors of the current design point.
STABILITY The algorithm described above is guaranteed to converge. However, upon convergence, the solution is sensitive to the initial configuration of points. Thus, it is recommended that multiple optimizations be done (i.e. set nruns greater than 1 ). Also, the quality of the solution depends on the density of the points on the region. At the same time, for large regions , optimization can be computationally prohibitive unless the nearest neighbor option is employed. Up to now, we have be run up to 20,000 candidate points, 400 design points, and 20 dimensions.
##
##
# first generate candidate set
set.seed(123) # setting seed so that you get the same thing I do!
test.df <- matrix( runif( 600), ncol=3)
test1.des<-cover.design(R=test.df,nd=10)
summary( test1.des)
plot( test1.des)
#
candidates<- make.surface.grid( list( seq( 0,5,,20), seq(0,5,,20)))
out<- cover.design( candidates, 15)
# find 10 more points keeping this original design fixed
out3<-cover.design( candidates, 10,fixed=out$best.id)
# see what happened
plot( candidates[,1:2], pch=".")
points( out$design, pch="x")
points( out3$design, pch="o")
# here is a strange graph illustrating the swapping history for the
# the first design. Arrows show the swapping
#at each pass through the design.
h<- out$history
cd<- candidates
plot( cd[,1:2], pch=".")
points( out$design, pch="O", col=2)
points( out$start.design, pch="x", col=5)
arrows(
cd[h[,2],1],
cd[h[,2],2],
cd[h[,3],1],
cd[h[,3],2],length=.1)
text( cd[h[,2],1],
cd[h[,2],2], h[,1], cex=1.0 )
#
# try this out using "Manhattan distance"
# ( distance following a grid of city streets)
dist.man<- function(x1,x2) {
d<- ncol( x1)
temp<- abs(outer( x1[,1], x2[,1],'-'))
for ( k in 2:d){
temp<- temp+abs(outer( x1[,k], x2[,k],'-'))
}
temp }
# use the design from the Euclidean distance as the starting
#configuration.
cover.design.S( candidates, 15, DIST=dist.man, start= out3$best.id)-> out2
# this takes a while ...
plot( out2$design)
points( out3$design, col=2)
# find a design on the sphere
#
candidates<- make.surface.grid( list( x=seq( -180,180,,20), y= seq( -85,
85,,20)))
out4<-cover.design.S( candidates, 15, DIST=rdist.earth)
# this takes a while
plot( candidates, pch=".")
points(out4$design, pch="o", col=3)
# covering based on correlation for 153 ozone stations
data( ozone2)
cor.mat<-cor( ozone2$y, use="pairwise")
cor.dist<- function( x1,x2)
{matrix( 1-cor.mat[ x1,x2], ncol=length(x2))}
# find 25 points oiut of the 153
out5<-cover.design.S(1:153,25, DIST= cor.dist, scale.type="unscaled")
plot( ozone2$lon.lat, pch=".")
points( ozone2$lon.lat[out5$best.id,],pch="O", col=4)
Run the code above in your browser using DataLab