# sample.geodata

##### Sampling from geodata objects

This functions facilitates extracting samples from geodata objects.

##### Usage

```
sample.geodata(x, size, replace = FALSE, prob = NULL, coef.logCox,
external)
```

##### Arguments

- x
an object of the class

`geodata`

.- size
non-negative integer giving the number of items to choose.

- replace
Should sampling be with replacement?

- prob
A vector of probability weights for obtaining the elements of the data points being sampled.

- coef.logCox
optional. A scalar with the coeficient for the log-Cox process. See DETAILS below.

- external
numeric values of a random field to be used in the log-Cox inhomogeneous poisson process.

##### Details

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:
$$exp(b Y(x))$$
with \(b\) given by the value passed to the argument
`coef.logCox`

and \(Y(x)\) taking values passed to
the argument `external`

or, if this is missing,
the element `data`

of the `geodata`

object.
Therefore, the latter generates a preferential sampling.

##### Value

a list which is an object of the class `geodata`

.

##### See Also

##### Examples

```
# 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)
# }
```

*Documentation reproduced from package geoR, version 1.8-1, License: GPL (>= 2)*