Type: | Package |
Title: | Functions and Data for the Book 'Integrated Population Models' |
Version: | 0.1.5 |
Date: | 2023-08-21 |
Depends: | R (≥ 2.10) |
Imports: | stats, abind |
Description: | Provides functions and data sets to accompany the book 'Integrated Population Models: Theory and Ecological Applications with R and JAGS' by Michael Schaub and Marc Kéry (ISBN: 9780128205648). |
License: | GPL (≥ 3) |
URL: | https://www.vogelwarte.ch/de/projekte/publikationen/ipm/ |
BugReports: | https://github.com/kenkellner/IPMbook/issues |
NeedsCompilation: | no |
Encoding: | UTF-8 |
Language: | en-US |
Packaged: | 2023-08-21 13:48:37 UTC; ken |
Author: | Michael Schaub [aut], Marc Kéry [aut], Mike Meredith [aut], Ken Kellner [cre], Raphaël Arlettaz [dtc] (bats), Gabriel Banderet [dtc] (peregrine), François Biollaz [dtc] (bats), Radames Bionda [dtc] (grouse), Thomas Bregnballe [dtc] (cormorant), Hans Jakober [dtc] (redbacked), Ioannis Ntzoufras [ctb], Luca Rotelli [dtc] (grouse), Antoine Sierro [dtc] (bats), Wolfgang Stauber [dtc] (redbacked), Bruno Ullrich [dtc] (woodchat11), Fonds Sauvegarde Faune Flore Jurassienne - Groupe Pèlerin Jura [dtc] (peregrine), Idaho Department of Fish and Game [dtc] (elk), Louisiana Department of Wildlife and Fisheries [dtc] (bear), Monitoring Avian Productivity and Survivorship program (MAPS) [dtc] (catbird), North American Breeding Bird Survey (BBS) [dtc] (catbird), University Bern, Division of Conservation Biology [dtc] (hoopoe), Vogelwarte Hiddensee, Germany [dtc] (stork), Swiss Ornithological Institute [dtc] (hoopoe, kestrel, peregrine, swallow, wryneck) |
Maintainer: | Ken Kellner <contact@kenkellner.com> |
Repository: | CRAN |
Date/Publication: | 2023-08-21 18:30:12 UTC |
Functions and data for the book 'Integrated Population Models'
Description
Provides functions and data sets to accompany the book Integrated Population Models by Michael Schaub and Marc Kéry (ISBN: 9780128205648).
Details
The functions are listed by chapter below.
Chapter 2
demoMCMC
Demonstration of a random-walk sampler for MCMC (section 2.5)
Chapter 4
simMHB
Simulates detection and count data with spatial and temporal replication (section 4.3.3)
createAge
Creates an age matrix (section 4.5.1.1)
marray
Converts single- or multistate capture histories to an m-array for one age class (section 4.5.1.2)
marrayAge
Converts single-state capture histories to age-dependent m-arrays (section 4.5.1.2)
Chapter 5
simPop
Simulates a population based on demographic parameters (section 5.5.1)
simCapHist
Simulates capture histories from a population (section 5.5.1)
simProd
Simulates productivity data for a population (section 5.5.1)
simCount
Simulates population survey data for a population (section 5.5.1)
Chapter 12
marrayDead
Converts dead-recovery capture histories to an m-array (section 12.4.2)
DATA SETS
bats
Data for greater horseshoe bats from Switzerland, 1989-2017, chapter 13.
bear
Data for black bears from USA, 2007-2012, chapter 21.
catbird
Data for catbirds from USA, 1992-2008, chapter 19.
cormorant
Data for cormorants from Denmark, 1991-2004, chapter 18.
elk
Data for elk cows from USA, 1988-1993, chapter 17.
grouse
Data for black grouse from Italy, 1997-2016, chapter 15.
hoopoe
Data for hoopoe from Switzerland, 2001-2017, chapter 14.
kestrel
Data for kestrels from Switzerland, 2002-2016, chapter 20.
peregrine
Data for peregrine falcons from France and Switzerland, 1965-2007, chapter 12.
redbacked
Data for red-backed shrike from Germany, 1971-2006, section 8.2.
stork
Data for white storks from Germany, 1986-2001, section 4.5.4.
swallow
Data for barn swallow from Switzerland, 1997-2003, chapter 16.
woodchat5
Simulated data for woodchat shrike for use in chapter 5.
woodchat6
Simulated data for woodchat shrike for use in chapter 6.
woodchat64
Simulated data for woodchat shrike for use in section 6.4.
woodchat66
Simulated data for woodchat shrike for use in section 6.6.
woodchat7
Simulated data for woodchat shrike for use in chapter 7.
woodchat10
Simulated data for woodchat shrike for use in chapter 10.
woodchat11
Data for woodchat shrike from Germany, 1964-1992, chapter 11.
wryneck
Nest survival data for wryneck from Switzerland, 2002-2006, section 4.4.6.
UTILITY FUNCTIONS
ch2matrix
Convert capture histories in text format to a matrix.
cleanCH
Removes all-zero rows from a capture history matrix.
dbeta2
Beta distribution with mean and sd.
dbeta3
Beta distribution with mode and concentration.
dgamma2
Gamma distribution with mean and sd.
getFirst
Calculates the occasion of first capture from a capture history matrix.
rmFirst
Removes the records of first capture from a capture history matrix.
zInit
Converts a capture history matrix to one with 1 after the occasion of first capture, NA elsewhere.
zInitDR
Converts a dead-recovery capture history matrix to one with 1 after the occasion of first capture until the occasion of dead recovery, then 0; NA elsewhere.
zKnown
Converts a capture history matrix to one with 1 where the animal is know to be alive, NA elsewhere.
Author(s)
Michael Schaub, Marc Kéry, Mike Meredith
The beta distribution
Description
Density, distribution function, quantile function and random number generation for the beta distribution with parameters mean
and sd
OR mode
and concentration
. These are wrappers for stats::dbeta
, etc. getBeta*Par
returns the shape parameters.
Usage
dbeta2(x, mean, sd)
pbeta2(q, mean, sd, lower.tail=TRUE, log.p=FALSE)
qbeta2(p, mean, sd, lower.tail=TRUE, log.p=FALSE)
rbeta2(n, mean, sd)
getBeta2Par(mean, sd)
dbeta3(x, mode, concentration)
pbeta3(q, mode, concentration, lower.tail=TRUE, log.p=FALSE)
qbeta3(p, mode, concentration, lower.tail=TRUE, log.p=FALSE)
rbeta3(n, mode, concentration)
getBeta3Par(mode, concentration)
Arguments
x |
vector of parameter values. |
q |
vector of quantiles. |
p |
vector of probabilities. |
n |
number of random draws required. |
mean |
mean of the beta distribution; cannot be 0 or 1. |
sd |
standard deviation of the beta distribution; this must be less than |
mode |
mode of the beta distribution; may be 0 or 1. |
concentration |
concentration of the beta distribution; concentration = 2 is uniform, and the distribution becomes narrower as concentration increases. It is sometimes referred to as 'sample size', but best thought of as sample size + 2. |
lower.tail |
logical; if TRUE (default), cumulative probabilities up to x, otherwise, above x. |
log.p |
logical; if TRUE, probabilities p are given as log(p). |
Value
dbeta*
gives the density, pbeta*
gives the distribution function, qbeta*
gives the quantile function, and rbeta*
generates random deviates.
getBeta*Par
returns a 2-column matrix with the shape parameters corresponding to mean
and sd
OR mode
and concentration
.
Author(s)
Mike Meredith
See Also
See the stats functions dbeta
, pbeta
, qbeta
, rbeta
.
Examples
# Plot some curves with dbeta2
xx <- seq(0, 1, length.out=101)
plot(xx, dbeta2(xx, 0.4, 0.12), xlab="x", ylab="Probability density",
main="Beta curves with mean = 0.4", type='l', lwd=2)
lines(xx, dbeta2(xx, 0.4, 0.24), col='darkgreen', lwd=2)
lines(xx, dbeta2(xx, 0.4, 0.28), col='red', lwd=2)
lines(xx, dbeta2(xx, 0.4, 0.36), col='blue', lwd=2)
abline(v=0.4, lty=3, lwd=2)
legend('topright', paste("sd =", c(0.12,0.24, 0.28, 0.36)), lwd=2,
col=c('black', 'darkgreen', 'red', 'blue'), bty='n')
# Get shape and rate parameters for mean = 0.4 and sd = c(0.12,0.24, 0.28, 0.36, 0.49)
# The last value for sd is too big and will produce NAs and a warning
getBeta2Par(mean = 0.4, sd = c(0.12,0.24, 0.28, 0.36, 0.49))
# The parameterisation with mean and sd doesn't seem intuitive,
# let's try mode and concentration.
# This does not allow 'bathtub' curves, which are bimodal.
plot(xx, dbeta3(xx, 0.4, 16), xlab="x", ylab="Probability density",
main="Beta curves with mode = 0.4", type='l', lwd=2)
lines(xx, dbeta3(xx, 0.4, 8), col='darkgreen', lwd=2)
lines(xx, dbeta3(xx, 0.4, 4), col='red', lwd=2)
lines(xx, dbeta3(xx, 0.4, 2), col='blue', lwd=2)
abline(v=0.4, lty=3, lwd=2)
legend('topright', , lwd=2, paste("concentration =", c(16, 8, 4, 2)),
col=c('black', 'darkgreen', 'red', 'blue'), bty='n')
# The mode can be at 0 or 1:
plot(xx, dbeta3(xx, 1, 16), xlab="x", ylab="Probability density",
main="Beta curves with mode = 1", type='l', lwd=2)
lines(xx, dbeta3(xx, 1, 8), col='darkgreen', lwd=2)
lines(xx, dbeta3(xx, 1, 4), col='red', lwd=2)
lines(xx, dbeta3(xx, 1, 2), col='blue', lwd=2)
legend('topleft', paste("concentration =", c(16, 8, 4, 2)), lwd=2,
col=c('black', 'darkgreen', 'red', 'blue'), bty='n')
# Cumulative plots with pbeta3
plot(xx, pbeta3(xx, 0.4, 16), xlab="x", ylab="Cumulative probability",
main="Beta curves with mode = 0.4", type='l', lwd=2)
lines(xx, pbeta3(xx, 0.4, 8), col='darkgreen', lwd=2)
lines(xx, pbeta3(xx, 0.4, 4), col='red', lwd=2)
lines(xx, pbeta3(xx, 0.4, 2), col='blue', lwd=2)
abline(v=0.4, lty=3, lwd=2)
legend('topleft', paste("concentration =", c(16, 8, 4, 2)), lwd=2,
col=c('black', 'darkgreen', 'red', 'blue'), bty='n')
# Generate random draws and plot a histogram
rnd <- rbeta3(1e5, 0.4, 8)
hist(rnd, freq=FALSE)
# Add the curve:
lines(xx, dbeta3(xx, 0.4, 8), col='darkgreen', lwd=2)
# Get shape and rate parameters for mode = 0.4 and concentration = c(2, 4, 8, 16)
getBeta3Par(mode = 0.4, concentration = c(2, 4, 8, 16))
Discrete uniform prior distribution
Description
dUnif
creates a vector or matrix to be used with the categorical distribution, dcat
, in JAGS to generate a discrete uniform prior.
Usage
dUnif(lower, upper)
Arguments
lower , upper |
Range of the discrete uniform prior. Either scalars, or vectors of the same length. Values are rounded to integers. |
Value
If the arguments are scalar, a vector of length equal to upper
, with the first lower - 1
elements filled with zeros and remainder holding a constant value such that the vector sums to 1.
Otherwise a matrix with each row constructed as above: the columns from lower
to upper
have a constant value, other columns hold zeros. See the examples.
Author(s)
Michael Schaub, Marc Kéry, Mike Meredith
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 5.4.4.
Examples
# Both arguments scalar, vector output
(p <- dUnif(lower = 4, upper = 8))
# 0.0 0.0 0.0 0.2 0.2 0.2 0.2 0.2
sum(p)
# Non-integer arguments are rounded
(p <- dUnif(lower = 3.8, upper = 8.2)) # same as above
# Vector arguments, matrix output
(p <- dUnif(lower = c(4, 2, 5), upper = c(8,11,6)))
# [1,] 0 0.0 0.0 0.2 0.2 0.2 0.2 0.2 0.0 0.0 0.0
# [2,] 0 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1
# [3,] 0 0.0 0.0 0.0 0.5 0.5 0.0 0.0 0.0 0.0 0.0
rowSums(p) # all 1
Quick and dirty specification of matrices
Description
Many of the arguments to functions in the IPMbook package are in the form of matrices, eg, age classes x time. Entering the full matrix is tedious and difficult to read. In many cases, the parameter will be time-invariant or several age classes will share the same values, when input can be abbreviated.
If all values are equal, a single value can be entered and all elements of the matrix will be set to this.
For a time-invariant parameter, a vector can be entered, and this will be plugged in to all columns of the matrix. The vector can be shorter than the number of age classes, when the last value will be replicated for the remaining classes.
If the parameter varies with time, a matrix must be entered, but it does not need a row for every age class. If the matrix has fewer rows than the number of age classes, the last row will be replicated for the remaining classes.
In most cases, the full matrix is included in the output of the function: check this to make sure the expansion has worked as expected.
The gamma distribution
Description
Density, distribution function, quantile function and random number generation for the gamma distribution with parameters mean
and sd
. These are wrappers for stats::dgamma
, etc. getGammaPar
returns the shape and rate parameters.
Usage
dgamma2(x, mean, sd)
pgamma2(q, mean, sd, lower.tail=TRUE, log.p=FALSE)
qgamma2(p, mean, sd, lower.tail=TRUE, log.p=FALSE)
rgamma2(n, mean, sd)
getGammaPar(mean, sd)
Arguments
x |
vector of parameter values. |
q |
vector of quantiles. |
p |
vector of probabilities. |
n |
number of random draws required. |
mean |
mean of the gamma distribution. |
sd |
standard deviation of the gamma distribution. |
lower.tail |
logical; if TRUE (default), cumulative probabilities up to x, otherwise, above x. |
log.p |
logical; if TRUE, probabilities p are given as log(p). |
Value
dgamma2
gives the density, pgamma2
gives the distribution function, qgamma2
gives the quantile function, and rgamma2
generates random deviates.
getGammaPar
returns a 2-column matrix with the shape and rate parameters corresponding to mean
and sd
.
Author(s)
Mike Meredith
See Also
See the stats functions dgamma
, pgamma
, qgamma
, rgamma
.
Examples
# Plot some curves with dgamma2
xx <- seq(0, 20, length.out=101)
plot(xx, dgamma2(xx, 5, 1), xlab="x", ylab="Probability density",
main="Gamma curves with mean = 5", type='l', lwd=2)
lines(xx, dgamma2(xx, 5, 2), col='darkgreen', lwd=2)
lines(xx, dgamma2(xx, 5, 4), col='red', lwd=2)
lines(xx, dgamma2(xx, 5, 8), col='blue', lwd=2)
abline(v=5, lty=3, lwd=2)
legend('topright', paste("sd =", c(1,2,4,8)), lwd=2,
col=c('black', 'darkgreen', 'red', 'blue'), bty='n')
# Cumulative plots with pgamma2
plot(xx, pgamma2(xx, 5, 1), xlab="x", ylab="Cumulative probability",
main="Gamma curves with mean = 5", type='l', lwd=2)
lines(xx, pgamma2(xx, 5, 2), col='darkgreen', lwd=2)
lines(xx, pgamma2(xx, 5, 4), col='red', lwd=2)
lines(xx, pgamma2(xx, 5, 8), col='blue', lwd=2)
abline(v=5, lty=3, lwd=2)
legend('bottomright', paste("sd =", c(1,2,4,8)), lwd=2,
col=c('black', 'darkgreen', 'red', 'blue'), bty='n')
# Generate random draws and plot a histogram
rnd <- rgamma2(1e5, 5, 2)
hist(rnd, freq=FALSE)
# Add the curve:
lines(xx, dgamma2(xx, 5, 2), col='darkgreen', lwd=2)
# Get shape and rate parameters for mean = 5 and sd = c(1,2,4,8)
getGammaPar(mean = 5, sd = c(1,2,4,8))
Various helper functions
Description
cleanCH
removes histories without any capture (ie, all-zero rows) from a capture-recapture matrix.
rmFirst
removes the first capture in each row of a capture history matrix, replacing it with zero.
zKnown
takes a capture history and returns a matching matrix with 1 where the individual is know to be alive (ie, between the first and last capture) and NA elsewhere.
zInit
takes a capture history and returns a matching matrix with 1 after the occasion of first capture and NA elsewhere.
zInitDR
takes a dead-recovery capture history and returns a matching matrix with 1 after the occasion of first capture until the recovery occasion and 0 subsequently; NA elsewhere.
getFirst
calculates the occasion of first capture in a capture history matrix.
Usage
cleanCH(ch)
zKnown(ch)
zInit(ch)
zInitDR(chDR)
rmFirst(x)
getFirst(x)
Arguments
ch |
an individuals x time matrix with capture histories. |
chDR |
an individuals x time matrix with dead recovery capture histories: 1 indicates initial capture or dead recovery, 0 otherwise. |
x |
an individuals x time matrix with capture histories, or a vector of capture/noncapture data, typically 1 row of a capture history. |
Value
cleanCH
, zKnown
, zInit
, zInitDR
and rmFirst
return the modified capture history matrix.
getFirst
returns the occasion of first capture, NA if no capture recorded for an individual.
Author(s)
Michael Schaub, Marc Kéry, Mike Meredith
Data for greater horseshoe bats from Switzerland, 1989-2017
Description
Data for greater horseshoe bats (Rhinolophus ferrumequinum) were collected from 1989 to 2017 from a nursery colony in a church in the Swiss Alps (Valais).
Bats were captured and marked resulting in capture-recapture data, but in some years no capture was performed. Every year the number of adults was counted when they leave the colony at dusk and the number of newborn was recorded in the colony.
Usage
data(bats)
Format
bats
is a list with 7 components:
- ch
matrix of capture histories for 574 bats x 29 years.
- age
the age of each bat at first capture, 1 = juvenile, 2 = 1-year old, 3 = at least 2 years old.
- sex
sex of bats captured, 1 = female, 2 = male.
- J.count
annual counts of newborn bats in the roost; in most years these were complete counts.
- Jm
number of newborn bats recorded as male (not all newborns captured were sexed).
- Jf
number of newborn bats recorded as female.
- A.count
annual number of adults counted when the bats leave the colony at dusk; exit counts were not done in 1991 and 2001.
Source
Raphaël Arlettaz, François Biollaz, Antoine Sierro
References
Schaub, M., Gimenez, O., Sierro, A., Arlettaz, R. (2007) Use of integrated modeling to enhance estimates of population dynamics obtained from limited data. Conservation Biology 21, 945-955.
Sierro, A., Lugon, A., Arlettaz, R. (2009) La colonie de grands rhinolophes Rhinolophus ferrumequinum de l'église St-Sylvie à Vex (Valais, Suisse): évolution sur deux décennies (1968-2006). Le Rhinolophe 18, 75-82.
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, chapter 13.
Examples
data(bats)
str(bats)
Data for black bears in Louisiana, USA, 2007-2012
Description
The data on the Louisiana black bear (Ursus americanus luteolus) were collected during six years (2007-2012) in the Upper Atchafalaya River Basin in South-central Louisiana, USA, using hair snares. Hair samples were collected during eight consecutive weeks in each year and a selection of samples were genotyped resulting in spatial capture-recapture (SCR) data. This data set includes SCR data for 2007, 2009 and 2011, plus simple occupancy data for 2008, 2010 and 2012. See Chandler and Clark (2014) for details.
Note that not all hair samples were successfully genotyped, and traps were not deployed at all 128 locations in every year, leading to NAs in the data.
Usage
data(bear)
Format
bear
is a list with 3 components:
- scr
an array with SCR data, individuals x traps x occasions x years.
- occ
an array with detection/nondetection data, locations x occasions x years.
- trap.coord
a 2-column matrix with the coordinates of the trap locations.
Source
Louisiana Department of Wildlife and Fisheries
References
Chandler, R. B., Clark, J. D. (2014) Spatially explicit integrated population models. Methods in Ecology and Evolution 5, 1351-1360.
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, chapter 21.
Examples
data(bear)
str(bear)
Data for gray catbird from New England/Mid-Atlantic region, USA, 1992-2008
Description
The data set includes sighting data from the North American Breeding Bird Survey (BBS) and mark-recapture data from the Monitoring Avian Productivity and Survivorship program (MAPS) for gray catbirds (Dumetella carolinensis) in the New England/Mid-Atlantic region, USA, for 1992-2008.
Usage
data(catbird)
Format
catbird
is a list with 9 components:
- y
matrix of capture-recapture data from MAPS data, 4276 birds x 17 years.
- r
residency for each bird, 1 if the bird was captured more than once at least 11 days apart in the same year; 0 otherwise.
- station
banding station identifier.
- count
number of individuals detected on each route in the BBS data.
- stratum
identifier of the stratum of the route.
- year
year of the count.
- observer
identifier of the observer making the count.
- firstyr
1 if the observer counted on the route for the first time, 0 otherwise.
- area
the area of each stratum.
Source
North American Breeding Bird Survey (BBS) and Monitoring Avian Productivity and Survivorship program (MAPS)
References
Ahrestani, F. S., Saracco, J. F., Sauer, J. R., Pardieck, K. L., Royle, J. A. (2017) An integrated population model for bird monitoring in North America. Ecological Applications 27, 916-924.
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, chapter 19.
Examples
data(catbird)
str(catbird)
Convert capture histories in text format to a matrix
Description
The function takes capture histories in any of the following formats and converts it to a matrix of integers with one column for each capture occasion and one row for each capture history.
Possible formats for ch
are:
1a. a proper CH matrix: numeric, > 1 column – returned unchanged.
1b. the same, as a data frame.
2a. a character vector with "100110", "001100", etc, consisting entirely of digits (no letters, spaces, or symbols).
2b. the same, as a factor.
2c. a numeric vector with 100110, 1100, etc (leading zeros dropped).
3a. a 1-column data frame with 2a, b or c.
3b. a 1-column matrix with 2a or 2c.
Usage
ch2matrix(ch)
Arguments
ch |
capture histories in a suitable format, see Description. |
Value
A matrix of integers with one column for each capture occasion and one row for each capture history.
Author(s)
Mike Meredith
Examples
# Create some example data
raw <- c("1000", "1000", "1100", "1100", "1100", "1110",
"0110", "0110", "0111", "0101", "0010", "0011", "0001")
ch1 <- ch2matrix(raw) # character vector
cbind(raw, ch1)
ch <- ch2matrix(factor(raw)) # factor
all(ch == ch1)
ch <- ch2matrix(as.numeric(raw)) # numeric
all(ch == ch1)
ch <- ch2matrix(matrix(raw, ncol=1)) # 1 column matrix
all(ch == ch1)
ch <- ch2matrix(data.frame(raw=raw)) # 1 column data frame
all(ch == ch1)
# Error messages:
try(ch2matrix(matrix(rep(raw, 2), ncol=2))) # 2 column matrix -> error
try(ch2matrix(data.frame(raw=raw, dummy=raw))) # 2 column data frame -> error
raw[2] <- "11000" # wrong length
try(ch2matrix(raw)) # error
ch2matrix(as.numeric(raw)) # this works, leading zeros not expected.
Data from three Danish cormorant breeding colonies, 1991-2004
Description
The data were collected during 14 years from 1991 to 2004 at the three Danish cormorant breeding colonies located in the southwestern Kattegat in the inner Danish waters: Vorsø (labelled V), Mågeøerne (M) and Stavns Fjord (S).
Counts: The number of occupied nests in each colony was counted each year in early May.
Resightings: In all colonies, a large number of nestlings were marked with a standard metal ring on one leg and an alphanumeric colored plastic ring on the other leg; in total 12,659 individuals were marked. Resightings of marked individuals at the breeding colonies by trained field workers from towers, hides or from the ground using a telescope were recorded. Resightings were restricted to breeding individuals. Some individuals appear for the first time in the data set as breeders, having been marked as nestlings prior to 1991.
Usage
data(cormorant)
Format
cormorant
is a list with 2 components:
- count
matrix of counts of active nests in 3 breeding colonies x 14 years.
- ms.ch
a multistate capture history matrix for 12,659 birds x 14 years. The state codes 1-3 index nestlings in colonies V, M and S, respectively, and the state codes 4-6 do the same for the breeders.
Source
Thomas Bregnballe
References
Borysiewicz, R. S., Morgan, B. J. T., Hénaux, V., Bregnballe, T., Lebreton, J. D., Gimenez, O. (2009) An integrated analysis of multisite recruitment, mark-recapture-recovery and multisite census data. Pages 579-591 in D. Thomson, E. Cooch and M. Conroy, editors. Modeling demographic processes in marked populations. Springer, New York.
McCrea, R. S., Morgan, B. J. T., Gimenez, O., Besbeas, P., Bregnballe, T., Hénaux, V., Lebreton, J. D. (2010) Multi-site integrated population modelling. JABES 15, 539-561.
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, chapter 18.
Examples
data(cormorant)
str(cormorant)
Creates an age matrix
Description
Creates an animals x intervals matrix which gives the age class for each individual at the beginning of each interval, based on the occasion of first capture and the age at first capture.
Usage
createAge(f, age, nyears, mAge=2)
Arguments
f |
a vector of first capture occasions. |
age |
a corresponding vector with the age at first capture of each animal. |
nyears |
the number of years of the study; the number of intervals is |
mAge |
the maximum age class; age is incremented by 1 each year up to |
Value
An individuals x intervals matrix with the age of each individual at the beginning of each interval. Cells prior to the first capture are filled with NAs.
Author(s)
Michael Schaub
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Adademic Press, section 4.5.1.1.
Examples
data(woodchat5)
f <- getFirst(woodchat5$ch)
# Remove animals first captured on the last occasion
last <- which(f==ncol(woodchat5$ch))
f <- f[-last]
age <- woodchat5$age[-last]
x <- createAge(f, age, 20, 2)
head(x)
x[115:120,]
tail(x)
Demonstration of a random-walk sampler for a single parameter
Description
Generates an MCMC chain for the probability of success on the logit scale, ltheta = logit(theta)
, for binomial data with y successes in N trials. The prior for ltheta
is a Normal distribution with mean mu.ltheta
and SD sd.ltheta
. Proposal values are drawn from a Normal distribution with mean = current value and SD = prop.sd.
Usage
demoMCMC(y = 20, N = 50, niter = 25000, mu.ltheta = 0, sd.ltheta = 100,
prop.sd = 1, init = 0, quiet = FALSE, show.plots = TRUE)
Arguments
y |
number of successes. |
N |
number of trials. |
niter |
the number of MCMC draws required. |
mu.ltheta |
the mean of the Normal prior distribution for logit(theta). |
sd.ltheta |
the SD of the Normal prior distribution for logit(theta). |
prop.sd |
the SD of the Normal distribution for the proposals. |
init |
initial value for logit(theta). |
quiet |
if TRUE, console output is suppressed. |
show.plots |
if FALSE, plotting is suppressed. |
Value
A list with the values of the input arguments and the following additional elements:
ltheta |
a vector with the MCMC draws. |
acc.prob |
the proportion of proposed values accepted. |
Author(s)
Adapted from code in Ntzoufras (2009), p. 48.
References
Ntzoufras, I. (2009) Bayesian Modeling Using WinBUGS, Wiley, Hoboken NJ.
Schaub, M., Kéry, M. (2022), Integrated Population Models, Academic Press, section 2.5.
Examples
require(graphics)
# Default settings
str(tmp <- demoMCMC(y = 20, N = 50, niter = 25000,
mu.ltheta = 0, sd.ltheta = 100, prop.sd = 1, init = 0))
# Show convergence
str(tmp <- demoMCMC(prop.sd = 0.1, init = 10))
# Show convergence: no convergence
str(tmp <- demoMCMC(prop.sd = 0.1, init = 100))
# Very, very small step size: very inefficient
str(tmp <- demoMCMC(prop.sd = 0.01))
# Very small step size: inefficient
str(tmp <- demoMCMC(prop.sd = 0.1))
# Default step size: pretty good for this case
str(tmp <- demoMCMC(prop.sd = 1))
# Larger than default step size: efficiency goes down again
str(tmp <- demoMCMC(prop.sd = 10))
# Muuuuch larger ..... brrrrr !
str(tmp <- demoMCMC(prop.sd = 100))
Data from an elk population in USA, 1988-1993
Description
All three data sets from an elk (Cervus canadensis) population are from Northern Idaho, 1988 to 1993, and include only females, i.e., the elk cows.
The age-at-harvest data summarize the number of elk cows harvested and reported in each year stratified by age. All animals reported are sexed and aged based on tooth inspection, discarding records of elk older than 18 years. Not all hunted animals are reported.
The reporting rate was assessed by a telephone survey of registered hunters, recording in each year the number who said they had killed an elk cow and the number of hunters interviewed.
Some elk cows were radio-tracked each year, and for these we have data for survival, hunting mortality and other mortality.
Usage
data(elk)
Format
elk
is a list with 3 matrices:
- C
age-at-harvest data from cow elk, 17 age classes x 6 years.
- H
hunter survey results, 2 rows x 6 years.
- R
data for radio-tagged elk, 3 categories x 6 years.
Source
Idaho Department of Fish and Game, see Gove et al. (2002)
References
Gove, N. E., Skalski, J. R., Zager, P., Townsend, R. L. (2002) Statistical models for population reconstruction using age-at-harvest data. Journal of Wildlife Management 66, 310-320.
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, chapter 17.
Examples
data(elk)
str(elk)
Data for black grouse from Italy, 1997-2016
Description
Data for black grouse (Lyrurus tetrix) from Alpe Devero in the Piemont region of the Alps in Northern Italy from 1997 to 2016.
The number of displaying cocks was recorded each spring. In late summer, grouse were looked for with the help of pointer dogs and counted. Some grouse were equipped with a radio transmitter and the status of these birds (alive, dead) was regularly recorded.
Usage
data(grouse)
Format
grouse
is a list with 10 components:
- ch
matrix of capture histories for 96 radio-tagged birds x 128 months: 1 if found alive, 0 if found dead, otherwise NA.
- age
the actual age of each bird: 1 = juvenile, 2 = adult.
- sex
the sex of each bird: 1 = female, 2 = male.
- season
the season of the survey: 1 = spring, 2 = summer, 3 = autumn, 4 = winter.
- count.sp
annual count of displaying males at leks in spring.
- count.lsM
annual count of flushed adult males in late summer.
- count.lsF
annual count of flushed adult females in late summer.
- count.lsC
annual count of flushed chicks in late summer.
- v
annual total number of chicks in families where chicks could be sexed.
- u
annual number of female chicks in families where chicks could be sexed.
Source
Luca Rotelli, Radames Bionda
References
Rotelli, L., Zbinden, N., Bionda, R., Schaub, M. (in prep.) Chick survival and hunting are important drivers for the dynamics of two Alpine black grouse (Lylurus tetrix) populations. Wildlife Biology.
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, chapter 15.
Examples
data(grouse)
str(grouse)
Data for hoopoe from Switzerland, 2002-2017
Description
The data for the hoopoe (Upupa epops) were collected from 2002 to 2017 in the Swiss Alps (Valais). The nestboxes were checked regularly to record the number of broods and to determine breeding success. Nestlings were ringed and breeding adults captured.
Usage
data(hoopoe)
Format
hoopoe
is a list with 5 components:
- ch
matrix of capture histories for 3,844 female birds x 16 years.
- age
the age of each female at first capture, 1 = nestling, 2 = at least 1-year old.
- count
the annual population index (number of breeding pairs recorded).
- reproAgg
a data frame with annual totals of mothers for which fledglings were recorded (B1 = 1-year-old, B2 = older females) and the corresponding number of fledglings (J1 and J2, respectively).
- reproInd
a data frame with details of reproduction of individual females: id = mother's ID, f = total annual number of fledglings raised by each mother, including any replacement and second broods, year = year of the record.
Source
Swiss Ornithological Institute and Institute of Ecology and Evolution (Division of Conservation Biology), University of Bern.
References
Arlettaz, R., M. Schaub, J. Fournier, T. S. Reichlin, A. Sierro, J. E. M. Watson, V. Braunisch (2010) From Publications to Public Actions: When Conservation Biologists Bridge the Gap between Research and Implementation. BioScience 60, 835-842.
Plard, F., R. Arlettaz, A. Jacot, M. Schaub (2020) Disentangling the spatial and temporal causes of decline in a bird population. Ecology and Evolution 10, 6909-6918.
Schaub, M., T. S. Reichlin, F. Abadi, M. Kéry, L. Jenni, R. Arlettaz (2012) The demographic drivers of local population dynamics in two rare migratory birds. Oecologia 168, 97-108.
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, chapter 14.
Examples
data(hoopoe)
str(hoopoe)
Data for kestrels from Switzerland, 2002-2016
Description
The data sets for kestrels (Falco tinnunculus) were collected between 2002 and 2016 in the north-western quadrant of Switzerland.
They comprise breeding bird counts from a monitoring program and from the breeding bird atlas, and dead-recoveries of ringed individuals.
Usage
data(kestrel)
Format
kestrel
is a list with 4 components:
- landData
landscape data, a data frame with rows for 15,734 quadrats (1 x 1km) in the study area and the following columns:
x and y : the coordinates of the center of the quadrat.
elevation : mean elevation of the quadrat (m).
lakes : proportion of the quadrat covered by water.
- mhbData
data from Swiss Breeding Bird Monitoring (MHB, Schmid et al., 2004) for 120 quadrats in the study area, a list with the following components:
x and y : the coordinates of the center of the quadrat.
tcount : a quadrats x years matrix, the annual total count of kestrels.
- atlasData
data from the Swiss atlas survey (Knaus et al., 2018) for 574 atlas quadrats in the study area, a list with the following components:
x and y : the coordinates of the center of the quadrat.
year : the year of the survey, 2013-2015.
count : a quadrats x surveys matrix, the count of kestrels in the quadrat for up to 3 surveys; quadrats with only 2 surveys have NA in the third column.
- drData
dead-recovery data from a total of 24,561 kestrels ringed at a nest-box in one of 7 ringing areas in the study area (Fay et al., 2019), a list with the following components:
site : a matrix with 24,561 rows and columns for site ID and mean x and y coordinates of the nest-boxes at the site.
deadrecovery : an individual x year (2002-2016) matrix with 1 for the occasions of initial capture and dead recovery, 0 otherwise.
age : a length 24,561 vector with the age ("juv" or "ad") of ringing.
Source
Swiss Ornithological Institute
References
Fay, R., Michler, S., Laesser, J., Schaub, M. (2019) Integrated population model reveals that kestrels breeding in nest boxes operate as a source population. Ecography 42, 2122-2131.
Knaus, P., Antoniazza, S., Wechsler, S., Guelat, J., Kéry, M., Strebel, N., Sattler, T. (2018) Schweizer Brutvogelatlas 2013-2016. Verbreitung und Bestandsentwicklung der Vögel in der Schweiz und im Fürstentum Liechtenstein, Sempach.
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press. chapter 20.
Schmid, H., Zbinden, N., Keller, V. (2004) Überwachung der Bestandsentwicklung häufiger Brutvögel in der Schweiz. Schweizerische Vogelwarte, Sempach.
Examples
data(kestrel)
str(kestrel)
Converts capture-histories to an m-array for one age class
Description
Creates an m-array for a single- or multistate capture-recapture data with one age class and optionally more than one group.
Usage
marray(ch, unobs = 0, freq = 1, groups = NULL)
Arguments
ch |
an individuals x time matrix with single- or multistate capture histories (0: not captured; 1...X: captured in the 1...X states). See Details. |
unobs |
number of unobserved states (default is 0, needs to be given only in specific cases). |
freq |
a vector with the number of animals with each capture history, or a matrix with a column for each group. If a single value is supplied, it will be used for all rows in the capture history; the default is to assume each row corresponds to a single animal. |
groups |
a factor (or a vector that can be coerced to a factor) which identifies the group that each row of |
Details
The argument ch
can be a matrix of unique capture histories accompanied by a vector or matrix, freq
, specifying the number of animals with each capture history. Trap losses can be indicated either by negative values for freq
, or by filling the row with NA after the last capture. For other formats, see ch2matrix
.
Value
For single-state capture recapture data, an m-array which is a (years-1) x years x groups array, where element [i, j, g] contains the number of individuals in group g released in year i and recaptured in year j+1 (by definition no recaptures can occur in year 1). If no groups are specified, this will be a (years-1) x years matrix. The last column contains the number of individuals released in year i and never recaptured.
For multi-state capture-recapture data with s states (including potential unobservable states), an m-array which is a (years-1)*s x (years-1)*2 + 1 x groups array. An element [i, j, g] contains the number of individuals in group g released in year t and state n (i = (t-1)*s + n) and recaptured in year k+1 in state m (j = (k-1)*s + m). If no groups are specified, this will be a matrix. The last column contains the number of individuals released in year t and state s and never recaptured. The labeling of unobserved states starts with the number of observed states + 1.
Author(s)
Michael Schaub
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 4.5.1.2.
Examples
# Convert a single state capture history matrix into an m-array
data(woodchat5)
dim(woodchat5$ch) # 1902 animals x 20 years
ch1 <- cleanCH(woodchat5$ch[, 11:20]) # Use last 10 years only
marray(ch1)
# Convert a multistate capture history into an m-array
data(cormorant)
dim(cormorant$ms.ch) # 12,659 animals x 14 years
ch2 <- cleanCH(cormorant$ms.ch[, 11:14]) # Use last 4 years only
table(ch2) # 6 states
marray(ch2)
Creates age-dependent m-arrays
Description
Converts single-state capture-recapture data to age-dependent m-arrays.
Usage
marrayAge(ch, age = 1, mAge = 1, freq = 1, groups = NULL)
Arguments
ch |
an individuals x time matrix with capture histories (0: not captured; 1: captured). See Details. |
age |
vector with the age class at first capture for each individual, or a scalar that will be used for all individuals. |
mAge |
maximum number of age classes for which m-arrays are constructed; ignored if |
freq |
a vector with the number of animals with each capture history, or a matrix with a column for each group. If a single value is supplied, it will be used for all rows in the capture history; the default is to assume each row corresponds to a single animal. |
groups |
a factor (or a vector that can be coerced to a factor) which identifies the group that each row of |
Details
The argument ch
can be a matrix of unique capture histories accompanied by a vector or matrix, freq
, specifying the number of animals with each capture history. Trap losses can be indicated either by negative values for freq
, or by filling the row with NA after the last capture. For other formats, see ch2matrix
.
Value
A 4-d array, (years-1) x years x age classes x groups, where element [i, j, k, g] contains the number of individuals in group g of age class k released in year i and recaptured in year j+1 (by definition no recaptures can occur in year 1). If no groups are specified, this will be a 3-d array, (years-1) x years x age classes. The last column contains the number of individuals released in year i and never recaptured.
Author(s)
Michael Schaub
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 4.5.1.2.
Examples
data(woodchat5)
dim(woodchat5$ch) # 1902 animals x 20 years
marrayAge(ch=woodchat5$ch, age=woodchat5$age, mAge=2)
Converts dead-recovery capture histories to an m-array
Description
Converts dead-recovery capture histories to an m-array.
Usage
marrayDead(MR, freq = 1, groups = NULL)
Arguments
MR |
an individuals x time matrix with 1 denoting either the time of marking or the time of recovery; otherwise 0. |
freq |
a vector with the number of animals with each capture history, or a matrix with a column for each group. If a single value is supplied, it will be used for all rows in the capture history; the default is to assume each row corresponds to a single animal. |
groups |
a factor (or a vector that can be coerced to a factor) which identifies the group that each row of |
Details
The argument MR
can be a matrix of unique capture histories accompanied by a vector or matrix, freq
, specifying the number of animals with each capture history. For other formats, see ch2matrix
.
Value
An m-array, a (years-1) x years x groups array, where element [i, j, g] contains the number of individuals in group g marked in year i and recovered in year j+1. The last column contains the number of individuals marked in year i and never recovered. If no groups are specified, this will be a (years-1) x years matrix.
Author(s)
Michael Schaub
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, chapter 12.4.3.
Examples
data(peregrine)
str(peregrine$recoveries) # 1810 animals x 43 years
dr <- cleanCH(peregrine$recoveries[, 29:43]) # Use last 15 years of data
marrayDead(dr)
Data for peregrine falcons from the Jura Mountains, 1965-2007
Description
Data for peregrine falcons (Falco peregrinus) from the Jura Mountains straddling the Franco-Swiss border for 1965 to 2007. We combined data collected by Gaby Banderet and colleagues in Switzerland and René-Jean Monneret, René Ruffinoni and their colleagues in France.
Data comprise the annual number of breeding pairs, information on productivity and dead-recoveries of marked individuals.
Usage
data(peregrine)
Format
peregrine
is a list with 3 components:
- count
a 2-column matrix with the number of breeding pairs recorded in each year.
- productivity
a 3-column matrix with the number of broods surveyed and the total number of fledglings for each year.
- recoveries
an individuals x years matrix, with 1 when an individual was ringed as a nestling and when recovered dead; otherwise 0.
Source
Swiss data from Gabriel Banderet and the Swiss Ornithological Institute. French data from Fonds Sauvegarde Faune Flore Jurassienne - Groupe Pèlerin Jura.
References
Kéry, M., Banderet, G., Neuhaus, M., Weggler, M., Schmid, H., Sattler, T., Parish, D. (2018) Population trends of the Peregrine Falcon in Switzerland with special reference to the period 2005-2016. Ornis Hungarica 26, 91-103.
Monneret, R.-J., Rufinioni, R., Parish, D., Pinaud, D., Kéry, M. (2018) The Peregrine population study in the French Jura mountains 1964-2016: use of occupancy modeling to estimate population size and analyze site persistence and colonization rates. Ornis Hungarica 26, 69-90.
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, chapter 12.
Examples
data(peregrine)
str(peregrine)
Data for red-backed shrike from Germany, 1971-2006
Description
Data for the red-backed shrike (Lanius collurio) were collected from 1971 to 2006 from a study area in southern Germany. They comprise the annual number of breeding pairs, information about productivity from regular checks of nests, and capture-recapture data of juvenile and adult shrikes.
Usage
data(redbacked)
Format
redbacked
is a list with 5 components:
- marr.a
capture histories for females marked as adults in m-array format.
- marr.j
capture histories for females marked as fledglings in m-array format.
- B
the number of broods monitored each year.
- J
the number of fledglings produced each year by the monitored broods.
- count
the number of active breeding pairs on 15 June each year.
Source
Wolfgang Staube, Hans Jakober
References
Abadi, F., Gimenez, O., Jakober, H., Stauber, W., Arlettaz, R., Schaub, M. (2012) Estimating the strength of density dependence in the presence of observation errors using integrated population models. Ecological Modelling 242, 1-9.
Schaub, M., Jakober, H., Stauber, W. (2013) Strong contribution of immigration to local population regulation: evidence from a migratory passerine. Ecology 94, 1828-1838.
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 8.2.
Examples
data(redbacked)
str(redbacked)
Simulates capture histories from a population
Description
Simulates capture histories from a simulated population created by simPop
. Capture probabilities may vary among the age classes and with time, and can be different for initial capture vs recapture.
Usage
simCapHist(state, cap = c(0.35, 0.4), recap = NULL, maxAge = NULL, verbose = TRUE)
Arguments
state |
an animals x years matrix with the age of each animal in the population (animals born in the current year coded as age = 0), usually the output from |
cap |
matrix with age- and time-specific probabilities for initial capture; the first row refers to newborns/nestlings. Input can be abbreviated. |
recap |
matrix with age- and time-specific probabilities probabilities of REcapture: this has 1 less column than |
maxAge |
maximum number of age classes that can be identified when the individuals are captured for the first time; if NULL, no upper limit is imposed. |
verbose |
if TRUE, information is displayed in the console. |
Value
A list with the arguments used and the following 2 components:
ch |
matrix with the capture histories. |
age |
vector with the age class at first capture for each individual; note that animals marked as newborns/nestlings have age = 1, older individuals have ages from 2 to |
Author(s)
Michael Schaub
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 5.5.1.
Examples
# Generate a simulated population:
pop <- simPop()
# Simulate capture histories
ch <- simCapHist(pop$state)
str(ch)
ch$cap
ch$recap
ch$age
head(ch$ch)
# Time-varying recapture probabilities, same for all classes:
# use 1-row matrix
ch <- simCapHist(pop$state, recap=matrix(1:5/10, nrow=1))
ch$recap
Simulates count survey data
Description
Simulates count survey data assuming a binomial, normal, or Poisson sampling process. For the last two, it is assumed that individuals may be double counted and missed at the same rate.
Usage
simCountBin(N, pDetect)
simCountNorm(N, sigma)
simCountPois(N)
Arguments
N |
annual number of individuals at risk of detection, which may be all adults or just those breeding. The length of the vector determines the number of sampling occasions. |
pDetect |
vector with the annual detection probabilities of the individuals at risk of counting; all individuals have the same probability to be counted; a scalar can be used if probability does not change with time. |
sigma |
vector with the annual observation error (SD); a scalar can be used if error does not change with time. |
Value
A list with the parameters entered and count
with the number of individuals counted in each year.
Author(s)
Michael Schaub
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 5.5.1.
Examples
# Generate a simulated population:
pop <- simPop()
pop$breeders
# Simulate count data of breeders or of adults
simCountBin(pop$totBreeders, p=0.6)
simCountNorm(pop$totBreeders, sigma=10)
simCountPois(pop$totAdults)
Simulates detection and count data with spatial and temporal replication
Description
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.
Usage
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)
Arguments
nsites |
number of sites included in the survey. |
nsurveys |
number of replicate surveys at each site in each year. |
nyears |
number of years. |
mean.lam |
intercept of expected abundance. |
mean.beta |
average slope of log(lambda) on year. |
sd.lam |
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. |
mean.p |
value of constant detection probability per survey (or intercept of the logit-linear model for p). |
beta.p |
slope of the logit(p) in year. |
show.plot |
if TRUE, the output will be displayed graphically. |
Value
A list with the arguments used and the following components:
alpha |
vector with intercept used for the log-linear model for lambda for each site. |
beta |
vector with slope used for the log-linear model for lambda for each site. |
lam |
sites x years matrix with the expected number of animals at each site. |
N |
sites x years matrix with the realized number of animals at each site. |
totalN |
vector with the total number of animals in each year. |
p |
vector with the probability of detection in each year. |
C |
sites x surveys x years array with the counts of animals detected. |
Author(s)
Marc Kéry
References
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.
Examples
# 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,
show.plot=TRUE))
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)
Simulates a population based on demographic parameters
Description
The simulation tracks individual females from birth through a series of adult age classes to death, as well as numbers of female and male offspring. The function allows for 1 or more age classes. Once an animal reaches the oldest age class, age does not increase further until death.
The user specifies the number of females in each age class at the beginning of the simulation, before the first breeding season. Adult females can enter the population as immigrants; the age of immigrants is controlled by ageOfImm
.
Fecundity (the total number of offspring per adult female per year) can vary by age class and year in an age x year matrix. The sex ratio determines the proportion of females among the offspring.
In some age classes, not all animals may attempt to breed, and the probability of breeding can be specified.
Probability of survival can also vary by age class and year. The first row of the survival matrix specifies the survival of the animals born in each year and the remaining rows control survival for the respective older age classes.
Usage
simPop(Ni = c(10, 10), phi = c(0.3, 0.55), f = 3.2, nYears = 6, pBreed = 1,
sex.ratio = 0.5, Im = 0, ageOfIm = 1)
Arguments
Ni |
vector with number of females of each adult age class in the population prior to breeding in the first year. The length of this vector determines the number of age classes. The first age class refers to the individuals born the previous year. |
phi |
survival probabilities for new-borns and each age class for each interval between surveys: a (age classes + 1) x (years - 1) matrix. Input can be abbreviated. |
f |
fecundity rates, the number of offspring (male + female) per female in the population, for each adult age class and each year: an age classes x years matrix. Input can be abbreviated. |
nYears |
number of years the population is simulated. |
pBreed |
the probability that a female will attempt to breed for each adult age class and each year: an age classes x years matrix. Input can be abbreviated. |
sex.ratio |
sex ratio (probability that a new-born is a female) in each year: either scalar or a vector of length |
Im |
number of female immigrants in each year: either scalar or a vector of length |
ageOfIm |
the age class of immigrants in each year: either scalar or a vector of length |
Value
A list with the simulation settings and the following components:
state |
an individuals x years matrix, with the state of each individual in each year. States are coded: -1 = died, 0 = newborn, 1,2,... = 1-Year, 2-Year,... |
imYear |
a vector with the year of immigration for each individual, or NA if not an immigrant. |
reprod |
an individuals x years x 3 array with the number of female and male offspring and the age of the mother for each individual; NAs indicate individuals not alive or alive but not attempting to breeding. |
N |
a matrix with a column for each year and rows for numbers surviving in each age class, total adults, number of females born and total births, number of immigrants. (Immigrants are included in the age classes at the top of the table.) |
breeders |
a matrix with a column for each year and rows for numbers breeding in each age class and total breeders. Note that all animals attempting to breed are classified as breeders, even though no offspring may be produced. |
totAdults |
a vector with total adults in each year. |
totBreeders |
a vector with total breeders in each year. |
The last two are the same as the relevant rows in N
and breeders
, repeated for ease of extraction with $
.
Author(s)
Michael Schaub
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 5.5.1.
Examples
# Simulate a population with the default arguments:
str(pop <- simPop())
pop$N
# Try View, but not available on all platforms
# View(pop$state)
pop$phi
pop$f
pop$reprod[1:5,,]
# Just one (adult) age group:
str(pop <- simPop(Ni=20))
pop$N
pop$phi
pop$f
# Using matrices for time-dependent survival, fecundity
phi <- matrix(c(
0.3, 0.5, 0.5, 0.2, 0.2, # newborns
0.5, 0.7, 0.7, 0.4, 0.4), # adults
nrow=2, byrow=TRUE)
f <- matrix(c(3, 4, 5, 2, 2, 3), nrow=1)
str(pop <- simPop(phi=phi, f=f))
pop$phi
pop$f # Matrices expanded to all adult age classes
pop$N
# With immigration
str(pop <- simPop(Im=5))
pop$N
# with ageOfIm = 1 (default) immigrants are included in 1-Year figures.
# Not all 1-Years attempt to breed, and fecundity is lower
str(pop <- simPop(f = c(2, 3.2), pBreed = c(0.7, 1)))
pop$f
pop$pBreed
# Note the difference between numbers of breeders and adults among 1-Years
pop$breeders
pop$N
# Extinction
set.seed(1)
str(pop <- simPop(f = 0.1, phi = c(0.1, 0.2)))
pop$N
# Sink population, rescued by immigration
set.seed(1)
str(pop <- simPop(f = 0.1, phi = c(0.1, 0.2), Im=5))
pop$N
Simulates productivity data
Description
Simulates a survey of breeding females, where a proportion of the females are included each year and the number of their offspring (male and female) recorded.
Usage
simProd(reprod, pInclude = 0.3, females.only = FALSE, verbose = TRUE)
Arguments
reprod |
array with the reproductive performance of the population, usually the output from |
pInclude |
vector with the annual detection probabilities of broods; it can be scalar, used for all years. |
females.only |
if TRUE only the number of females that are produced is recorded. Default: total reproduction is recorded. |
verbose |
if TRUE, information is displayed in the console. |
Value
A list with the following 2 components:
prod.ind |
matrix with the individual reproductive output. The three columns give the output, the year of the brood and the actual age of the mother. |
prod.agg |
matrix with the same data, but aggregated. The two columns give the year-specific total number of newborn and the year-specific number of surveyed broods. |
Author(s)
Michael Schaub
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 5.5.1.
Examples
# Generate a population
pop <- simPop()
# Simulate productivity data
prod <- simProd(pop$reprod)
str(prod)
Data on marked white storks in Germany, 1986-2001
Description
Data for white stork (Ciconia ciconia) during 16 years (1986-2001) in eastern Germany. Chicks were ringed and adults resighted when they raised a brood in the study area. Nineteen ringed storks were recovered dead. The data set only includes birds resighted at least once as > 2 year olds.
Usage
data(stork)
Format
stork
is a matrix with rows for 691 marked birds and columns for the years 1986 to 2001. 1 indicates ringing or resighting, 2 a dead recovery, otherwise 0.
Source
Vogelwarte Hiddensee, Germany
References
Schaub, M., Kania, W., Köppen, U. (2005) Variation of primary production during winter induces synchrony in survival rates in migratory white storks Ciconia ciconia. Journal of Animal Ecology 74, 656-666.
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 4.5.4.
Examples
data(stork)
str(stork)
Calculates summary statistics from a subset of a population
Description
Calculates summary statistics from a subset of a population; used if a count survey is to be simulated with a subset of the complete population.
Usage
summaryPop(state, subset)
Arguments
state |
individuals x years matrix for the population with ages of adult individuals plus newborns (coded 0) and died (-1), usually the output from |
subset |
vector with the indices of the individuals that are to be included for the summary statistics; if missing, all individuals are included. |
Value
A matrix with the numbers in each adult age class for each year, total adults, and number of female juveniles.
Author(s)
Michael Schaub
Examples
pop <- simPop()
summaryPop(pop$state) # default is to include all, compare with
pop$N
# define a subset of 80 drawn at random
sset <- sample(nrow(pop$state), 80)
summaryPop(pop$state, subset=sset)
Data for barn swallows in Switzerland, 1997-2003
Description
Demographic data of barn swallows (Hirundo rustica) were collected from nine sites in Switzerland that were between 19 and 224 km apart from 1997 to 2003.
Each year the number of breeding pairs and detailed information about productivity from regular checks of the nests were recorded. Nestlings were ringed and adults captured, resulting in capture-recapture data. Not all sites were surveyed every year, resulting in NAs in the data.
Usage
data(swallow)
Format
swallow
is a list with 5 components:
- marr.j
an array with capture-recapture data for juvenile females in m-array format, sites x release year x recapture year.
- marr.a
an array with capture-recapture data for adult females in m-array format, sites x release year x recapture year.
- counts
a matrix with annual number of breeding pairs observed at each site, sites x years.
- productivity
an array with productivity variables for monitored broods, brood type (first or second) x sites x years x variable; the variables are total number of eggs and fledglings in monitored broods and the number of broods monitored.
- second
an array with the number of first broods and second broods observed, sites x years x brood type.
Source
Swiss Ornithological Institute
References
Schaub, M., von Hirschheydt, J., Grüebler, M.U. (2015) Differential contribution of demographic rate synchrony to population synchrony in barn swallows. Journal of Animal Ecology 84, 1530-1541.
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, chapter 16.
Examples
data(swallow)
str(swallow)
Simulated data for woodchat shrike for use in chapter 10
Description
Demographic parameters based on the woodchat shrike are introduced in Schaub & Kéry (2021) section 3.2 and details of the simulation are given in section 5.5. This data set has simulated data for use in chapter 10.
Usage
data(woodchat10)
Format
woodchat10
is a list with 4 components:
- marr.a
capture histories for females marked as adults in m-array format.
- marr.j
capture histories for females marked as fledglings in m-array format.
- B
number of broods monitored each year.
- J
number of fledglings produced by the monitored broods.
- count
number of breeding pairs recorded in each year.
Source
Simulated data
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 10.5.1.
Examples
data(woodchat10)
str(woodchat10)
Data for woodchat shrike from Germany, 1964-1992
Description
Real data for the woodchat shrike (Lanius senator) were collected from 1964 to 1992 from a study area in southern Germany.
They comprise the annual number of breeding pairs, information about productivity from regular checks of nests, and capture, ringing and resighting of juvenile and adult shrikes. In some years, no resighting data were collected.
Usage
data(woodchat11)
Format
woodchat11
is a list with 6 components:
- ch
capture histories for 1079 individuals (males and females) x 29 years.
- age
the age of each individual at first capture, 1 = nestling (juvenile), 2 = at least 1 year old (adult).
- count
the annual number of breeding pairs found in the study area.
- f
the number fledglings (male or female) produced by 365 broods monitored.
- d
d = 0 if
f
is an accurate count, d = 1 if it is a lower bound.- year
the year the brood was monitored.
Source
Bruno Ullrich
References
Ullrich, B. (2017) Entdeckung und Aussterben einer Population des Rotkopfwürgers Lanius senator in den Streuobstwiesen des Mittleren Albvorlandes, Landkreise Göppingen und Esslingen am Neckar. Ökologie der Vögel 35, 273-335.
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 11.4.
Schaub, M., B. Ullrich (2021) A drop in immigration results in the extinction of a local woodchat shrike population. Animal Conservation 24, accepted <https://doi.org/10.1111/acv.12639>
Examples
data(woodchat11)
str(woodchat11)
Simulated data for woodchat shrike for use in chapter 5
Description
Demographic parameters based on the woodchat shrike are introduced in Schaub & Kéry (2021) section 3.2 and details of the simulation are given in section 5.5. This data set has simulated data for use in chapter 5.
Usage
data(woodchat5)
Format
woodchat5
is a list with 4 components:
- ch
capture histories for 1902 females x 20 years.
- age
the age of each individual at first capture: 1 = juvenile, 2 = at least 1 year old (adult).
- repro
reproduction information for 929 monitored nests: Reproduction = total number of fledglings (male + female), Year = year monitored, Age of mother = 1 = 1 year old, 2 = at least 2 years old.
- count
total number of breeding pairs observed in each year.
Source
Simulated data
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, chapter 5.
Examples
data(woodchat5)
str(woodchat5)
Simulated data for woodchat shrike for use in section 6.3
Description
Demographic parameters based on the woodchat shrike are introduced in Schaub & Kéry (2021) section 3.2 and details of the simulation are given in section 5.5. This data set has simulated data for use in section 6.3.
Usage
data(woodchat6)
Format
woodchat6
is a list with 6 components:
- ch
capture histories for 947 females x 10 years.
- age
the age of each individual at first capture: 1 = juvenile, 2 = at least 1 year old (adult).
- count
number of breeding pairs recorded in each year.
- J
annual number of juveniles (fledglings) per year.
- B
annual number of broods surveyed from which the fledglings counts are obtained.
- f
number of fledglings per monitored nest.
Source
Simulated data
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 6.3.
Examples
data(woodchat6)
str(woodchat6)
Simulated data for woodchat shrike for use in section 6.4
Description
Demographic parameters based on the woodchat shrike are introduced in Schaub & Kéry (2021) section 3.2 and details of the simulation are given in section 5.5. This data set has simulated data for use in section 6.4.
Usage
data(woodchat64)
Format
woodchat64
is a list with 6 components:
- ch
capture histories for 947 females x 10 years.
- age
the age of each individual at first capture: 1 = juvenile, 2 = at least 1 year old (adult).
- count
number of breeding pairs recorded in each year.
- J
annual number of juveniles (fledglings) per year.
- B
annual number of broods surveyed from which the fledglings counts are obtained.
- trueN
true number of breeding pairs (known because it is a simulated data set).
Source
Simulated data
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 6.4.
Examples
data(woodchat64)
str(woodchat64)
Simulated data for woodchat shrike for use in section 6.6
Description
Demographic parameters based on the woodchat shrike are introduced in Schaub & Kéry (2021) section 3.2 and details of the simulation are given in section 5.5. This data set has simulated data for use in section 6.6.
Usage
data(woodchat66)
Format
woodchat66
is a list with 5 components:
- ch
capture histories for 947 females x 10 years.
- age
the age of each individual at first capture: 1 = juvenile, 2 = at least 1 year old (adult).
- count
number of breeding pairs recorded in each year.
- J
annual number of juveniles (fledglings) per year.
- B
annual number of broods surveyed from which the fledglings counts are obtained.
Source
Simulated data
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 6.6.2.
Examples
data(woodchat66)
str(woodchat66)
Simulated data for woodchat shrike for use in chapter 7
Description
Simulation of data with demographic parameters based on the woodchat shrike are introduced in section 3.2. This data set has additional simulated data for use in chapter 7. It is the same as woodchat5
but with approximately 5 times the number of observations.
Usage
data(woodchat7)
Format
woodchat7
is a list with 4 components:
- ch
capture histories for 9438 females x 20 years.
- age
the age of each individual at first capture: 1 = juvenile, 2 = at least 1 year old (adult).
- repro
reproduction information for 6207 monitored nests: Reproduction = total number of fledglings (male + female), Year = year monitored, Age of mother: 1 = 1 year old, 2 = at least 2 years old.
- count
total number of breeding pairs observed in each year.
Source
Simulated data
References
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 7.2.1.
Examples
data(woodchat7)
str(woodchat7)
Data from wrynecks in Switzerland, 2002-2006
Description
The data contain information about the survival of 181 broods of wrynecks (Jynx torquilla) collected in the Valais (Swiss Alps) from 2002-2006 in nestboxes. Dates are recorded such that day 1 is May 16.
Usage
data(wryneck)
Format
wryneck
is a data frame with 5 columns:
- f
day of first detection of nestlings.
- j
day of the latest check when nestlings were present.
- k
day of the last check; this is the same as 'j' if nestlings fledged successfully, or the day when the nest was found to have failed.
- x
1 if nestlings fledged successfully, otherwise 0.
- age
the age of the nestlings on first detection in number of days.
Source
Swiss Ornithological Institute
References
Geiser, S., R. Arlettaz, M. Schaub (2008) Impact of weather variation on feeding behaviour, nestling growth and brood survival in Wrynecks Jynx torquilla. Journal of Ornithology 149, 597-606.
Schaub, M., Kéry, M. (2022) Integrated Population Models, Academic Press, section 4.4.6.
Examples
data(wryneck)
str(wryneck)