Fit time-to-detection occupancy models of Garrard et al. (2008, 2013). Time-to-detection can be modeled with either an exponential or Weibull distribution.
stan_occuTTD(
psiformula = ~1,
gammaformula = ~1,
epsilonformula = ~1,
detformula = ~1,
data,
ttdDist = c("exp", "weibull"),
linkPsi = c("logit"),
prior_intercept_state = logistic(0, 1),
prior_coef_state = logistic(0, 1),
prior_intercept_det = normal(0, 5),
prior_coef_det = normal(0, 2.5),
prior_intercept_shape = normal(0, 2.5),
prior_sigma = gamma(1, 1),
log_lik = TRUE,
...
)
Right-hand sided formula for the initial probability of occupancy at each site.
Right-hand sided formula for colonization probability. Currently ignored as dynamic models are not yet supported.
Right-hand sided formula for extinction probability. Currently ignored as dynamic models are not yet supported.
Right-hand sided formula for mean time-to-detection.
unmarkedFrameOccuTTD
object that supplies the data
(see unmarkedFrameOccuTTD
).
Distribution to use for time-to-detection; either
"exp"
for the exponential, or "weibull"
for the Weibull,
which adds an additional shape parameter \(k\).
Link function for the occupancy model. Only option is
"logit"
for now, in the future "cloglog"
will be supported for the complimentary log-log link.
Prior distribution for the intercept of the
state (occupancy probability) model; see ?priors
for options
Prior distribution for the regression coefficients of the state model
Prior distribution for the intercept of the time-to-detection model
Prior distribution for the regression coefficients of the time-to-detection model
Prior distribution for the intercept of the shape parameter (i.e., log(shape)) for Weibull TTD models
Prior distribution on random effect standard deviations
If TRUE
, Stan will save pointwise log-likelihood values
in the output. This can greatly increase the size of the model. If
FALSE
, the values are calculated post-hoc from the posteriors
Arguments passed to the stan
call, such as
number of chains chains
or iterations iter
ubmsFitOccuTTD
object describing the model fit.
Garrard, G.E., Bekessy, S.A., McCarthy, M.A. and Wintle, B.A. 2008. When have we looked hard enough? A novel method for setting minimum survey effort protocols for flora surveys. Austral Ecology 33: 986-998.
Garrard, G.E., McCarthy, M.A., Williams, N.S., Bekessy, S.A. and Wintle, B.A. 2013. A general model of detectability using species traits. Methods in Ecology and Evolution 4: 45-52.
Kery, Marc, and J. Andrew Royle. 2016. Applied Hierarchical Modeling in Ecology, Volume 1. Academic Press.
# \donttest{
#Simulate data
N <- 500; J <- 1
scovs <- data.frame(elev=c(scale(runif(N, 0,100))),
forest=runif(N,0,1),
wind=runif(N,0,1))
beta_psi <- c(-0.69, 0.71, -0.5)
psi <- plogis(cbind(1, scovs$elev, scovs$forest) %*% beta_psi)
z <- rbinom(N, 1, psi)
Tmax <- 10 #Same survey length for all observations
beta_lam <- c(-2, -0.2, 0.7)
rate <- exp(cbind(1, scovs$elev, scovs$wind) %*% beta_lam)
ttd <- rexp(N, rate)
ttd[z==0] <- Tmax #Censor at unoccupied sites
ttd[ttd>Tmax] <- Tmax #Censor when ttd was greater than survey length
#Build unmarkedFrame
umf <- unmarkedFrameOccuTTD(y=ttd, surveyLength=Tmax, siteCovs=scovs)
#Fit model
(fit <- stan_occuTTD(psiformula=~elev+forest, detformula=~elev+wind,
data=umf, chains=3, iter=300))
#>
#> SAMPLING FOR MODEL 'occuTTD' NOW (CHAIN 1).
#> Chain 1: Rejecting initial value:
#> Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
#> Chain 1: Stan can't start sampling from this initial value.
#> Chain 1:
#> Chain 1: Gradient evaluation took 0.000355 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 3.55 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1:
#> Chain 1:
#> Chain 1: Iteration: 1 / 300 [ 0%] (Warmup)
#> Chain 1: Iteration: 30 / 300 [ 10%] (Warmup)
#> Chain 1: Iteration: 60 / 300 [ 20%] (Warmup)
#> Chain 1: Iteration: 90 / 300 [ 30%] (Warmup)
#> Chain 1: Iteration: 120 / 300 [ 40%] (Warmup)
#> Chain 1: Iteration: 150 / 300 [ 50%] (Warmup)
#> Chain 1: Iteration: 151 / 300 [ 50%] (Sampling)
#> Chain 1: Iteration: 180 / 300 [ 60%] (Sampling)
#> Chain 1: Iteration: 210 / 300 [ 70%] (Sampling)
#> Chain 1: Iteration: 240 / 300 [ 80%] (Sampling)
#> Chain 1: Iteration: 270 / 300 [ 90%] (Sampling)
#> Chain 1: Iteration: 300 / 300 [100%] (Sampling)
#> Chain 1:
#> Chain 1: Elapsed Time: 0.989 seconds (Warm-up)
#> Chain 1: 1.142 seconds (Sampling)
#> Chain 1: 2.131 seconds (Total)
#> Chain 1:
#>
#> SAMPLING FOR MODEL 'occuTTD' NOW (CHAIN 2).
#> Chain 2:
#> Chain 2: Gradient evaluation took 0.000367 seconds
#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 3.67 seconds.
#> Chain 2: Adjust your expectations accordingly!
#> Chain 2:
#> Chain 2:
#> Chain 2: Iteration: 1 / 300 [ 0%] (Warmup)
#> Chain 2: Iteration: 30 / 300 [ 10%] (Warmup)
#> Chain 2: Iteration: 60 / 300 [ 20%] (Warmup)
#> Chain 2: Iteration: 90 / 300 [ 30%] (Warmup)
#> Chain 2: Iteration: 120 / 300 [ 40%] (Warmup)
#> Chain 2: Iteration: 150 / 300 [ 50%] (Warmup)
#> Chain 2: Iteration: 151 / 300 [ 50%] (Sampling)
#> Chain 2: Iteration: 180 / 300 [ 60%] (Sampling)
#> Chain 2: Iteration: 210 / 300 [ 70%] (Sampling)
#> Chain 2: Iteration: 240 / 300 [ 80%] (Sampling)
#> Chain 2: Iteration: 270 / 300 [ 90%] (Sampling)
#> Chain 2: Iteration: 300 / 300 [100%] (Sampling)
#> Chain 2:
#> Chain 2: Elapsed Time: 0.906 seconds (Warm-up)
#> Chain 2: 0.85 seconds (Sampling)
#> Chain 2: 1.756 seconds (Total)
#> Chain 2:
#>
#> SAMPLING FOR MODEL 'occuTTD' NOW (CHAIN 3).
#> Chain 3:
#> Chain 3: Gradient evaluation took 0.000385 seconds
#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 3.85 seconds.
#> Chain 3: Adjust your expectations accordingly!
#> Chain 3:
#> Chain 3:
#> Chain 3: Iteration: 1 / 300 [ 0%] (Warmup)
#> Chain 3: Iteration: 30 / 300 [ 10%] (Warmup)
#> Chain 3: Iteration: 60 / 300 [ 20%] (Warmup)
#> Chain 3: Iteration: 90 / 300 [ 30%] (Warmup)
#> Chain 3: Iteration: 120 / 300 [ 40%] (Warmup)
#> Chain 3: Iteration: 150 / 300 [ 50%] (Warmup)
#> Chain 3: Iteration: 151 / 300 [ 50%] (Sampling)
#> Chain 3: Iteration: 180 / 300 [ 60%] (Sampling)
#> Chain 3: Iteration: 210 / 300 [ 70%] (Sampling)
#> Chain 3: Iteration: 240 / 300 [ 80%] (Sampling)
#> Chain 3: Iteration: 270 / 300 [ 90%] (Sampling)
#> Chain 3: Iteration: 300 / 300 [100%] (Sampling)
#> Chain 3:
#> Chain 3: Elapsed Time: 0.84 seconds (Warm-up)
#> Chain 3: 0.688 seconds (Sampling)
#> Chain 3: 1.528 seconds (Total)
#> Chain 3:
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#tail-ess
#>
#> Call:
#> stan_occuTTD(psiformula = ~elev + forest, detformula = ~elev +
#> wind, data = umf, chains = 3, iter = 300)
#>
#> Occupancy (logit-scale):
#> Estimate SD 2.5% 97.5% n_eff Rhat
#> (Intercept) -0.599 0.237 -1.080 -0.1232 357 0.998
#> elev 0.441 0.148 0.157 0.7249 298 1.009
#> forest -0.660 0.389 -1.398 0.0899 395 0.998
#>
#> Detection (log-scale):
#> Estimate SD 2.5% 97.5% n_eff Rhat
#> (Intercept) -2.387 0.335 -3.036 -1.760 191 1.01
#> elev 0.126 0.194 -0.252 0.514 188 1.01
#> wind 1.259 0.424 0.425 2.109 206 1.01
#>
#> LOOIC: 1038.648
#> Runtime: 5.415 sec
# }