This function fits the hierarchical distance sampling model of Royle et al. (2004) to line or point transect data recorded in discerete distance intervals.

stan_distsamp(
  formula,
  data,
  keyfun = c("halfnorm", "exp", "hazard"),
  output = c("density", "abund"),
  unitsOut = c("ha", "kmsq"),
  prior_intercept_state = normal(0, 5),
  prior_coef_state = normal(0, 2.5),
  prior_intercept_det = normal(0, 5),
  prior_coef_det = normal(0, 2.5),
  prior_intercept_scale = normal(0, 2.5),
  prior_sigma = gamma(1, 1),
  ...
)

Arguments

formula

Double right-hand side formula describing covariates of detection and occupancy in that order

data

A unmarkedFrameDS object

keyfun

One of the following detection functions: "halfnorm" for half-normal, "exp" for negative exponential, or "hazard" for hazard-rate (see warning below)

output

Model either density "density" or abundance "abund"

unitsOut

Units of density. Either "ha" or "kmsq" for hectares and square kilometers, respectively

prior_intercept_state

Prior distribution for the intercept of the state (abundance) model; see ?priors for options

prior_coef_state

Prior distribution for the regression coefficients of the state model

prior_intercept_det

Prior distribution for the intercept of the detection probability model

prior_coef_det

Prior distribution for the regression coefficients of the detection model

prior_intercept_scale

Prior distribution for the intercept of the scale parameter (i.e., log(scale)) for Hazard-rate models

prior_sigma

Prior distribution on random effect standard deviations

...

Arguments passed to the stan call, such as number of chains chains or iterations iter

Value

ubmsFitDistsamp object describing the model fit.

Note

Values of `dist.breaks` in the `unmarkedFrameDS` should be as small as possible (<10) to facilitate convergence. Consider converting `unitsIn` from meters to kilometers, for example. See example below.

Warning

Use of the hazard-rate key function ("hazard") typically requires a large sample size in order to get good parameter estimates. If you have a relatively small number of points/transects (<100), you should be cautious with the resulting models. Check your results against estimates from unmarked, which doesn't require as much data to get good estimates of the hazard-rate shape and scale parameters.

References

Royle, J. A., Dawson, D. K., & Bates, S. (2004). Modeling abundance effects in distance sampling. Ecology 85: 1591-1597.

Examples

# \donttest{
data(issj)
#Note use of km instead of m for distance breaks
jayUMF <- unmarkedFrameDS(y=as.matrix(issj[,1:3]),
                          siteCovs=issj[,c("elevation","forest")],
                          dist.breaks=c(0,0.1,0.2,0.3),
                          unitsIn="km", survey="point")

fm_jay <- stan_distsamp(~1~scale(elevation), jayUMF, chains=3, iter=300)
#> 
#> SAMPLING FOR MODEL 'distsamp' NOW (CHAIN 1).
#> Chain 1: 
#> Chain 1: Gradient evaluation took 0.009753 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 97.53 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: 1.551 seconds (Warm-up)
#> Chain 1:                1.205 seconds (Sampling)
#> Chain 1:                2.756 seconds (Total)
#> Chain 1: 
#> 
#> SAMPLING FOR MODEL 'distsamp' NOW (CHAIN 2).
#> Chain 2: 
#> Chain 2: Gradient evaluation took 0.000725 seconds
#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 7.25 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: 1.411 seconds (Warm-up)
#> Chain 2:                0.902 seconds (Sampling)
#> Chain 2:                2.313 seconds (Total)
#> Chain 2: 
#> 
#> SAMPLING FOR MODEL 'distsamp' NOW (CHAIN 3).
#> Chain 3: 
#> Chain 3: Gradient evaluation took 0.000739 seconds
#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 7.39 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: 1.354 seconds (Warm-up)
#> Chain 3:                0.882 seconds (Sampling)
#> Chain 3:                2.236 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
# }