simMHB: Simulates detection and count data with spatial and temporal...

View source: R/simMHB.R

simMHBR Documentation

Simulates detection and count data with spatial and temporal replication


Function simulates MHB (Monitoring häufige Brutvögel) lookalike data. MHB is the Swiss breeding bird survey that is the source of many classic data sets (e.g. Kéry & Royle, 2016, 2021). This survey was launched in 1999 and for a total of 267 1km2 quadrats laid out in an approximate grid over Switzerland. 2 or 3 surveys are conducted in each breeding season (mid-April to early July) on a quadrat-specific, constant route averaging 4-6 km and all birds detected are mapped, thus yielding replicated counts of unmarked individuals.

The data are simulated under the assumptions of a binomial N-mixture model where for lambda we can specify a log-linear trend over the years and we can account for site-level random effects in both the intercept and the slopes of the log-linear model.

For detection probability we have currently a constant average or a logit-linear trend over the years, with no further heterogeneity.


simMHB(nsites = 267, nsurveys = 3, nyears = 25,
    mean.lam = 1, mean.beta = 0.03, sd.lam = c(0.5, 0.05),
    mean.p = 0.6, beta.p = 0.1,
    show.plot = TRUE)



number of sites included in the survey.


number of replicate surveys at each site in each year.


number of years.


intercept of expected abundance.


average slope of log(lambda) on year.


a length 2 vector, the SDs of the Normal distribution from which random site effects for the intercept and the slope in the log-linear model for lambda are drawn randomly.


value of constant detection probability per survey (or intercept of the logit-linear model for p).


slope of the logit(p) in year.


if TRUE, the output will be displayed graphically.


A list with the arguments used and the following components:


vector with intercept used for the log-linear model for lambda for each site.


vector with slope used for the log-linear model for lambda for each site.


sites x years matrix with the expected number of animals at each site.


sites x years matrix with the realized number of animals at each site.


vector with the total number of animals in each year.


vector with the probability of detection in each year.


sites x surveys x years array with the counts of animals detected.


Marc Kéry


Kéry, M., Royle, A. (2016) Applied Hierarchical Modeling in Ecology Vol 1, Academic Press.

Kéry, M., Royle, A. (2021) Applied Hierarchical Modeling in Ecology Vol 2, Academic Press.

Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 4.3.3.


# Explicit default values for all function arguments
str(dat <- simMHB(nsites=267, nsurveys=3, nyears=25, mean.lam=1,
    mean.beta=0.03, sd.lam=c(0.5, 0.05), mean.p=0.6, beta.p=0.1,
str(dat <- simMHB())                # Same, implicit
str(dat <- simMHB(nsites=1000))     # More sites
str(dat <- simMHB(nsurveys=10))     # More surveys
str(dat <- simMHB(nyears=50))       # More years
str(dat <- simMHB(mean.lam=5))      # Higher mean abundance
str(dat <- simMHB(mean.beta=-0.03)) # Population declines
str(dat <- simMHB(sd.lam=c(0, 0)))  # No site variability in lambda
str(dat <- simMHB(mean.p=1))        # Perfect detection
str(dat <- simMHB(mean.p=0.6, beta.p=0)) # Constant p = 0.6
str(dat <- simMHB(mean.p=0.6, beta.p=-0.2)) # Declining p
str(dat <- simMHB(show.plot=FALSE)) # No plots (when used in simulations)

IPMbook documentation built on Nov. 17, 2022, 9:05 a.m.