Skip to main content

Single-species site occupancy on an eco table

The single-season occupancy model of MacKenzie et al. (2002), as Kéry and Royle present it in chapter 10 of Applied Hierarchical Modeling, fit with unmarked to the willow tit table in eco. A simulator at the top shows why repeated surveys are what separate occupancy from detection.

Published

November 20, 2026

A site either holds a species or it does not, and a survey either finds it or does not. Those are two different coin flips, and one survey per site cannot tell them apart: an undetected species and an absent species produce the same zero. The single-season occupancy model (MacKenzie et al. 2002; Kéry and Royle 2016, chapter 10) separates the two by surveying each site more than once within a window short enough that the true state cannot change. This page walks through that model on one eco table, from fetch to goodness of fit, with unmarked doing the fitting.

WarningHow these vignettes were made

These vignettes, including the choice of tables, the analysis design, the code and the writing, were produced largely by Claude (Anthropic), working from a task specification and reviewed by a psychometrician who is new to ecological modelling. Treat the methodological choices and interpretations accordingly, check the code on each page directly if you are relying on the numbers, and open an issue if something looks wrong.

Try it first

Sites are occupied with probability \(\psi\). Each of \(J\) surveys of an occupied site detects the species with probability \(p\); surveys of an empty site never do. Drag the sliders and watch the amber strips: those are occupied sites the surveys never found, which are the whole reason the model exists.

detected not detected strip outline: occupied, never detected
True occupancy (share of sites with z = 1)
Naive occupancy (share with any detection)
Expected naive occupancy, ψ[1 − (1 − p)J]
Cumulative detection, 1 − (1 − p)J
P(occupied | all J surveys zero)
Occupied sites never detected

Each strip is one site, its cells the J surveys in order. Hover a strip for its history. The conditional probability is ψ(1 − p)J / [ψ(1 − p)J + 1 − ψ].

Three things to notice. Naive occupancy converges on \(\psi[1-(1-p)^J]\), not on \(\psi\), and the gap closes only as \(J\) grows or \(p\) is high. The conditional probability that an all-zero site is occupied is what the model will later hand back for every undetected site, and it is small only when \((1-p)^J\) is small. And at \(J = 1\) the simulator admits that it cannot distinguish a common, cryptic species from a rare, conspicuous one.

The model

Site \(i\) carries a latent state \(z_i \in \{0, 1\}\),

\[ z_i \sim \text{Bernoulli}(\psi_i), \]

and survey \(j\) of site \(i\) returns a detection \(y_{ij}\) that is possible only when the site is occupied,

\[ y_{ij} \mid z_i \sim \text{Bernoulli}(z_i \, p_{ij}). \]

Covariates enter on the logit scale at the level where they vary: \(\text{logit}(\psi_i) = \mathbf{x}_i^\top \boldsymbol{\beta}\) for things fixed at a site, \(\text{logit}(p_{ij}) = \mathbf{w}_{ij}^\top \boldsymbol{\alpha}\) for things that change between surveys. Summing \(z_i\) out gives the marginal likelihood of one site’s detection history \(\mathbf{y}_i\), a zero-inflated product of Bernoullis:

\[ L(\psi, p \mid \mathbf{y}_i) \;=\; \psi_i \prod_{j} p_{ij}^{y_{ij}} (1 - p_{ij})^{1 - y_{ij}} \;+\; (1 - \psi_i)\, \mathbb{1}\!\left[\textstyle\sum_j y_{ij} = 0\right]. \]

A site with at least one detection contributes only the first term, so it is known to be occupied and its surveys inform \(p\) alone. An all-zero site contributes \(\psi_i (1-p_{i\cdot})^{J} + 1 - \psi_i\), the mixture of “occupied and missed every time” with “empty”. Replicate surveys are what make the two terms separable: among the detected sites, the pattern of ones and zeros across surveys estimates \(p\) with no reference to \(\psi\), and once \(p\) is pinned the share of all-zero sites that must be occupied follows. With \(J = 1\) there is no within-site pattern, the likelihood depends on \(\psi p\) only, and the model is unidentified.

The data

The table is kery_2008_willowtit_occ: the Swiss breeding bird survey’s willow tit data that ship with unmarked and that Kéry and Royle use for the MHB examples in chapters 10 and 11. There are 237 one-km² quadrats, each surveyed up to three times in one breeding season, with elevation, forest cover and transect length at the quadrat and the survey date and intensity at each visit. All covariates are standardised in the source file. Reads are pinned to eco version 10 so the numbers on this page do not move when the warehouse grows.

library(eco)
eco_set_version(10)
eco_info("kery_2008_willowtit_occ")
kery_2008_willowtit_occ
  Willow tit detection/non-detection, Swiss MHB, 237 quadrats x 3 surveys (unmarked widewt.csv)
  237 units x 1 taxa x 1 periods x 3 occasions; 665 rows; y in 0..1
  family:   Single-season occupancy
  response: detection (unit = site)
  protocol: line_transect; taxa: Birds; CHE
  floor:    meets; surveys rest on: deposited_matrix
  licence:  GPL-3.0-or-later (source shows: GPL-3)
  cite:     Fiske, I. & Chandler, R. (2011). unmarked: An R package for fitting hierarchical models of wildlife occurrence and abundance. Journal of Statistical Software 43(10), 1-23. https://doi.org/10.18637/jss.v043.i10. Data: Swiss breeding bird survey MHB (Schweizerische Vogelwarte), file csv/widewt.csv.
  columns:  unit, taxon, y, occasion, unit_elev, unit_forest, unit_length, obs_date_doy_std, obs_ivel_std
  script:   https://github.com/ben-domingue/eco/blob/main/data/kery_2008_willowtit_occ.R
d <- eco_fetch("kery_2008_willowtit_occ")
eco tables rest on other people's fieldwork: please cite the original deposits (eco_cite(tables)). Silence with options(eco.cite_reminder = FALSE).
d <- d[order(d$unit, d$occasion), ]
rownames(d) <- NULL
head(d)
  unit  taxon y occasion unit_elev unit_forest unit_length obs_date_doy_std
1    1 POEMON 0        1     -1.17      -1.156        1.82           -1.761
2    1 POEMON 0        2     -1.17      -1.156        1.82            0.310
3    1 POEMON 0        3     -1.17      -1.156        1.82            1.381
4    2 POEMON 0        1     -1.13      -0.501        1.63           -2.904
5    2 POEMON 0        2     -1.13      -0.501        1.63           -1.047
6    2 POEMON 0        3     -1.13      -0.501        1.63            0.596
  obs_ivel_std
1       -0.506
2       -0.506
3       -0.506
4       -0.934
5       -0.991
6       -1.162

One row per survey. The unit_ columns are constant within a site and will become unmarked’s site covariates; the obs_ columns vary by survey and become its observation covariates. occasion is the survey index within the single primary period, and the standard requires a row to exist exactly when a survey happened.

table(table(d$unit))

  1   2   3 
  2  42 193 
nrow(d)
[1] 665
237 * 3 - nrow(d)
[1] 46

Forty-six site-surveys were never made, so forty-two quadrats have two rows and two have one. They have no rows at all rather than rows with y = 0, because a survey that did not happen is not evidence of absence. This matters for the likelihood above: an all-zero history over two surveys contributes \(\psi (1-p)^2 + 1 - \psi\), while the same site padded to three zeros would contribute \(\psi (1-p)^3 + 1 - \psi\) and claim an extra miss that never occurred. When the long table is widened those cells must become NA, which unmarked treats as not surveyed. eco_to_unmarked() does exactly that.

umf <- eco_to_unmarked(d)
sum(is.na(getY(umf)))
[1] 46
head(siteCovs(umf))
    elev   forest length
1 -1.173 -1.15623   1.82
2 -1.127 -0.50148   1.63
3 -0.198 -0.10136   1.46
4 -0.105  0.00776   1.69
5 -1.034 -1.19260   1.28
6 -0.848  0.91713   1.81
head(obsCovs(umf))
  date_doy_std ivel_std
1       -1.761   -0.506
2        0.310   -0.506
3        1.381   -0.506
4       -2.904   -0.934
5       -1.047   -0.991
6        0.596   -1.162

The prefixes are gone because the frame already encodes the level: siteCovs() holds what was unit_*, obsCovs() holds what was obs_*, one row per site-by-survey cell in the frame’s order. Naive occupancy is the share of sites with at least one detection.

Y <- getY(umf)
naive <- mean(rowSums(Y, na.rm = TRUE) > 0)
naive
[1] 0.333

Fit

occu() takes a double right-hand-side formula: detection first, occupancy second. Three models: the null model; one that puts elevation and forest on \(\psi\) with a quadratic in elevation, since willow tits are a subalpine bird and should peak at mid elevation; and one that adds survey date and intensity on \(p\).

m0 <- occu(~ 1 ~ 1, umf)
m1 <- occu(~ 1 ~ elev + I(elev^2) + forest, umf)
m2 <- occu(~ date_doy_std + ivel_std ~ elev + I(elev^2) + forest, umf)
modSel(fitList(null = m0, psi_covs = m1, psi_and_p_covs = m2))
               nPars    AIC delta   AICwt cumltvWt
psi_covs           5 433.47  0.00 7.8e-01     0.78
psi_and_p_covs     7 435.96  2.50 2.2e-01     1.00
null               2 528.99 95.52 1.4e-21     1.00
summary(m2)

Call:
occu(formula = ~date_doy_std + ivel_std ~ elev + I(elev^2) + 
    forest, data = umf)

Occupancy (logit-scale):
            Estimate    SE      z  P(>|z|)
(Intercept)   -0.218 0.279 -0.782 4.34e-01
elev           1.994 0.311  6.412 1.44e-10
I(elev^2)     -1.092 0.274 -3.987 6.68e-05
forest         0.848 0.234  3.626 2.87e-04

Detection (logit-scale):
             Estimate    SE     z  P(>|z|)
(Intercept)    1.2451 0.192 6.495 8.29e-11
date_doy_std   0.0978 0.115 0.852 3.94e-01
ivel_std       0.1362 0.222 0.613 5.40e-01

AIC: 436 
Number of sites: 237

Occupancy rises steeply with elevation, turns over above the mean (the quadratic term is negative), and is higher in forested quadrats. Neither detection covariate earns its place: the AIC gain from m1 to m2 is below what two free parameters cost, and both coefficients sit well inside their standard errors. The null model’s constants are the ones the simulator’s sliders correspond to.

backTransform(m0, "state")
Backtransformed linear combination(s) of Occupancy estimate(s)

 Estimate     SE LinComb (Intercept)
     0.34 0.0313  -0.665           1

Transformation: logistic 
backTransform(m0, "det")
Backtransformed linear combination(s) of Detection estimate(s)

 Estimate     SE LinComb (Intercept)
     0.79 0.0289    1.32           1

Transformation: logistic 

Interpret

Naive against estimated. Under the null model \(\hat\psi\) = 0.34 against a naive 0.33, a correction of only 0.01. That is not a failure of the method. With \(\hat p\) = 0.79 per survey the cumulative detection over three visits is \(1 - (1 - \hat p)^3\) = 0.99, so the surveys very nearly census the occupied quadrats and there is little to correct. Set the simulator to \(p\) = 0.8 and \(J\) = 3 to see the same thing; then set \(p\) = 0.3 to see what this analysis would look like for a cryptic species.

Conditional occupancy of the undetected sites. For an all-zero site the model’s posterior that it is occupied is \(\psi(1-p)^J / [\psi(1-p)^J + 1 - \psi]\), which under the null model is 0.005 for a site with three surveys. Under m2 each site has its own \(\psi_i\) and \(p_{ij}\), and ranef() returns the site-level posterior of \(z_i\).

re  <- ranef(m2)
z_hat <- bup(re, stat = "mean")     # posterior mean of z_i
undetected <- rowSums(Y, na.rm = TRUE) == 0
summary(z_hat[undetected])
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
1.58e-05 3.92e-04 1.75e-03 8.45e-03 1.37e-02 8.25e-02 
sum(undetected)
[1] 158

Every detected site has \(z_i = 1\) with certainty. The undetected sites range from essentially zero to about 0.08, with the highest values at mid-elevation forested quadrats where \(\psi_i\) is high, and at the quadrats with only one or two surveys, where \((1-p)^J\) is larger.

sc <- siteCovs(umf)
df <- data.frame(elev = sc$elev, z_hat = z_hat,
                 n_surveys = factor(rowSums(!is.na(Y))),
                 detected = ifelse(undetected, "never detected", "detected"))
ggplot(subset(df, detected == "never detected"),
       aes(elev, z_hat, shape = n_surveys)) +
  geom_point(size = 2.4, colour = "#c08a1e") +
  scale_shape_manual(values = c("1" = 17, "2" = 15, "3" = 16), name = "surveys") +
  labs(x = "Elevation (standardised)", y = "P(occupied | all surveys zero)")
Figure 1: Posterior probability that an undetected quadrat is occupied, against its elevation. Shape marks how many surveys it received.

Finite-sample against model occupancy. Two different questions hide behind “how many quadrats are occupied”. The model parameter \(\psi\) is the probability a quadrat like these is occupied; the finite-sample quantity is how many of these 237 quadrats are. The second is the sum of the \(z_i\), estimated by summing the posterior means, and its uncertainty is smaller because the detected sites contribute no uncertainty at all.

c(naive_count = sum(!undetected),
  finite_sample = sum(z_hat),
  model_mean_psi_times_n = sum(predict(m2, "state")$Predicted))
           naive_count          finite_sample model_mean_psi_times_n 
                  79.0                   80.3                   80.3 
nd <- data.frame(elev = seq(min(sc$elev), max(sc$elev), length.out = 100),
                 forest = 0)
pr <- cbind(nd, predict(m2, "state", newdata = nd))
ggplot(pr, aes(elev, Predicted)) +
  geom_ribbon(aes(ymin = lower, ymax = upper), fill = "#1e8a5a", alpha = 0.15) +
  geom_line(colour = "#1e8a5a", linewidth = 1) +
  geom_rug(data = subset(df, detected == "detected"), aes(x = elev, y = NULL),
           sides = "t", colour = "#1e8a5a", alpha = 0.5) +
  geom_rug(data = subset(df, detected == "never detected"), aes(x = elev, y = NULL),
           sides = "b", colour = "#8a8c94", alpha = 0.5) +
  labs(x = "Elevation (standardised)", y = expression(hat(psi)))
Figure 2: Predicted occupancy against elevation at mean forest cover, with the 95% confidence band. Ticks along the top are quadrats with a detection; along the bottom, quadrats without.

Check

The MacKenzie and Bailey (2004) test compares the observed count of each detection history (000, 001, …, 111, with the two- and one-survey cohorts separately) against what the fitted model expects, and bootstraps the Pearson statistic from the model to get its reference distribution. AICcmodavg::mb.gof.test() does it on an unmarked fit.

set.seed(2026)
gof <- mb.gof.test(m2, nsim = 200)

gof

MacKenzie and Bailey goodness-of-fit for single-season occupancy model

Pearson chi-square table:

    Cohort Observed Expected Chi-square
000      0      124   127.73       0.11
001      0        3     2.76       0.02
010      0        3     2.46       0.12
011      0        4     9.87       3.49
100      0        7     2.15      10.97
101      0        4     8.63       2.49
110      0        5     7.71       0.95
111      0       43    31.70       4.03
00.      1       32    28.39       0.46
01.      1        2     2.20       0.02
10.      1        4     1.97       2.08
11.      1        4     9.44       3.13
0..      2        2     1.80       0.02

Chi-square statistic = 28.1 
Number of bootstrap samples = 200
P-value = 0.005

Quantiles of bootstrapped statistics:
  0%  25%  50%  75% 100% 
 1.5  4.8  7.2 10.0 31.1 

Estimate of c-hat = 3.62 

The test rejects, with \(\hat c\) = 3.6. Two cells carry it: 111 is observed well above its expectation, and 100 at about three times its expectation, while the mixed histories 011 and 110 fall short. That pattern is the signature of detection heterogeneity the covariates have not captured. Some quadrats are easy, the bird is found every time, and some are hard, so the histories bunch at the extremes rather than spreading binomially. The excess of 100 could also be a closure failure: a bird present and singing on the first visit that had moved on by the second.

Neither violation is harmless for \(\hat\psi\). Unmodelled heterogeneity in \(p\) means the all-zero sites are disproportionately the hard ones, where \((1-p)^J\) is larger than the model thinks, so \(\hat\psi\) is biased low. Closure failure does the opposite: \(\psi\) becomes the probability that a quadrat was used at some point during the season, which is larger than the probability it was occupied throughout, so \(\hat\psi\) overstates the quantity most people mean. Here the two may partly cancel, and with \(\hat p\) near 0.8 the damage to \(\hat\psi\) is bounded either way; a quasi-likelihood fix multiplies the standard errors by \(\sqrt{\hat c}\) = 1.9. The constructive fixes are a detection covariate that captures the heterogeneity, a finite-mixture detection model, or a dynamic model that drops the closure assumption.

The same model across the corpus

One table is a tutorial. The point of a warehouse is that the same six lines run over every table of the same shape, so this section fits the null model \(\psi(\cdot)\,p(\cdot)\) to every species in every site-level detection or count table in eco version 10 and asks three questions of each fit: how far \(\hat\psi\) sits from naive occupancy, whether the estimate is at a boundary, and whether the MacKenzie and Bailey test rejects. The tables are chosen by rule from eco_metadata(), not by name: site units, a detection or count response, at least two occasions. Designs the model does not describe (multi-scale eDNA, false-positive and two-scale co-occurrence tables) are excluded by name, each with its reason, and the tables over the 100 MB that Redivis serves without a login are held back for now; both lists are at the end of this section. The fits take most of an hour because of the bootstrap, so they live in a companion script, occupancy_corpus_compute.R, and the page reads its cache. Multi-season tables contribute the primary period with the most surveys; count tables are collapsed to detection; a species never detected in that period, or surveyed once per site, is skipped, since the null model has nothing to fit or cannot separate \(\psi\) from \(p\).

corpus <- readRDS("occupancy_data/occupancy_corpus.rds")
# Tables withdrawn since the sweep (releases/withdrawals.csv) are dropped from
# the cache: obrist_2024_gooseisland_birds_count, pending CARE review (#150).
withdrawn <- "obrist_2024_gooseisland_birds_count"
corpus$fits <- corpus$fits[!corpus$fits$table %in% withdrawn, ]
corpus$corpus_tables <- corpus$corpus_tables[!corpus$corpus_tables$table %in% withdrawn, ]
fits <- corpus$fits
fits$correction <- fits$psi - fits$naive
fits$boundary <- !fits$converged | fits$psi > 0.995 | fits$psi < 0.005 | fits$p < 0.005
# The test's cohort table has 2^J cells. Past ten surveys the expected counts
# are tiny and the statistic degenerates (the marten table, J = 24, returns a
# c-hat in the billions), so the test is only read where J <= 10.
fits[fits$J > 10, c("chisq", "gof_p", "c_hat")] <- NA
fits$reject <- !is.na(fits$gof_p) & fits$gof_p < 0.05
fits$floor <- ifelse(fits$sample_floor == "meets", "meets floor", "below floor")

Of the 84 tables the rule selects, 12 are excluded by design and 8 held back for size, and the rule on one survey per site removes 2 more entirely (frimpong_2017_newriver_dynocc and sandercock_2022_norway_plants_comm): in the period each contributes, most sites were surveyed once for each species.

The null model by taxon group. Medians and the test are over the fits not at a boundary.
group tables species at boundary median p median psi median psi - naive GOF rejects median c-hat
Invertebrates 14 509 20% 0.14 0.57 0.11 34 / 278 1.19
Birds 13 505 17% 0.39 0.41 0.06 127 / 376 1.38
Fish 5 354 21% 0.39 0.61 0.08 30 / 278 0.98
Multiple 4 120 56% 0.07 0.36 0.03 9 / 33 0.82
Mammals 16 90 26% 0.20 0.31 0.06 17 / 58 1.02
Amphibians 4 23 0% 0.47 0.36 0.04 6 / 23 1.61
Reptiles 5 6 0% 0.50 0.40 0.02 1 / 5 1.44
Plants 1 1 0% 0.42 0.18 0.03 0 / 1 0.90

Across 1608 species fits in 62 tables, 352 are at a boundary, with \(\hat\psi\) pinned to 1 or \(\hat p\) to 0. A good share of those (143) are species detected at fewer than one site in twenty, where a handful of detections cannot say whether the species is rare or merely hard to see. The rest gather in a few designs: the extended Aldabra reef-fish survey, with two visits per site and 38 of 144 species at the boundary; the West Virginia camera grids, where the occasion is a single camera-day and the per-day \(\hat p\) for most species is under 0.01 (26 of 35 species in the Monongahela table); and the Belgian carabid pitfalls, with three visits and low catch rates. 16 tables, most of them small community surveys of reef fish, odonates and bumblebees, are below the standard’s sample floor. Among the well-behaved fits the median correction \(\hat\psi - \text{naive}\) is 0.06, with the middle 80% of species between 0.00 and 0.94. That upper decile is species with \(\hat p\) just above the boundary rule, and 54 of its 87 fits come from two tables: the UK woodland beetle pitfalls and the Berchtesgaden wild bees, where the median \(\hat p\) is 0.13 and 0.01. Those fits are technically interior and substantively the same failure as the boundary ones.

The group table says the corpus has changed character. Birds were most of the version 2 corpus; now invertebrates and fish together outnumber them. Invertebrates are detected far less often than birds (median \(\hat p\) 0.14 against 0.39) and carry about twice the correction; fish are detected as often as birds but estimated present at more of the sites. Whether that is the taxa or the designs that survey them (pitfalls and pan traps visited two or three times, against point counts and territory mapping) the null model cannot say, and the next section’s covariate is a first attempt to tell them apart.

f$label <- sprintf("%s\n%s\n%d sites, J = %g\nnaive %.2f, psi %.2f, p %.2f%s",
                   f$table, f$taxon, f$n_sites, f$J, f$naive, f$psi, f$p,
                   ifelse(is.na(f$c_hat), "", sprintf("\nc-hat %.1f", f$c_hat)))
f$group <- factor(f$taxon_group, levels = grp$group)
g <- ggplot(f, aes(naive, psi, colour = p, shape = floor, text = label)) +
  geom_abline(slope = 1, intercept = 0, colour = "#c9ccc8") +
  geom_point(size = 1.6, alpha = 0.8) +
  scale_colour_gradient(low = "#bfe3d2", high = "#0b4f33", name = "p", limits = c(0, 1)) +
  scale_shape_manual(values = c("meets floor" = 16, "below floor" = 2), name = NULL) +
  facet_wrap(~ group, ncol = 3) +
  coord_equal(xlim = c(0, 1), ylim = c(0, 1)) +
  labs(x = "Naive occupancy", y = "Estimated occupancy")
plotly::ggplotly(g, tooltip = "text", width = 760, height = 860) |>
  plotly::layout(legend = list(title = list(text = ""))) |>
  plotly::config(displayModeBar = FALSE)
Figure 3: Estimated against naive occupancy for every species fit, one panel per taxon group. Colour is the estimated per-survey detection probability; open triangles are tables below the sample floor; points on the top edge are boundary fits. Hover a point for the species.

The picture is the simulator’s expected-naive line read backwards. Species with high \(\hat p\) sit on the diagonal; the correction grows as \(\hat p\) falls, and below about \(p = 0.2\) with three surveys the all-zero sites can no longer be told apart from empty ones and the fit slides up the top edge. The bird panel is mostly the first regime and the invertebrate panel mostly the second. The below-floor tables show the same failure from the other direction: ten or twenty sites cannot pin \(\psi\) down whatever \(p\) is.

ggplot(f[!is.na(c_hat)], aes(pmin(c_hat, 10))) +
  geom_histogram(binwidth = 0.25, fill = "#1e8a5a", colour = "white", boundary = 0) +
  geom_vline(xintercept = 1, linetype = 2, colour = "#55575f") +
  labs(x = expression(hat(c)), y = "species")
Figure 4: The overdispersion estimate from the MacKenzie and Bailey test for every fit it could be run on (ten or fewer surveys, not at a boundary). Values above 10 are drawn at 10. The dashed line is 1, where the null model fits.

The test rejects at the 5% level for 26% of the well-behaved fits, with a median \(\hat c\) of 1.2. The share tracks sample size and detection as a power calculation would predict: in the MHB community table, with 266 quadrats and a median \(\hat p\) above 0.6, the test rejects for 68% of species, while in the low-\(p\) invertebrate tables it rarely has the power to reject anything. A quiet test there is not evidence of fit. That the willow tit’s \(\hat c\) of 3.1 is not unusual among the well-sampled bird tables is the useful lesson: the constant-\(p\) model is a starting point, and the detection heterogeneity it leaves behind is the norm in field data, not a feature of one table. The remedies are the ones listed above, and the covariates to try are already in the tables’ unit_ and obs_ columns.

Every table in the sweep (62), and the ones left out
table species group sites J median p median psi - naive at boundary GOF rejects floor
kery_2014_mhb_comm 145 Birds 266 3.0 0.65 0.01 23 83 / 127 meets floor
koester_2023_aldabra_reeffishext_count 144 Fish 21 2.0 0.06 0.85 38 6 / 106 below floor
bradferlawrence_2025_ukwood_beetle_comm 115 Invertebrates 60 5.0 0.11 0.14 9 9 / 106 meets floor
barea_2021_sierranevada_butterfly_count 90 Invertebrates 21 13.0 0.16 0.08 9 0 / 0 below floor
margenau_2021_rowsongbirds_nmix 90 Birds 216 2.0 0.22 0.28 19 4 / 71 meets floor
maihoff_2023_berchtesgaden_bees_count 83 Invertebrates 33 5.0 0.02 0.90 9 10 / 74 meets floor
koester_2023_aldabra_reeffish_count 73 Fish 21 3.0 0.38 0.13 21 5 / 52 below floor
stallings_2025_gulfreefs_count 70 Fish 14 4.0 0.35 0.07 13 6 / 57 below floor
sullivan_2026_powdermill_count 70 Birds 101 2.0 0.20 0.52 10 7 / 60 meets floor
peer_2014_bmsil_butterfly_count 64 Invertebrates 27 17.0 0.09 0.11 16 0 / 0 meets floor
henry_2020_karoo_birds_comm 63 Birds 61 18.0 0.10 0.11 18 0 / 0 meets floor
bradferlawrence_2025_ukwood_bird_comm 54 Birds 125 3.0 0.37 0.07 3 21 / 51 meets floor
fukaya_2022_kasumigaura_fish_mb 50 Fish 50 3.0 0.63 0.02 2 9 / 48 meets floor
clipp_2024_wvprivate_comm 47 Multiple 146 63.0 0.01 0.73 27 0 / 0 meets floor
kyaw_2024_myanmar_mamm_comm 46 Mammals 518 5.0 0.11 0.10 12 5 / 34 meets floor
peters_2026_carabid_pitfall_count 42 Invertebrates 225 3.0 0.01 0.93 24 1 / 18 meets floor
work_2026_ocala_odonatenymphs_count 36 Invertebrates 16 2.0 0.14 0.72 13 2 / 23 below floor
clipp_2024_monongahela_comm 35 Multiple 129 9.0 0.00 0.97 26 3 / 9 meets floor
lebeuftaylor_2026_boreal_edges_aru_comm 34 Birds 564 3.0 0.36 0.05 3 0 / 31 meets floor
glorioso_2025_atchafalaya_ves 32 Multiple 66 6.0 0.04 0.69 12 6 / 20 meets floor
work_2026_ocala_odonates_comm 28 Invertebrates 16 2.0 0.11 0.78 14 0 / 14 below floor
palacio_2020_pampasbirds_comm 19 Birds 10 5.0 0.18 0.25 7 2 / 12 below floor
mctigue_2023_nwarkansas_comm 18 Mammals 285 6.0 0.19 0.10 6 6 / 12 meets floor
lafferty_2024_estuaryfish_mb 17 Fish 14 2.0 0.72 0.00 2 4 / 15 below floor
peters_2026_carabid_emergence_count 17 Invertebrates 99 3.0 0.17 0.41 3 5 / 14 meets floor
boone_2023_minnesota_bombus_count 15 Invertebrates 25 5.0 0.58 0.02 1 7 / 14 below floor
dettling_2021_marin_riparian_count 14 Birds 175 2.0 0.37 0.17 1 5 / 13 meets floor
doser_2022_hbef_trends_dynocc 12 Birds 373 3.0 0.53 0.06 0 2 / 12 meets floor
johnson_2023_tweedsmuir_bombus_count 10 Invertebrates 26 2.0 0.15 0.69 3 0 / 7 below floor
hamer_2024_hungary_amph_comm 9 Amphibians 100 3.0 0.36 0.06 0 4 / 9 meets floor
price_2018_mtr_salamanders_count 7 Amphibians 23 4.0 0.65 0.01 0 0 / 7 below floor
addis_2026_rmap_amph_dynocc 6 Amphibians 313 4.0 0.46 0.03 0 2 / 6 meets floor
nowicki_2019_sharkbay_count 6 Multiple 10 9.5 0.28 0.03 2 0 / 4 below floor
galvez_2021_araucania_comm 5 Mammals 180 11.0 0.36 0.01 0 0 / 0 meets floor
bradferlawrence_2025_ukwood_mammal_comm 4 Mammals 100 4.0 0.53 0.02 0 3 / 4 meets floor
dezeeuw_2024_nl_waterbeetle_nmix 4 Invertebrates 85 2.0 0.72 0.04 0 0 / 4 meets floor
malhotra_2021_loslagos_comm 4 Mammals 48 10.0 0.23 0.02 0 3 / 4 meets floor
inbo_2026_flanders_dragonfly_count 3 Invertebrates 16 2.0 0.70 0.06 0 0 / 3 meets floor
ahizi_2021_civ_crocodylians_occ 2 Reptiles 42 5.0 0.82 0.00 0 0 / 2 meets floor
blount_2025_neturkiye_carniv_count 2 Mammals 216 10.0 0.13 0.28 1 0 / 1 meets floor
goldingay_2022_richmond_mammals_dynocc 2 Mammals 34 3.0 0.26 0.24 0 0 / 2 meets floor
armstrong_2024_hydrilla_dynocc 1 Plants 504 4.0 0.42 0.03 0 0 / 1 meets floor
bhattacharya_2022_himachal_bear_occ 1 Mammals 67 37.0 0.05 0.11 0 0 / 0 meets floor
bison_2024_montblanc_hare_dynocc 1 Mammals 45 91.0 0.01 0.78 1 0 / 0 meets floor
blount_2025_neturkiye_lynx_occ 1 Mammals 216 10.0 0.07 0.24 0 0 / 1 meets floor
bruce_2021_wisconsin_monarch_nmix 1 Invertebrates 60 3.0 0.71 0.02 0 0 / 1 meets floor
burgar_2018_alberta_fisher_count 1 Mammals 64 64.0 0.04 0.42 1 0 / 0 meets floor
evans_2021_maine_marten_dynocc 1 Mammals 193 24.0 0.12 0.03 0 0 / 0 meets floor
hartley_2024_cpraealtus_occ 1 Reptiles 113 5.0 0.23 0.11 0 1 / 1 meets floor
hepler_2018_serengeti_gazelle_occ 1 Mammals 194 34.0 0.15 0.28 1 0 / 0 meets floor
kery_2005_mallard_count 1 Birds 235 3.0 0.66 0.01 0 0 / 1 meets floor
kery_2008_willowtit_occ 1 Birds 237 3.0 0.79 0.01 0 1 / 1 meets floor
kery_2010_crossbill_dynocc 1 Birds 266 3.0 0.69 0.02 0 1 / 1 meets floor
knape_2018_shoveler_count 1 Birds 50 10.0 0.67 0.00 0 1 / 1 meets floor
koetke_2024_jprf_moose_count 1 Mammals 72 91.0 0.02 0.39 1 0 / 0 meets floor
leone_2019_minnesota_monarch_nmix 1 Invertebrates 20 3.0 0.47 0.15 1 0 / 0 below floor
samek_2024_racerunner_occ 1 Reptiles 100 3.0 0.23 0.27 0 0 / 1 meets floor
schank_2015_tapir_occ 1 Mammals 22 45.0 0.03 0.10 0 0 / 0 below floor
smith_2024_florida_tegu_dynocc 1 Reptiles 77 19.0 0.15 0.03 0 0 / 0 meets floor
teitsworth_2026_necturus_dynocc 1 Amphibians 93 4.0 0.55 0.02 0 0 / 1 meets floor
tleimat_2023_ecuador_capuchin_occ 1 Mammals 21 28.0 0.13 0.04 0 0 / 0 below floor
yadav_2022_rapti_gharial_count 1 Reptiles 18 3.0 0.98 0.00 0 0 / 1 below floor
table status reason
allen_2021_nj_lanternfly_edna excluded multi-scale eDNA qPCR with a paired visual survey
chambert_2018_plethodon_fpocc excluded two species with misidentification; needs a false-positive model
dougherty_2016_rustycrayfish_edna excluded multi-scale eDNA qPCR with trap; occasions mix methods
kleiven_2020_varanger_dynocc excluded two spatial scales and 304 occasions; a co-occurrence design
lafferty_2024_tidewatergoby_edna excluded multi-scale, multi-method eDNA (qPCR and metabarcoding)
sandercock_2022_norway_insects_edna excluded multi-scale eDNA metabarcoding
smith_2019_greatbasin_csf_edna excluded multi-scale eDNA (watershed > site > sample); the unit is not the site the model wants
smith_2019_greatbasin_csf_qpcr excluded multi-scale eDNA with false positives (site > sample > qPCR replicate)
swedberg_2023_springfish_occ excluded multi-scale (reach > site > survey) with two gears
tomke_2025_hellbender_edna excluded multi-scale eDNA (site > filter > qPCR replicate)
whittington_2015_banff_tracks_comm excluded multi-scale (cell > segment > repeat walk) with Markovian detection
ziolkowski_2026_bbs_count excluded 18 GB, 110 M rows; too large for a per-species sweep (the BCR 15 pilots stand in for BBS)
frimpong_2017_newriver_dynocc no fit one survey per site per species in the period used
sandercock_2022_norway_plants_comm no fit one survey per site per species in the period used
neon_2026_carabids_count skipped 529 MiB; large tables held back for now (run with –big)
neon_2026_landbirds_count skipped 931 MiB; large tables held back for now (run with –big)
neon_2026_smallmammals_count skipped 369 MiB; large tables held back for now (run with –big)
nina_2026_norway_pollinator_count skipped 531 MiB; large tables held back for now (run with –big)
rooney_2025_snapshotusa_comm skipped 617 MiB; large tables held back for now (run with –big)
vanklink_2025_wijster_carabid_count skipped 136 MiB; large tables held back for now (run with –big)
ziolkowski_2026_bbs_bcr15_block skipped 214 MiB; large tables held back for now (run with –big)
ziolkowski_2026_bbs_bcr15_stop skipped 712 MiB; large tables held back for now (run with –big)

One covariate everywhere: effort on \(p\)

The null model’s ĉ says the constant-\(p\) assumption fails; the natural first covariate is the one every protocol records in some form, how hard the survey tried. 19 of the tables in the sweep carry it: camera nights, days or hours, minutes searched, the standardised survey intensity of the Swiss transects, trap-nights at a station, pitfall traps or cover tiles per visit, transect length. The units differ, so each is taken as standardised log effort (the two Kéry tables are standardised already) and the model becomes \(\psi(\cdot)\,p(\text{effort})\). The slope is then the change in logit \(p\) per standard deviation of log effort, a comparable number across protocols. The compute script fits it for every species in those tables, on the surveys with an effort value, and reruns the goodness-of-fit test. Three tables the metadata flags as having effort get no fit: in one the survey length is the same at every survey, and in two the flagged column is not effort.

ef <- as.data.table(corpus$effort)
ef <- merge(ef, f[, .(table, taxon, n_sites, J, naive, p_null = p, c_hat_null = c_hat,
                      boundary, floor, taxon_group)], by = c("table", "taxon"))
ef[, `:=`(lo = slope - 1.96 * slope_se, hi = slope + 1.96 * slope_se,
          d_aic = aic_null - aic_effort)]
ef[, significant := converged & lo > 0]
ef[J > 10, c_hat_effort := NA]
ok_e <- ef[converged & !boundary]
table species effort median slope positive, CI excludes 0 median delta AIC median c-hat, null median c-hat, effort
kery_2014_mhb_comm 120 dur_min 0.24 31 / 120 0.10 4.49 4.38
bradferlawrence_2025_ukwood_beetle_comm 105 n_traps 0.13 11 / 105 -1.06 0.85 0.82
maihoff_2023_berchtesgaden_bees_count 71 n_days -0.88 0 / 71 -1.95 1.64 1.77
kyaw_2024_myanmar_mamm_comm 34 camera_days 0.60 15 / 34 5.00 0.19 0.09
glorioso_2025_atchafalaya_ves 20 duration_min 0.05 1 / 20 -1.48 0.95 1.05
clipp_2024_wvprivate_comm 18 camera_hours 1.06 1 / 18 -1.21 NA NA
mctigue_2023_nwarkansas_comm 12 camera_days 0.54 10 / 12 37.55 3.13 3.49
clipp_2024_monongahela_comm 9 camera_hours 0.43 1 / 9 0.46 0.51 2.09
hamer_2024_hungary_amph_comm 9 effort_ves_min 1.36 8 / 9 13.98 1.15 2.49
galvez_2021_araucania_comm 5 camera_nights 0.11 2 / 5 -1.05 NA NA
malhotra_2021_loslagos_comm 4 trapnights -0.14 0 / 4 -0.55 4.86 7.17
nowicki_2019_sharkbay_count 4 transect_km -0.26 0 / 4 -1.63 0.69 0.84
hartley_2024_cpraealtus_occ 1 tiles_available -0.72 0 / 1 9.01 3.94 2.29
kery_2005_mallard_count 1 ivel_std -0.24 0 / 1 -1.28 1.82 1.73
kery_2008_willowtit_occ 1 ivel_std 0.24 0 / 1 -0.89 3.06 2.89
schank_2015_tapir_occ 1 trapdays 0.13 0 / 1 -1.92 NA NA
smith_2024_florida_tegu_dynocc 1 camera_days 0.33 0 / 1 0.60 NA NA

Of the 416 species with a usable effort fit, 259 have a positive slope, 80 have an interval above zero and 7 an interval below it; the median slope is 0.16 on the logit scale, so one standard deviation more searching raises the odds of a detection by about 17%.

ok_e[, table_short := sub("_(comm|occ|count|ves|nmix|dynocc)$", "", table)]
ok_e[, label := sprintf("%s\n%s\nslope %.2f (%.2f, %.2f)\np at mean effort %.2f\ndelta AIC %.1f%s",
                        table, taxon, slope, lo, hi, p_at_mean, d_aic,
                        ifelse(is.na(c_hat_effort), "", sprintf("\nc-hat %.1f -> %.1f", c_hat_null, c_hat_effort)))]
setorder(ok_e, table, slope)
ok_e[, row := seq_len(.N), by = table]
g <- ggplot(ok_e, aes(slope, row, text = label)) +
  geom_vline(xintercept = 0, colour = "#c9ccc8") +
  geom_errorbarh(aes(xmin = pmax(lo, -4), xmax = pmin(hi, 4)), height = 0, colour = "#8a8c94", linewidth = 0.4) +
  geom_point(aes(fill = significant), shape = 21, size = 1.8, colour = "#1e8a5a") +
  scale_fill_manual(values = c(`TRUE` = "#1e8a5a", `FALSE` = "white"), guide = "none") +
  facet_wrap(~ table_short, scales = "free_y", ncol = 3) +
  coord_cartesian(xlim = c(-4, 4)) +
  labs(x = "Effort slope on logit p (per SD of log effort)", y = NULL) +
  theme(axis.text.y = element_blank(), panel.grid.major.y = element_blank(),
        strip.text = element_text(size = 8))
plotly::ggplotly(g, tooltip = "text", width = 760, height = 1000) |>
  plotly::config(displayModeBar = FALSE)
Figure 5: The effort slope on logit p for every species, with 95% intervals, grouped by table. Filled points have an interval that excludes zero. Hover for the species.

Three things stand out. The sign is mostly positive but the strength is not uniform: where effort varies a lot between surveys the slope is large and the fit improves sharply (the Hungarian pond searches, 3 to 114 minutes, with eight of nine species positive and clear of zero; the Arkansas cameras, 1 to 7 days, ten of twelve; the Myanmar camera network, half a day to ten days per occasion, 15 of 34 with a median \(\Delta\)AIC of 5.0), while where it barely varies (the Los Lagos stations, 67 to 80 trap-nights; the Chilean cameras, 2 to 5 nights) the slope is unidentified and the interval spans zero. The MHB community table is the instructive middle case: survey duration there runs from 105 to 420 minutes, yet the median slope is small and the AIC gain is nil. The territory-mapping protocol is designed so that every quadrat is covered completely on every visit, and the extra minutes go to terrain and pace rather than to a more thorough search, so for this protocol raw duration is not effort in the sense the model wants. The willow tit and mallard tables carry the package’s survey intensity, effort scaled to the route, which is the better variable and the reason those scripts kept it.

Two tables need a caveat before their slopes are read. In the West Virginia camera grids the occasion is one camera-day and nearly every occasion is a full 24 hours, so the slope rests on the few partial days at deployment and retrieval, and 53 of 82 species there are at a boundary under the null model and drop out of the figure. In the Berchtesgaden bee table the variable is whether a visit took one day or two, and the slope is negative for 63 of 71 species (median -0.88): two-day visits detect less. That is not what effort does. One possible reading, not yet checked against the deposit, is that a visit ran to a second day when the first was cut short, so the variable marks bad conditions rather than extra searching. It stays in the sweep as a reminder that a column called effort has to be read against the protocol before it goes into \(p\).

And one covariate does not fix the fit: ĉ falls for 57% of the species where both tests ran, but only 48% end up at or below 1.5, and the MHB median does not move. Most of the heterogeneity the null model’s test detected lives elsewhere, in the site, the observer, or the abundance behind a collapsed count, which is where the unit_ columns and a mixture on \(p\) come in.

Where this goes

Everything above changes by one line in the state or observation process, and eco carries a table for each.

  • Poisson state. Let \(N_i \sim \text{Poisson}(\lambda_i)\) with \(y_{ij} \mid N_i \sim \text{Binomial}(N_i, p)\) and the same table of counts fits the N-mixture model of chapter 6 (unmarked::pcount()). eco_to_unmarked() picks pcount when y goes beyond 0/1; kery_2014_mhb_comm is the MHB count table.
  • Markov state. Let \(z_{it}\) evolve across seasons by colonisation and extinction and the table with a period column fits the dynamic occupancy model of chapter 16 (unmarked::colext()), which is also the model that relaxes closure. kery_2010_crossbill_dynocc is the MHB crossbill table over nine years.
  • Species as random effects. Give every species in a community table its own \((\psi_k, p_k)\) drawn from a shared distribution and you have the community occupancy model of chapter 11. galvez_2021_araucania_comm and hamer_2024_hungary_amph_comm are community tables with one period and several surveys; eco_to_array() keeps the species dimension that eco_to_unmarked() refuses.

Reproducibility

Source: site/vignettes/occupancy.qmd and occupancy_corpus_compute.R in the eco repository; the corpus fits were run on 2026-11-04 with 100 bootstrap samples per test. Data were read with eco_set_version(10), so a later release of the warehouse does not change the page.

eco version 10 (Redivis eco v2.2, eco_meta v9.0, released 2026-11-04)
R 4.6.2; eco 0.1.0; unmarked 1.5.2; AICcmodavg 2.3.4

References

MacKenzie, D. I., Nichols, J. D., Lachman, G. B., Droege, S., Royle, J. A. and Langtimm, C. A. (2002). Estimating site occupancy rates when detection probabilities are less than one. Ecology 83, 2248–2255.

MacKenzie, D. I. and Bailey, L. L. (2004). Assessing the fit of site-occupancy models. JABES 9, 300–318.

Kéry, M. and Royle, J. A. (2016). Applied Hierarchical Modeling in Ecology, volume 1, chapters 10 and 11. Academic Press.

Fiske, I. and Chandler, R. (2011). unmarked: an R package for fitting hierarchical models of wildlife occurrence and abundance. Journal of Statistical Software 43(10).