| sim.popn {secr} | R Documentation |
Simulate a Poisson process representing the locations of individual animals.
sim.popn (D, core, buffer = 100, model2D = 'poisson', buffertype =
'rect', covariates = list(sex = c(M=0.5, F=0.5)), Ndist = 'poisson',
details = NULL, seed = NULL)
D |
density animals / hectare (10 000 m^2) |
core |
data frame of points defining the core area |
buffer |
buffer radius about core area |
model2D |
character string for 2-D distribution ('poisson', 'cluster', 'IHP') |
buffertype |
character string for buffer type |
covariates |
list of named covariates |
Ndist |
character string for distribution of number of individuals |
details |
optional list with additional parameters |
seed |
value for setting .Random.seed - either NULL or an integer |
core must contain columns 'x' and 'y'; a traps object is
suitable. For buffertype = 'rect', animals are simulated in the
rectangular area obtained by extending the bounding box of core
by buffer metres to top and bottom, left and right. This box has area A.
A notional covariate 'sex' is generated by default.
Each element of covariates defines a categorical (factor)
covariate with the given probabilities of membership in each class. No
mechanism is provided for generating continuous covariates, but these
may be added later (see Examples).
Ndist may be 'poisson' or 'fixed'. The number of individuals N has expected value DA. If DA is non-integer then Ndist = 'fixed' results in N in { trunc(DA), trunc(DA)+1 } , with probabilities set to yield DA individuals on average.
If model2D = 'cluster' then the simulated population approximates a Neyman-Scott
clustered Poisson distribution. Ancillary parameters are passed as
components of details: details$mu is the fixed number of
individuals per cluster and details$hsigma is the spatial scale
(sigma) of a 2-D kernel for location within each cluster.
The algorithm is
Toroidal wrapping is a compromise. The result is more faithful to the Neyman-Scott distribution if the buffer is large enough that only a small proportion of the points are wrapped.
If model2D = 'IHP' then an inhomogeneous Poisson distribution is fitted.
core should be a habitat mask and D should be a
vector of length equal to the number of cells (rows) in core. The
number of individuals in each cell is Poisson-distributed with mean DA where
A is the cell area (an attribute of the mask).
The random number seed is managed as in simulate.lm.
An object of class 'popn', a data frame with columns 'x' and 'y'. Rows correspond to individuals. Individual covariates (optional) are stored as a data frame attribute. The initial state of the R random number generator is stored in the 'seed' attribute.
Other buffertypes will be defined later. (e.g. convex hull, concave)
Murray Efford murray.efford@otago.ac.nz
temppop <- sim.popn (D = 10, expand.grid(x = c(0,100), y =
c(0,100)), buffer = 50)
## plot, distinguishing 'M' and 'F'
plot(temppop, pch = 1, cex= 1.5,
col = c('green','red')[covariates(temppop)$sex])
## add a continuous covariate
## assumes covariates(temppop) is non-null
covariates(temppop)$size <- rnorm (nrow(temppop), mean = 15, sd = 3)
summary(covariates(temppop))
## Neyman-Scott cluster distribution
oldpar <- par(xpd = TRUE, mfrow=c(2,3))
for (h in c(5,15))
for (m in c(1,4,16)) {
temppop <- sim.popn (D = 10, expand.grid(x = c(0,100),
y = c(0,100)), model2D = 'cluster', buffer = 100,
details = list(mu = m, hsigma = h))
plot(temppop)
text (50,230,paste(' mu =',m, 'hsigma =',h))
}
par(oldpar)
## Inhomogeneous Poisson distribution
data(secrdemo)
xy <- secrdemo.0$mask$x + secrdemo.0$mask$y - 900
tempD <- xy^2 / 1000
plot(sim.popn(tempD, secrdemo.0$mask, model2D = 'IHP'))