run_sampler_geo: Aggregated and overdispersed sampling for geographic...

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Generate aggregated or overdispersed sampling designs for any given coordinates. Results can be used to design experiments/samples, for resample proposes and data bias removal.

Usage

1
2
run_sampler_geo(x, n, alpha, dist.func = rdist.earth, n_start = 1,
  return_start = FALSE, starting = NULL)

Arguments

x

matrix or data.frame indicating the coordinates (first column = longitude; second column = latitude). Row names should be given.

n

A positive integer number indicating the sample size.

alpha

Number indicating the strength of aggregation (if negative) or overdispersion (if positive). When alpha = 0 sample is random.

dist.func

A distance function to calculate coordinates distance. Default is rdist.earth from package fields.

n_start

Number of initial selected points. Default is one starting point.

return_start

if TRUE the starting point is returned.

starting

Character vector indicating the starting point (= to row names). If not provided, random starting value(s) is(are) selected.

Details

The function uses the algorithm in run_sampler, but here it accepts a two column matrix of coordinates as input.

Value

The function returns a vector indicating the selected rows. If return_start is TRUE, a list is returned with the first element being the Sampling_selection - selected sampling units - and Starting_points - selected starting point(s).

Author(s)

Bruno Vilela

See Also

run_sampler

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
require(sp)
require(maptools)
data(wrld_simpl)  # World map
Brazil <- wrld_simpl[wrld_simpl$NAME == "Brazil", ]  # Brazil (polygon)
coords <- slot(spsample(Brazil, 100, "regular"), "coords")
rownames(coords) <- paste0("t", 1:nrow(coords))
## Subsample 50%
### Overdispersed
selection.geo <- run_sampler_geo(x = coords, n = 10, alpha = 100, starting = "t10")
### Aggregated
selection.geo2 <- run_sampler_geo(x = coords, n = 10, alpha = -100, starting = "t10")
### Random
selection.geo3 <- run_sampler_geo(x = coords, n = 10, alpha = 0, starting = "t10")

## Plot
par(mfrow = c(1, 3), mar = c(1, 1, 15, 1))
plot(Brazil, main = "Overdispersed 50% sampling (red were selected)")
points(selection.geo, cex = 2, pch = 19, col = "red")
plot(Brazil, main = "Aggregated 50% sampling (blue were selected)")
points(selection.geo2, cex = 2, pch = 19, col = "blue")
plot(Brazil, main = "Random 50% sampling (green were selected)")
points(selection.geo3, cex = 2, pch = 19, col = "green")

BrunoVilela/sampler documentation built on May 20, 2019, 2:23 p.m.