A general function for simulating hierarchical distance sampling (HDS) data combined with a time-removal (with 3 removal periods) or double-observer protocol, either for a line or a point transect protocol and with method = "removal" or method = "double". Also produces plots of the output.
At each site, it works with a strip of width B*2
(for line transects) or a circle of radius B
(for point transects).
The state process is simulated by first drawing a covariate value, "habitat", for each site from a Normal(0, 1) distribution. This is used in a log-linear regression with arguments beta0
and beta1
to calculate the expected number of groups in each strip or circle. Group size is simulated by first drawing from a Poisson distribution with parameter lambda.group
then adding 1.
For line transects, the distance from the line is drawn from a Uniform(0, B) distribution. For point transects, the distance from the point is simulated from B*sqrt(Uniform(0,1)), which ensures a uniform distribution over the circle.
The group size is used in a log-linear regression with arguments alpha0
and alpha1
to calculate the scale parameter, sigma, of the half-normal detection function. Detections are simulated according to the selected protocol.
To recreate the data sets used in the book with R 3.6.0 or later, include sample.kind="Rounding"
in the call to set.seed
. This should only be used for reproduction of old results.
simHDStr(type = c("line", "point"), method=c("removal", "double"), nsites = 200,
lambda.group = 1, alpha0 = 0, alpha1 = 0, beta0 = 1, beta1 = 0.5,
p.avail = 0.75, K = 3, p.double = c(0.4, 0.6),
B = 3, discard0 = FALSE, show.plot = TRUE)
A list with the values of the arguments and the following additional elements:
simulated distance sampling data: a matrix with a row for each group detected and 7 columns: site ID, status (1 if captured), x and y coordinates (NA for line transects), distance from the line or point, group size, the time interval of removal or capture history; if discard0 = FALSE
, sites with no detections will appear in the matrix with NAs in columns 2 to 7.
simulated habitat covariate
simulated number of groups at each site
for point counts, the simulated number of groups within the circle sampled
a vector with the input arguments
The type of distance transect, either "line" or "point".
Is the method time-removal ("removal") or double-observer ("double")?
Number of sites (spatial replication)
Poisson mean of group size
intercept of log-linear model relating sigma of half-normal detection function to group size
slope of log-linear model relating sigma of half-normal detection function to group size
intercept of log-linear model relating the Poisson mean of the number of groups per unit area to habitat
slope of log-linear model relating the Poisson mean of the number of groups per unit area to habitat
overall availability probability (phi in text)
number of removal periods (of equal length)
detection probability for first and second observer
strip half width or radius of the circle
whether to discard or keep the data from sites with nobody detected
choose whether to show plots or not. Set to FALSE when running simulations.
Marc Kéry & Andy Royle
Kéry, M. & Royle, J.A. (2016) Applied Hierarchical Modeling in Ecology AHM1 - 9.3.2 (time removal) and 9.4.1 (double observer).
# Run with the default arguments and look at the structure of the output:
set.seed(123)
tmp <- simHDStr() # default: line, removal
str(tmp)
head(tmp$data)
tmp <- simHDStr("point", method="double")
str(tmp)
head(tmp$data)
Run the code above in your browser using DataLab