Learn R Programming

AHMbook (version 0.2.2)

simOcc: Simulate data for static occupancy models under wide range of conditions

Description

Function to simulate static occupancy measurements replicated at M sites during J occasions. Population closure is assumed for each site. Expected occurrence may be affected by elevation (elev), forest cover (forest) and their interaction. Expected detection probability may be affected by elevation, wind speed (wind) and their interaction.

Usage

simOcc(M = 267, J = 3, mean.occupancy = 0.6, beta1 = -2, beta2 = 2, beta3 = 1,
  mean.detection = 0.3, time.effects = c(-1, 1),
  alpha1 = -1, alpha2 = -3, alpha3 = 0, sd.lp = 0.5,
  b = 2, show.plot = TRUE)

Arguments

M

Number of spatial replicates (sites)

J

Number of temporal replicates (occasions)

mean.occupancy

Mean occurrence at value 0 of occurrence covariates

beta1

Main effect of elevation on occurrence

beta2

Main effect of forest cover on occurrence

beta3

Interaction effect on occurrence of elevation and forest cover

mean.detection

Mean detection prob. at value 0 of detection covariates

time.effects

bounds (on logit scale) for uniform distribution from which time effects gamma will be drawn

alpha1

Main effect of elevation on detection probability

alpha2

Main effect of wind speed on detection probability

alpha3

Interaction effect on detection of elevation and wind speed

sd.lp

standard deviation of random site effects (on logit scale)

b

constant value of 'behavioral response' leading to 'trap-happiness' (if b > 0) or 'trap shyness' (if b < 0)

show.plot

if TRUE, plots of the data will be displayed; set to FALSE if you are running simulations

Value

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

gamma

The time effects, a vector of length J

eps

Individual random effects, a vector of length M

elev

Elevation, a vector of length M

forest

Forest cover, a vector of length M

wind

wind speed, a M x J matrix

psi

Probability of occurrence, a vector of length M

z

Realized occurrence (0/1), a vector of length M

p

probability of capture, possibly with a behavioral effect, a M x J matrix

p0

probability of capture when not captured on previous occasion, a M x J matrix

p1

probability of capture when captured on previous occasion, a M x J matrix

y

simulated capture history, a M x J matrix

sumZ

True number of occupied sites

sumZ.obs

Number of sites observed to be occupied

psi.fs.true

True proportion of occupied sites in sample (sumZ/N)

psi.fs.obs

Proportion of sites observed to be occupied (sumZ.obs/N)

References

K<U+00E9>ry, M. & Royle, J.A. (2016) Applied Hierarchical Modeling in Ecology AHM1 - 10.8.

Examples

Run this code
# NOT RUN {
# Generate data with the default arguments and look at the structure
tmp <- simOcc()
str(tmp)

# Simplest possible occupancy model, with constant occupancy and detection
str(simOcc(mean.occ=0.6, beta1=0, beta2=0, beta3=0, mean.det=0.3, time.effects=c(0, 0),
  alpha1=0, alpha2=0, alpha3=0, sd.lp=0, b=0))
# psi = 1 (i.e., species occurs at every site)
str(simOcc(mean.occ=1))

# p = 1 (i.e., species is always detected when it occurs)
str(simOcc(mean.det=1))

# Other potentially interesting settings include these:
# }
# NOT RUN {
str(simOcc(J = 2))                 # Only 2 surveys
str(simOcc(M = 1, J = 100))        # No spatial replicates, but 100 measurements
str(simOcc(beta3 = 1))             # Including interaction elev-wind on p
str(simOcc(mean.occ = 0.96))       # A really common species
str(simOcc(mean.occ = 0.05))       # A really rare species
str(simOcc(mean.det = 0.96))       # A really easy species
str(simOcc(mean.det = 0.05))       # A really hard species
str(simOcc(mean.det = 0))          # The dreaded invisible species
str(simOcc(alpha1=-2, beta1=2))    # Opposing effects of elev on psi and p
str(simOcc(J = 10, time.effects = c(-5, 5))) # Huge time effects on p
str(simOcc(sd.lp = 10))            # Huge (random) site effects on p
str(simOcc(J = 10, b = 0))         # No behavioural response in p
str(simOcc(J = 10, b = 2))         # Trap happiness
str(simOcc(J = 10, b = -2))        # Trap shyness
# }

Run the code above in your browser using DataLab