simHDSg {AHMbook} | R Documentation |
Simulate data under HDS protocol with groups
Description
Simulates hierarchical distance sampling (HDS) data for groups under either a line or a point transect protocol and using a half-normal detection function (Buckland et al. 2001).
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 as Bernoulli trials with probability of success decreasing with distance from the line or point.
Usage
simHDSg(type = c("line", "point"), nsites = 100, lambda.group = 0.75,
alpha0 = 0, alpha1 = 0.5,
beta0 = 1, beta1 = 0.5, B = 4, discard0 = TRUE, show.plot = TRUE)
Arguments
type |
The type of distance transect, either "line" or "point". |
nsites |
Number of sites (spatial replication) |
lambda.group |
Poisson mean of group size |
alpha0 |
intercept of log-linear model relating sigma of the half-normal detection function to group size |
alpha1 |
slope of log-linear model relating sigma of the half-normal detection function to group size |
beta0 |
intercept of log-linear model relating the Poisson mean of the number of groups per unit area to habitat |
beta1 |
slope of log-linear model relating the Poisson mean of the number of groups per unit area to habitat |
B |
strip half width or the radius of the circle |
discard0 |
whether to discard or keep the data from sites with nobody detected |
show.plot |
choose whether to show plots or not. Set to FALSE when using function in simulations. |
Value
A list with the values of the arguments entered and the following additional elements:
data |
simulated distance sampling data: a matrix with a row for each group detected and 6 columns: site ID, status (1 if captured), x and y coordinates (NA for line transects), distance from the line or point, group size; if |
habitat |
simulated habitat covariate |
N |
simulated number of groups at each site |
N.true |
for point counts, the simulated number of groups within the circle sampled |
groupsize |
group size for each of the groups observed |
Author(s)
Marc Kéry & Andy Royle
References
Buckland, S.T., et al (2001) Introduction to distance sampling: estimating abundance of biological populations. Oxford University Press, Oxford, UK.
Kéry, M. & Royle, J.A. (2016) Applied Hierarchical Modeling in Ecology AHM1 - 9.2.1.
Examples
# Run with the default arguments and look at the structure of the output:
set.seed(123)
tmp <- simHDSg()
str(tmp)
head(tmp$data)
str(simHDSg(type = "line")) # Defaults for line transect data
str(simHDSg(type = "point")) # Defaults for point transect data
str(simHDSg(lambda.group = 5)) # Much larger groups
str(simHDSg(lambda.group = 5, alpha1 = 0)) # No effect of groups size on p