Description Usage Arguments Details Value Note Author(s) References Examples
View source: R/discrete_inhibit_sample.r
Draw a spatially discrete sample from a specified set of spatial locations within a polygonal sampling region according to an "inhibitory plus close pairs" specification.
1 2 3 |
obj |
a |
size |
a non-negative integer giving the total number of locations to be sampled. |
delta |
minimum permissible distance between any two locations in preliminary sample. This can be allowed to vary with number of |
delta.fix |
'logical' specifies whether |
k |
number of close-pair locations in the sample. Must be an integer between 0 and |
cp.criterion |
criterion for choosing close pairs k. The |
zeta |
maximum permissible distance (radius of a disk with center x^{*}_{j}, j = 1, …, k) within which a close-pair point is placed. See Details. |
ntries |
number of rejected proposals after which the algorithm terminates. |
poly |
'optional', a |
plotit |
'logical' specifying if graphical output is required. Default is |
To draw a sample of size n from a population of spatial locations X_{i} : i = 1,…,N, with the property that the distance between any two sampled locations is at least δ, the function implements the following algorithm.
Step 1. Draw an initial sample of size n completely at random and call this x_{i} : i = 1,…, n.
Step 2. Set i = 1.
Step 3. Calculate the smallest distance, d_{\min}, from x_{i} to all other x_{j} in the initial sample.
Step 4. If d_{\min} ≥ δ, increase i by 1 and return to step 2 if i ≤ n, otherwise stop.
Step 5. If d_{\min} < δ, draw an integer j at random from 1, 2,…,N, set x_{i} = X_{j} and return to step 3.
Samples generated in this way exhibit more regular spatial arrangements than would random samples of the same size. The degree of regularity achievable will be influenced by the spatial arrangement of the population X_{i} : i = 1,…,N, the specified value of δ and the sample size n. For any given population, if n and/or δ is too large, a sample of the required size with the distance between any two sampled locations at least δ will not be achievable; the algorithm will then find n_{s} < n points that can be placed for the given parameters.
Sampling close pairs of points.
For some purposes, typically when using the same sample for parameter estimation and spatial prediction, it is desirable that a spatial sampling scheme include pairs of closely spaced points x. The function offers two ways of specifying close pairs, either as the closest available unsampled point to an existing sampled point (cp.critetrion = cp.neighb)
, or as a random choice from amongst all available unsampled points within distance zeta of an existing sampled point (cp.criterion = cp.zeta)
.
The algorithm proceeds as follows.
Let k be the required number of close pairs.
Step 1. Construct a simple inhibitory design SI(n - k, δ).
Step 2. Sample k from x_{1}, …, x_{n - k} without replacement and call this set x_{j} : j = 1, …, k.
Step 3. For each x_{j}: j = 1, …, k, select a close pair x_{n-k+j} according to the specified criterion.
Note: Depending on the spatial configuration of potential sampling locations and, when the selection criterion cp.criterion = cp.zeta
, the specified value of zeta, it is possible that one or more of the selected points x_{j} in Step 2 will not have an eligible “close pair”. In this case, the algorithm will try find an alternative x_{j} and report a warning if it fails to do so.
a list with the following four components:
unique.locs:
the number of unique sampled locations.
delta:
the value of δ after taking into account the number of close pairs k. If delta.fix = TRUE
, this will be δ input by the user.
k: the number of close pairs included in the sample (for inhibitory plus close pairs design).
sample.locs:
a sf
or sp
object containing the final sampled locations and any associated values.
If 'delta'
is set to 0, a completely random sample is generated. In this case, 'close pairs' are not permitted and 'zeta'
becomes trivial.
Michael G. Chipeta mchipeta@mlw.mw
Peter J. Diggle p.diggle@lancaster.ac.uk
Chipeta M G, Terlouw D J, Phiri K S and Diggle P J. (2016). Inhibitory geostatistical designs for spatial prediction taking account of uncertain covariance structure, Enviromentrics, pp. 1-11.
Diggle P J. (2014). Statistical Analysis of Spatial and Spatio-Temporal Point Patterns. 3rd ed., Boca Raton: CRC Press
Diggle P J and Lophaven S. (2006). Bayesian geostatistical design, Scandinavian Journal of Statistics 33(1) pp. 53 - 64.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | library("sf")
set.seed(1234)
x <- 0.015+0.03*(1:33)
xall <- rep(x,33)
yall <- c(t(matrix(xall,33,33)))
xy <- cbind(xall,yall)+matrix(-0.0075+0.015*runif(33*33*2),33*33,2)
# Convert to SF object
xy <- xy %>%
as.data.frame %>%
sf::st_as_sf(coords = c(1,2))
# Plot the points
plot(st_geometry(xy),pch=19,cex=0.25,xlab="longitude",ylab="latitude",
cex.lab=1,cex.axis=1,cex.main=1, axes = TRUE)
# Generate spatially random sample
set.seed(15892)
xy.sample1 <- xy[sample(1:dim(xy)[1],50,replace=FALSE),]
plot(xy.sample1, pch = 19, col = 'black', add = TRUE)
set.seed(15892)
xy.sample2 <- discrete.inhibit.sample(obj=xy,size = 100,
delta = 0.08,plotit = TRUE)
plot(st_geometry(xy),pch=19, cex = 0.25, col="black", add = TRUE)
# Generate spatially inhibitory sample
# with close pairs (cp.zeta criterion):
set.seed(15892)
xy.sample3 <- discrete.inhibit.sample(obj=xy, size = 100,delta = 0.065,
k = 25,cp.criterion = "cp.zeta",
zeta = 0.025, plotit = TRUE)
plot(st_geometry(xy),pch=19, cex = 0.25, col="black", add = TRUE)
# Generate spatially inhibitory sample
# with close pairs (cp.neighb criterion):
set.seed(15892)
xy.sample4 <- discrete.inhibit.sample(obj=xy,size = 100,
delta = 0.065, k = 25,cp.criterion = "cp.neighb",
plotit = TRUE)
plot(st_geometry(xy),pch=19, cex = 0.25, col="black", add = TRUE)
# Generate spatially inhibitory sample
# with close pairs (cp.zeta criterion):
set.seed(15892)
xy.sample5 <- discrete.inhibit.sample(obj=xy,size = 100,
delta = 0.065, cp.criterion = "cp.zeta",
zeta = 0.025, delta.fix = TRUE,
k = 25, plotit = TRUE)
plot(st_geometry(xy),pch=19, cex = 0.25, col="black", add = TRUE)
# Generate simple inhibitory sample from a regular grid
library("PrevMap")
data("sim.data")
set.seed(15892)
xy.sample6 <- discrete.inhibit.sample(obj = sim.data,
size = 50, delta = 0.08,plotit = TRUE)
plot(st_geometry(sim.data),pch=19,col="black", cex = 0.25, add = TRUE)
# Generate inhibitory plus close pairs sample from a regular grid
set.seed(15892)
xy.sample7 <- discrete.inhibit.sample(obj = sim.data,
cp.criterion = "cp.neighb", size = 50,
delta = 0.1, k = 5, plotit =TRUE)
plot(st_geometry(sim.data),pch=19,col="black", cex = 0.25, add = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.