simHDS {AHMbook}R Documentation

Simulate data under hierarchical distance sampling protocol (line or point)


The function simulates hierarchical distance sampling (HDS) data under either a line or a point transect protocol. At each site, it works with a strip of width B*2 (for line transects) or a circle of radius B inscribed in a square of side B*2 (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 mean.lambda and beta.lam to calculate the expected number of animals, lambda, in each strip or square.

For line transects, the distance from the line is drawn from a Uniform(0, B) distribution. For point transects, the animals are distributed randomly over the square before calculating the distance of each from the point. Observations of animals further than B from the point are discarded.

A detection covariate, "wind", for each site is drawn from a Uniform(-2, 2) distribution. This is used in a log-linear regression with arguments mean.sigma and beta.sig to calculate the scale parameter, sigma, of the half-normal detection function. Detections are simulated as Bernoulli trials with probability of success decreasing with distance from the line or point.


simHDS(type=c("line", "point"), nsites = 100, mean.lambda = 2, beta.lam = 1,
  mean.sigma = 1, beta.sig = -0.5, B = 3, discard0 = TRUE, show.plot = TRUE)



type of transect, "line" or "point".


Number of sites (spatial replication)


the expected value of lambda when the habitat covariate = 0; the intercept of the log-linear regression for lambda is log(mean.lambda).


the slope of the log-linear regression for lambda on a habitat covariate.


the expected value of the scale parameter of the half-normal detection function when the wind speed = 0; the intercept of the log-linear regression for sigma is log(mean.sigma).


the slope of log-linear regression of scale parameter of the half-normal detection function on wind speed


the strip half-width or circle radius


If TRUE, subset to sites at which individuals were captured. You may or may not want to do this depending on how the model is formulated so be careful.


choose whether to show plots or not. Set to FALSE when using function in simulations.


A list with the values of the arguments entered and the following additional elements:


simulated distance sampling data: a matrix with a row for each individual detected and 5 columns: site ID, status (1 if captured), x and y coordinates (NA for line transects), distance from the line or point; if discard0 = FALSE, sites with no detections will appear in the matrix with NAs in columns 2 to 5.


simulated habitat covariate


simulated detection covariate


simulated number of individuals at each site


for point counts, the simulated number of individuals within the circle sampled


Marc Kéry & Andy Royle


Kéry, M. & Royle, J.A. (2016) Applied Hierarchical Modeling in Ecology AHM1 - 8.5.1.


# Simulate a data set with the default arguments and look at the structure of the output
tmp <- simHDS()

tmp <- simHDS("point", discard0=FALSE)
head(tmp$data, 10)

[Package AHMbook version 0.2.3 Index]