This functions facilitates extracting samples from geodata objects.
sample.geodata(x, size, replace = FALSE, prob = NULL, coef.logCox,
external)
an object of the class geodata
.
non-negative integer giving the number of items to choose.
Should sampling be with replacement?
A vector of probability weights for obtaining the elements of the data points being sampled.
optional. A scalar with the coeficient for the log-Cox process. See DETAILS below.
numeric values of a random field to be used in the log-Cox inhomogeneous poisson process.
a list which is an object of the class geodata
.
If prob=NULL
and
the argument coef.logCox
, is provided,
sampling follows a log-Cox proccess, i.e.
the probability of each point being sampled is proportional to:
coef.logCox
and external
or, if this is missing,
the element data
of the geodata
object.
Therefore, the latter generates a preferential sampling.
# NOT RUN {
par(mfrow=c(1,2))
S1 <- grf(2500, grid="reg", cov.pars=c(1, .23))
image(S1, col=gray(seq(0.9,0.1,l=100)))
y1 <- sample.geodata(S1, 80)
points(y1$coords, pch=19)
## Now a preferential sampling
y2 <- sample.geodata(S1, 80, coef=1.3)
## which is equivalent topps
## y2 <- sample.geodata(S1, 80, prob=exp(1.3*S1$data))
points(y2$coords, pch=19, col=2)
## and now a clustered (but not preferential)
S2 <- grf(2500, grid="reg", cov.pars=c(1, .23))
y3 <- sample.geodata(S1, 80, prob=exp(1.3*S2$data))
## which is equivalent to
## points(y3$coords, pch=19, col=4)
image(S2, col=gray(seq(0.9,0.1,l=100)))
points(y3$coords, pch=19, col=4)
# }
Run the code above in your browser using DataLab