crywolf (development version)
fp_occu_ms(random_ver = TRUE)adds a random effect on the logit of the verified detection probability for each site and species, with one standard deviation shared by the species (sd_verified_site, with the prior offp_priors(det_site_sd = )). It is for verified detections of a site and species that are more often all or none than one detection probability allows, which makesfp_ppc(method = "verified")fail.fp_ppc(),fp_sites(),fp_richness(),fp_state_draws()andsimulate()include the effect, andsimulate_fp_ms()gainssd_ver_siteto simulate it.vignette("multispecies")has a section on passing the state draws offp_state_draws()to a joint species distribution model, with the simulations that check how well ‘gllvm’ and ‘Hmsc’ recover the residual associations between species from them.
crywolf 2.5.0
- New
fp_state_draws()(experimental) draws the occupancy state of every species at every site from anfp_occu_ms()fit, one site x species matrix per posterior draw, corrected for false positives. The draws can be passed to a joint species distribution model of another package (‘gllvm’, ‘Hmsc’) by multiple imputation; the help page shows how, and states the limits: the associations between species come out weaker than they are, and confusion between species is not corrected. -
fp_read_sheepdog()reads the true identity of reviewed clips from schema version 1.5 of the sheepdog export:validationgainsidentity(what the clip held; several identities separated by"|") andidentity_certainty("sure"or"probable"),NAwhere the reviewer gave none and in earlier exports. The models do not use them; they show which confusions the false-positive rate holds.
crywolf 2.4.0
- New
fp_occu_rn()fits the Royle-Nichols occupancy model with false positives: Poisson abundance, per-individual detection, false positives on every occasion, verified occasions and the observation-confirmation design, with site effects on the per-individual detection (random_det), on log abundance (random_abund) and on the false-positive rate (random_fp).random_detthen measures variation in detection among sites beyond that due to abundance.simulate_fp_rn()simulates data from it, with unbalanced occasions if needed, andfp_priors()gainsabund_site_sd. Its fits haveloo()(leave one site out, with the site effects integrated out and exact refits withreloo = TRUE) andsimulate()methods, andfp_sites()(with the posterior mean abundance of each site),fp_ppc()andfp_loo_weights()accept them. Its defaultadapt_deltais 0.99, above the 0.95 offp_occu(), because divergences were common at 0.95 in simulations. Both functions join the stable interface (?crywolf-api). The new articlevignette("royle-nichols")describes the model and the simulations that validate it (simulation-based calibration and a grid over sites, occasions and annotation schemes). -
fp_calibrate()gainsdynamic: withdynamic = TRUE, the design is simulated withsimulate_fp_dyn(), each dataset is fitted withfp_occu_dyn()(formulaspsi1,colandext), and the coverage of initial occupancy, colonization, extinction, the false-positive rate and the verified detection probability is scored.plot()of a dynamic calibration counts verified site-seasons.fp_verification_curve()gains the same arguments and, withdynamic = TRUE, prints the coverage of initial occupancy, colonization and extinction against the fraction of site-seasons verified. -
?fp_occuand?fp_occu_msnow state that the false-positive rate of a species does not depend on which other species are present. They also report how occupancy is overestimated when the classifier confuses two species often. -
fp_occu()no longer fails when every automated occasion is confirmed (observation-confirmation design with nothing left unchecked). - New
fp_review_priority()(experimental) gives every site, or site and species, a size for a directed review round of ‘sheepdog’ (sheepdog::select_directed()): the variance of its occupancy state given the data. Units already confirmed (a verified detection, or a confirmed clip invalidation) are left out. -
fp_read_sheepdog(): the warning on clips of the"directed_pps"design now says when using them without weights is right (the size of the units came from a model of data the fit also holds, as withfp_review_priority()) and when it is not (the size came from the scores).
crywolf 2.3.0
rOpenSci statistical standards: every general and Bayesian standard is tagged with ‘srr’ next to the code or test that addresses it, or declared not applicable with a reason in
R/srr-stats-standards.R.fp_data()checks thatsite,y,recorder,seasonandspecieseach name one column.plot(fit, type = "trace")shows the warm-up draws, shaded, when the fit kept them (save_warmup = TRUE).Messages of conditions are now unique, so each points to where it arose.
?crywolfhas sections on the relation to ‘unmarked’ and on argument conventions (single values, case-sensitive options); the README shows how to set a prior.Every error, warning and message of the package now has a test that triggers it and checks its text.
fp_data_wide()stops with a clear message whensite_covsis not a data frame or matrix.simulate_fp_ms()checks that its numeric arguments are single finite numbers, and works withfrac_verified = 0.Messages agree in number (“
markovandrandom_detare not available”, “validationmixes the verdicts”), and the CmdStan version message follows the version the package requires.Checks before sampling:
fp_occu(),fp_occu_dyn()andfp_occu_ms()warn (classcrywolf_design_warning) on collinear or constant covariates and unused factor levels, naming the redundant column whose posterior only repeats its prior. They stop on list columns in a formula and on invalidchains,iter_warmup,iter_sampling,adapt_deltaorseed.The sampler warnings now also cover transitions that hit the maximum tree depth and chains with an E-BFMI below 0.3 (
$diagnostics$low_ebfmi), and have classcrywolf_sampler_warning, so they can be muffled selectively.The help of
fp_occu()documents starting a run from a previous fit (init = old$fit), how to silence progress output, and the handling of missing values and of factor contrasts;?fp_datadocuments why rows with a missing detection are dropped.init = old$fitinfp_occu(),fp_occu_dyn()andfp_occu_ms()starts each chain from the last draw of a chain of the earlier fit; the conversion is done by crywolf, so it also works with cmdstanr versions whose own conversion fails with precompiled models.New tests of outputs without missing values, of starting values, of silenced output, and extended tests against
unmarked::occuFP(), of precision and run time against the number of sites and of covariate scale; the extended tests run weekly on GitHub Actions.Documentation for the rOpenSci review: a contributing guide (
.github/CONTRIBUTING.md), project-status and lifecycle badges, acodemeta.json, a Value section and examples forhelp("crywolf-api")andhelp("crywolf-output"), an example forfp_read_validation(), a fuller description of the sampler arguments offp_occu(), and a note in the README on how crywolf relates tounmarked::occuFP(). Internal functions now carry roxygen comments with@noRd.fp_occu(prior_only = TRUE)samples from the priors alone, through the same Stan program, to check what the priors imply and that the sampler recovers them.The seed CmdStan used is stored in
$sampler$seedof a fit, also whenseed = NULL, so any fit can be reproduced.New tests of parameter recovery and of the recovery of the priors; longer statistical tests (recovery over ten datasets, stability to noise and to the seed) run when
CRYWOLF_EXTENDED_TESTSis"true"(seetests/README.md).Bug fix:
fp_data()read a detection column stored as a factor by its level codes, so thatfactor(y, levels = c(1, 0))turned detections into 1s and 2s. Factors are now read by their labels, and detections become integer 0/1 in the returned data.Stricter checks of inputs, with messages that name the argument:
fp_priors()takes single positive numbers (and a single finitegap_mean);random_recorder,random_fpandrandom_detmust beTRUEorFALSE;priorsmust come fromfp_priors(); infinite covariates are rejected;fp_data()stops whenautohas no occasion with a detection record;simulate_fp()takes single finite numbers; andpredict()stops on missing covariates innewdatainstead of returning fewer rows thannewdata.fp_ppc()under the observation-confirmation design now checks all automated occasions, confirmed or not. It left the confirmed ones out, but these are usually chosen among the detections, so the unconfirmed ones held too few detections and the check gave false alarms (a p-value of 0 or 1 when every detection was confirmed).Changes for CRAN: examples that fit models run in
\donttest{}when CmdStan is installed, with two chains and one thread each, instead of never; examples that read a sheepdog export use one shipped ininst/extdata/sheepdog-export. Vignette fits run at most two chains at a time. UnderR CMD check, a model compiled after installation goes totempdir()instead of the user cache.Tessa Rhinehart is no longer listed as an author.
curiango$verifiedgainstest_set, the test set each annotated recording was drawn in. Sets 1 and 2 (960 recordings) are random draws; set 3 (239) was chosen to add detections, with information beyond the classifier scores.?curiangodescribed the test set as drawn in proportion to the effort at each site, which holds only for sets 1 and 2; it now describes both stages and advises leaving set 3 out of the verified method.fp_occu_ms(),simulate_fp_ms(),fp_richness(), thefp_occu_msandfp_sim_msclasses and their methods, and thespeciesargument offp_data()are no longer in development. Their arguments, classes and output names join the stable interface from 2.3.0 (seehelp("crywolf-api")).fp_occu_ms():centeredandcentered_occnow default to"auto", which centres both with at least 20 species and 100 sites and neither otherwise, with a message. The rule comes from a grid of simulations of 5, 20 and 50 species at 30, 100 and 300 sites (vignette("multispecies")). Passcentered = FALSE, centered_occ = FALSEfor the earlier default.fp_occu_mc()fitsfp_occu_ms()when the versions hold several species, asfp_draws_data()returns them from a multispecies export of sheepdog, and pools its draws. The parametrization is chosen once for all the fits.vignette("multispecies")shows the path from the export to the pooled posterior.vignette("multispecies")reports the cost offp_occu_ms()on a dataset of the size ofcuriangowith 20 species, and the time per gradient bythreads_per_chain.With cmdstanr 0.9.0, the current release on r-universe,
fp_occu(),fp_occu_dyn(),fp_occu_ms()and the other fitting functions ran each chain on one thread whateverthreads_per_chain: cmdstanr dropped the threads with a warning, because it did not recognise the compiled model as built with threads. crywolf now marks the model so that the threads are used.fp_read_sheepdog()drops reviewed clips of the new"score_bands"design of sheepdog with a warning, whateverkeep_top: they were drawn within bands of score, for thresholds and calibration, and would bias the false-positive rate. It stops with an error when every reviewed clip is of this design and the export has no annotated recordings.fp_read_sheepdog()keeps reviewed clips of the new"directed_pps"design of sheepdog (select_directed()) with a warning: their units were drawn with unequal probabilities, possibly from the scores, and crywolf does not weight byinclusion_prob.fp_occu_dyn(),simulate_fp_dyn()and thefp_occu_dynandfp_sim_dynclasses and their methods are no longer experimental. Their arguments, classes and output names joined the stable interface after 2.2.0 was released without changes to them (seehelp("crywolf-api")).New article
how-crywolf-works: what the model does and why it needs verified or confirmed data, in figures and without equations.The site has a three-page cheat sheet, in the tab “Cheat sheet”, with the figures of that article.
New dataset
pika: surveys of the American pika by Goldman et al. (2023), used invignette("dynamic").fp_data()warns about occasions that are both inverifiedand confirmed rows ofauto, which enter the likelihood twice. That is correct only for two independent reviews, not for one verdict copied to both tables. They are compared by site andoccasion_id(and species withspecies, season withseason) when both tables have anoccasion_idcolumn, as in a ‘sheepdog’ export.fp_occu_ms()(in development) gainsby_species: the slopes ofdet, the slopes offpand the intercept of the verified method can vary by species, drawn around the community values as the intercepts are. With every species deviation at 0 the likelihood is that of the shared terms, and with standard deviations 1 and community values 0 it equals that offp_occu()species by species, in both designs. The draws offp_occu()andfp_occu_dyn()do not change.Outputs of
fp_occu_ms()(in development):fp_sites()by site and species,fp_ppc()with a p-value per species,simulate(), the newfp_richness()(species richness of each site) and the new simulatorsimulate_fp_ms(). They run the code offp_occu()species by species, with the values of each species in the same posterior draws; the R log-likelihood of each species equals thelog_likof the Stan program.fp_occu_ms()(in development) gains random effects on the logit of the false-positive rate:fp_groupnames a column of the sites that groups them (e.g. the physical site when the sites are site-months) and adds an effect for each group and species (sd_fp_group);random_fp = TRUEadds one for each site and species (sd_fp_site). Their likelihood equals that offp_occu(random_fp = TRUE)species by species.simulate_fp_ms()gainsngroup,sd_fp_groupandsd_fp_site, andpsi_rare, the occupancy of the first species, to make it rare.fp_occu_ms()(in development) gainscentered_occ:TRUEuses a centred parametrization of the occupancy coefficients of the species, for data with many sites. It is apart fromcenteredbecause these coefficients are informed by the sites, not the occasions: with 2 species at 40 sites, centring them raised the divergent transitions. In simulations of 50 species at 100 sites,centered = TRUEraised the share of converged fits from 10% to 75%, and the remaining failures came from the occupancy intercept; withcentered_occ = TRUEas well, all 20 fits converged (articlemultispecies).predict()forfp_occu_msfits (in development): the occupancy probability or the false-positive rate of each species, from its own coefficients, for new covariates or the sites of the fit.
crywolf 2.2.0
Multispecies model (in development)
-
fp_data()gainsspecies, the column of the species, for the multispecies model in development: one row per occasion and species. It warns about species never detected, species without a verified detection, and sites where the species have unequal numbers of occasions;print()adds a table by species, andknown_presentis a matrix of sites by species. The single-species models refuse such data. -
fp_draws_data()accepts an export read with several species (fp_read_sheepdog(species = )naming them all) and returns data of all of them, asfp_data(species = "species"), from the calibration draws or the histories drawn by sheepdog. - New
fp_occu_ms(), in development: the false-positive occupancy model for several species at once, with species-specific occupancy coefficients, detection intercepts and gaps drawn from distributions of the community, and shared slopes of detection, false positives and the verified method, and a shared recorder effect. It reuses the likelihood offp_occu(), with site x species units, and hasprint(),summary()andas_draws_df()methods; its output names are documented incrywolf-output.fp_priors()gainsspecies_sd, the scale of the half-Normal priors on the standard deviations among species.centered = TRUEuses a centred parametrization of the detection intercepts, gaps and recorder effects, the same model, for data with thousands of occasions per species: on 16 species and 310,000 occasions, 1,000 iterations per chain took 14 minutes, against 10.8 hours for 4,000 with the default.
Dynamic model (experimental)
- New
fp_occu_dyn(), experimental: the false-positive occupancy model over several seasons, with initial occupancy (psi1), colonization (col) and extinction (ext) formulas on site and season covariates. Within each season the observation model is that offp_occu(), with all its options. The states are summed out by the forward algorithm. It hasprint(),summary()andas_draws_df()methods; its output names (psi1_*,col_*,ext_*) are documented incrywolf-output. - With a
fp_occu_dyn()fit,fp_sites()returns one row per site and season, with the occupancy expected from the covariates (psi) and the probability that the site-season is occupied given all the data of the site (occupied, by forward-backward over seasons).fp_ppc()checks detections per site-season, with the latent states drawn jointly over seasons by forward filtering, backward sampling, andsimulate()draws new states and detections with the structure of the data. -
fp_occu_dyn()gives derived quantities per season: expected occupancy over sites (psi_mean[t]), realized occupancy with the states drawn from their joint posterior (psi_fs[t]), turnover (turnover[t]) and, with intercept-only colonization and extinction, the equilibrium occupancy (psi_eq).summary()lists them with aseasoncolumn. - New
simulate_fp_dyn(), experimental: simulates data forfp_occu_dyn(), with colonization on a season covariate and initial occupancy and extinction on a site covariate. - The vignette
dynamicand the help page offp_occu_dyn()report the validation in simulation and its limits at low detection with little verification; the cross-validation oncuriangoaddsmarkovandrandom_det.fp_calibrate()says that it does not simulate dynamic designs. - New vignette
dynamic:fp_occu_dyn()on thecuriangodata with the nights of each site as seasons (use from one night to the next), compared with the model of independent site-nights by cross-validation on blocks of nights. -
fp_data()gainsseason_covs, covariates of each season or of each site and season. -
fp_data()fills in seasons that are dates (Date, or text asYYYY-MM-DDorYYYYMMDD, likenightandrecording_dateof a ‘sheepdog’ export): the dates missing between the first and the last are added as seasons without data, so that every transition spans the same time (one night for nightly seasons). It warns when dates or numbers are unevenly spaced and cannot be filled in. -
fp_data()gainsseason, the column of the season (primary period) of each automated and verified occasion, forfp_occu_dyn(). Seasons follow the levels of a factor or the sorted values, sonightorrecording_dateof a ‘sheepdog’ export work as they are.print()shows the number of seasons and of sites with data in each, andfp_data()warns about seasons without data at any site and about seasons without verified or confirmed data.fp_occu()ignores the column. - The Stan program keeps the likelihood of each site’s observations given that it is occupied and given that it is not (its emissions) in
fp_emissions.stanfunctions, whichfp_occu.stanincludes andfp_occu_dyn.stanshares.fp_occu()gives the same draws as before.
Integration with ‘sheepdog’ (experimental)
-
fp_draws_data()reads exports of schema 1.3, whose calibration has continuous covariates (schema$calibration$covariates, such as a standardised temperature of the night). The probability that a prediction is true then depends on its occasion, so sheepdog draws the histories when it exports and writes no calibration draws:fp_draws_data()reads those histories as they are, takesrule,p_minandseedfrom the export when they are left at their defaults, and stops with an error when asked for other values or more draws. crywolf 2.1.0 stops with an error on these exports, rather than ignoring the covariates. - The
print()method offp_read_sheepdog()shows the formula of the calibration.
crywolf 2.1.0
Integration with ‘sheepdog’ (experimental)
-
fp_read_sheepdog()reads exports of thesheepdog-occupancyschema 1.1 (any 1.x; 2.x is still refused). Its occasion covariates (schema$occasion_covariates) are extra columns ofoccasions, and the keys of the calibration are read as text. -
fp_draws_data()matches every key of the calibration (schema$calibration$keysbeyond site and species, such as month, season or recorder) by the column of that name in the occasions of the export. An occasion without a value of a key is treated as not surveyed, like one without calibration draws. Exports of schema 1.0 calibrated by month still take the month from the recording date. -
fp_draws_data()reads the detection histories that sheepdog drew (occasion_draws.parquet, schema 1.2) when they were drawn for the same species, rule, seed orp_min, and occasions; they are the histories it would draw itself.
crywolf 2.0.0
The first major version: the interface of the stable functions is frozen, the Stan model is compiled when the package is installed (the route to CRAN), and fits use several threads per chain by default. Three experimental functions start the integration with ‘sheepdog’.
Stable interface
- The interface of the stable functions is frozen (
help("crywolf-api")), extending the freeze of the names inhelp("crywolf-output")made in 1.9.0: the names, order and defaults of the arguments of these functions and of their methods, the crywolf classes of their results (and of the design warnings offp_data()), and the components and columns described in their help. These change only in a major version, announced in the NEWS of the previous minor version; a minor version may add arguments and columns. A test records the arguments of every stable function and method.fp_occu_mc(),fp_draws_data()andfp_to_unmarked()are experimental and say so in their help.
Breaking changes
-
threads_per_chainoffp_occu()defaults to"auto", as announced in 1.9.0: each chain uses its share of the physical cores. Fits are faster, but with more than one thread a fit is no longer reproduced exactly by itsseed(the posterior is the same). Setthreads_per_chain = 1to keep exact reproduction, for example to rerun an analysis made with an earlier version. The once-per-session notice of 1.9.0 and the advice after slow one-thread fits are gone.fp_calibrate(),fp_calibrate_fit()andfp_sbc()keep one thread per chain unlessfit_argssays otherwise, since their fits run side by side in parallel workers.
Installation
- The Stan model is compiled when the package is installed from source (through ‘instantiate’), with threading, if CmdStan 2.40 or later is found; otherwise, as for binary packages,
fp_compile()compiles it into the user cache on first use, as before. ‘cmdstanr’ moves from Imports to Suggests (it is not on CRAN) and ‘instantiate’ joins Imports; the Stan program moves frominst/stan/tosrc/stan/, andfp_stan_file()finds it in either case. Draws are unchanged.
New features (experimental)
-
fp_occu_mc()fits the model to several versions of the same data, such as detection histories drawn from the posterior of a classifier calibration (sheepdog::history_draws()), and pools the posteriors in equal shares (Monte Carlo propagation; a “cut” model, in which the calibration does not learn from occupancy).summary()splits each variance into parts within and between fits, and reports convergence fit by fit. With a single version and one thread per chain it reproducesfp_occu()draw for draw. Fits that did not converge (largest R-hat abovemax_rhat, 1.05 by default) are left out of the pool with a warning that names them. -
fp_draws_data()builds those versions from an export of sheepdog with calibration draws (calibration_draws.parquet): in each draw a prediction is judged true with its calibrated probability (rule = "sample", the default) or when that probability reachesp_min(rule = "threshold"). The sites of the model can be other than the recorders (for instance, site-nights). A calibration by month ("month"among the keys of the export) is matched by the month of recording; an occasion with a prediction that has no calibration is left unsurveyed (NA), not counted as a non-detection. Needs the ‘arrow’ package (Suggests). -
fp_to_unmarked()turns anfp_dataobject into theunmarkedFrameOccuFPofunmarked::occuFP(), the reverse offp_data_wide(): verified occasions first, aMETHcovariate that tells the methods apart, and optional observation covariates of the automated occasions. Withfp_read_sheepdog()andfp_aggregate(), an export of sheepdog can be fitted by maximum likelihood as well.
crywolf 1.9.0
This release freezes the API on the way to crywolf 2.0.0, and adds a site random effect on true detection.
API
- The names documented in
help("crywolf-output")(readable parameter names, the columns of the results described there, the fields of the fitted object, now includingrandom_det) are frozen from this version: they change only in a major version, announced one minor version earlier. New options may add names without changing existing ones. Results not described on that page are not covered yet.
Upcoming changes
- The default of
threads_per_chaininfp_occu()changes from 1 to"auto"in crywolf 2.0.0. Fits will be faster, but a fit will no longer be reproduced exactly by itsseed(the posterior is the same), so rerunning an old analysis with the same seed will give slightly different draws. A fit that does not setthreads_per_chainnow says so once per session; setthreads_per_chain = 1to keep exact reproduction.?fp_occuexplains the three choices ("auto", 1, or a number). -
fp_read_validation()will stop reading the legacy format of the sampler (validacao_por_clipe.csv, column names in Portuguese) in crywolf 3.0.0. It is read as before throughout crywolf 2.x, with no warning at run time.
New features
-
fp_read_sheepdog()reads the folder written bysheepdog::export_occupancy_data()(schemasheepdog-occupancy, version 1): occasions, predictions, reviewed clips with their sampling design, and recordings annotated by ear, in the forms offp_aggregate()andfp_data(). It drops clips drawn withsampling_mode = "top"with a warning (keep_top = TRUEkeeps them) and refuses other schemas and versions. Needs the ‘jsonlite’ package (Suggests). -
fp_occu(random_det = TRUE)adds a site random intercept to the logit of the true-detection probability of the automated method, for detection that varies among occupied sites in ways the covariates indetdo not capture. It is off by default, reported assd_det_site, with the priorfp_priors(det_site_sd = 1), and can be combined withrandom_fp; the combination mixes slowly, andfp_occu()warns about it. With the option off the draws are identical to those of the previous version with the same seed.loo()integrates the site effects out of each site’s log-likelihood also withrandom_det, with a two-dimensional Gauss-Hermite grid of 30 nodes per effect when both site effects are on.simulate(),fp_ppc(),fp_calibrate_fit(),fp_sbc()andfp_prior_predictive()support it. The new articlevignette("site_effects")shows in simulations (100 replicates of four scenarios) what each site effect recovers and costs, a simulation-based calibration, and thecuriangodata, where leave-one-site-out comparison prefersrandom_dettogether with the run term ofvignette("markov"). -
vignette("threshold")reports refits at thresholds 0.2 and 0.4 withfp = ~ temp + rh.
Changes
- Under
R CMD check(when_R_CHECK_LIMIT_CORES_is set, as on CRAN), a fit uses at most two cores:threads_per_chainis capped at 2 andparallel_chainsat2 %/% threads_per_chain. Fewer parallel chains do not change the draws, only the wall time: the chains run one after another. - With
random_fp = TRUE,loo()now integrates each site’s effect on the false-positive rate out of its log-likelihood, by Gauss-Hermite quadrature (new argumentsintegrate = TRUEandnodes = NULL, which means 100 nodes with one site effect), before the leave-one-out computation. A left-out site’s effect is not known from its own data, so this is the right predictive density; conditional on the fitted effects, many sites had Pareto k above 0.7 (in the example ofvignette("fp_variation"), 0 integrated against 26 to 29 conditional).integrate = FALSEgives the previous values. The exact refits ofreloo = TRUEintegrate the left-out site’s effect the same way, and no longer draw random numbers. - Tests and vignettes skip their model fits when the CmdStan found is older than 2.40, instead of failing in
fp_occu().
crywolf 1.7.0
Requirements
- CmdStan 2.40 or later is now required (it was 2.34). The data of the likelihood now travel in tuples, which
reduce_sum()accepts only from CmdStan 2.40. Update withcmdstanr::install_cmdstan(). The posterior is unchanged: at the same parameter values the log-likelihood is exactly equal to that of crywolf 1.6.0 in seven designs, and with the same seed the draws are identical in six (dev/profile/validate-tuples*.R).
Documentation
-
help("crywolf-output")gathers readable parameter names, their scales and availability, posterior summaries, diagnostics, predictions, site estimates, checks, calibration, simulation, and raw Stan mappings.
New features
-
fp_threshold_sweep()can derive MaxF1 and MaxPrecision thresholds from reviewed classifier clips. Ties favour recall, then the smaller threshold; selected thresholds and validation metrics are retained as attributes. Numeric thresholds remain supported and duplicate thresholds are fitted once.
Bug fixes
-
print()of anfp_dataobject counted the sites known to be occupied (from verified detections and confirmed true observations together) on the line of verified sites, so data with only confirmations showed “0 verified sites … 24 with a confirmed detection”. Verified sites, confirmed occasions, and sites known to be occupied now have their own lines. - With
parallel = TRUE, the workers of ‘furrr’ use the L’Ecuyer-CMRG generator, sosimulate_fp(seed = s)insidefp_calibrate(),fp_verification_curve(),fp_calibrate_fit(), andfp_sbc()simulated other datasets than a sequential run with the same seeds. Every function that takes aseednow sets R’s default generators along with it, so the two modes give identical results. In a session with the default generators nothing changes:simulate_fp()still reproduces the datasets of the fpcalib compendium exactly. - Two fits made within the same minute after the same
set.seed()could share CmdStan’s output file names, which ‘cmdstanr’ draws from R’s random numbers; discarding the first fit then deleted the files of the second, and reading its draws failed with “File does not exist” or “Supplied CSV file is corrupt”.fp_occu()now gives every fit its own file names, without using R’s random numbers.
Tests
- The precomputed results of the vignettes carry the MD5 of the Stan program that made them, and a vignette shows a note when its results come from another version of the program.
dev/precompute-all.Rrefreshes them all;dev/restamp-precomputed.Rmarks them current without recomputing, only after the posterior regression test passes. The MD5 is of the whole file, so even an edit to a comment in the Stan program shows the note until the results are restamped. - A posterior regression test checks, in four designs, that the log-likelihood at saved parameter values is unchanged and that posterior means stay within Monte Carlo error of saved references (
tests/testthat/test-regression.R; references made bydev/make-regression-refs.R).
New articles
- “From BirdNET output to an occupancy model”: BirdNET selection tables and ‘sheepdog’ verdicts to the data of
fp_data(). - “Choosing a classifier threshold”:
fp_threshold_sweep()on thecuriangodata. - “Reporting a crywolf analysis”: the items of the Bayesian Analysis Reporting Guidelines, with a template for methods and results.
- “Detections that come in runs”: the Markov term on the
curiangodata. - “False-positive rates that vary among sites and occasions”:
random_fpand occasion-level covariates on simulated data. - “Planning a study”: decisions to make before recording starts.
- “Performance”: computing time over the versions, threads, and what did not help.
Results that need long fits are precomputed by dev/precompute-markov.R, dev/precompute-threshold.R, and dev/precompute-fp-variation.R.
Installation
- ‘sheepdog’, suggested for reading clip reviews, is now installed from https://diogoprov.r-universe.dev (listed in
Additional_repositories) instead of from GitHub throughRemotes. The README says how.
crywolf 1.6.0
Speed
-
fp_occu(threads_per_chain = "auto")uses the physical cores divided among the parallel chains. On thecuriangodata, 150 iterations of one chain took 55 s with one thread, 16 s with four, and 10 s with eight. The default stays at one thread, because with more the order of the partial sums varies from run to run and a fit is no longer reproduced exactly by itsseed(the posterior is the same). A fit whose chains took over a minute on one core now says so and suggests"auto". -
fp_calibrate()documents that two chains per fit give an effective sample size of about 2000 and, with the chains of a fit run one after another as in a parallel calibration, half the cost of four. - Measured and not adopted (
dev/profile/rejected-2026-10-21.md): a dense mass matrix, sampling the false-positive intercept with the gap, a centred recorder effect, andreduce_sum_static(). Considered and not pursued, from the same measurements: initialization by Pathfinder (warm-up is 40% of the time) and a QR decomposition (no posterior correlation among covariate effects above 0.5). The confirmation design keeps its current likelihood path, for lack of a large dataset to measure it on. - With
random_fp = TRUE, 3 of 20 fits of the unstructured regime had an R-hat above 1.01 with the default settings; a warm-up of 2000 (2 of 20) oradapt_delta = 0.99(3 of 20) took longer for no clear gain, so the defaults stay.
Data
-
fp_read_validation()readsvalidation_by_clip.csvfrom ‘sheepdog’ 2.0.0 and later (English column names and verdicts:site,source_audio,clip_start,verdict = "positive", …) as well as the legacyvalidacao_por_clipe.csvof the sampler up to 1.2.0. The format is detected from the columns, and both give the same output, which now keepsoccasion_idwhen the file has it.
crywolf 1.5.0
Model options
All three are off by default; with them off, the draws are identical to those of crywolf 1.4.0.
-
fp_occu(ver = ~ ...)gives the verified method covariates of its own (from the verified table or the sites), reported asverified_*. - False-positive formulas can use covariates measured on each occasion (columns of the automated table), so the rate varies among the occasions of a site.
-
fp_occu(markov = "time")adds the detection on the previous occasion of the same site as a covariate of true detection (det_y_prev), for species recorded in runs. The previous occasion must be one time step earlier: after a gap (a missing occasion) a new run starts.simulate()simulates the runs in order, andfp_ppc()checks them one step ahead.
dev/validate-model-options.R checks the identity with 1.4.0 in three designs, compares the R likelihood used by fp_ppc(), fp_sites(), and simulate() with the Stan log_lik in six combinations of the options, and checks in simulations that each option’s effect is recovered; its output is in dev/validate-model-options.txt.
Checking and comparing models
-
fp_sbc(): simulation-based calibration of the computation (Talts et al. 2018; Modrák et al. 2025), with the log-likelihood of the data as a test quantity besides the parameters, andsummary()andplot(). -
loo(reloo = TRUE)refits the model without each site whose Pareto k exceeds a threshold and uses the exact leave-one-out value for it. A site that is the only one with its recorder, or with a level of a factor, keeps its approximate value, with a warning. -
fp_loo_weights(): stacking or pseudo-BMA weights of several fits. -
fp_gap_prior()turns the precision measured on a random sample of reviewed detections into a prior for the gap. -
predict(process = "fp")predicts for the automated occasions by default when the false-positive rate has occasion covariates. -
fp_threshold_sweep()fits the same model at several classifier thresholds and plots the estimates against the threshold.
crywolf 1.4.0
Plots and site-level estimates
-
plot()for fits draws the posterior intervals of the coefficients, one panel per process, or sampler diagnostics (type = "trace","rank","pairs", via ‘bayesplot’, with divergent transitions marked). -
fp_effects()gives the occupancy probability or the false-positive rate along one covariate, with the others at their means, and atransformargument for covariates standardized before fitting;plot()draws it. -
fp_sites()returns, for every site, the occupancy probability, the posterior probability that it is occupied given its data, and its false-positive rate;plot()ranks the sites or, with coordinates, maps them. -
plot()forfp_ppc()results: replicated against observed discrepancy, or the distribution of detections per site. -
fp_prior_predictive()simulates data from the priors with the design of the real data and compares simple summaries with the observed ones. -
plot()for calibrations can show verification effort as the expected number of verified sites or occasions, and mark a target coverage.
Reading classifier output
-
fp_read_birdnet()reads BirdNET selection tables (Raven format). -
fp_read_validation()reads the clip verdicts of the birdnet-validation-sampler. -
fp_aggregate()turns detections into automated occasions at a confidence threshold, and verdicts into counts for the observation-confirmation design, warning when a checked occasion has detections that were not reviewed. -
fp_data()warns about sites without automated occasions and about automated data that are all detections or all non-detections.
Other changes
- Fits keep every draw in memory, so a fit saved with
saveRDS()works in later sessions, after CmdStan’s temporary files are gone.
crywolf 1.3.0
Faster likelihood, same posterior
The Stan program evaluates the likelihood up to three times faster, with the log density, its gradient and log_lik unchanged up to floating-point rounding (checked in nine designs; scripts and results in dev/profile/ of the repository). Executables compiled by earlier versions are rebuilt once, and CmdStan 2.34 or later is now required.
- The unoccupied branch of each site is computed from its totals of automated occasions and detections, because the false-positive rate is constant within a site.
- When
dethas covariates, the occupied branch uses onebinomial_logit_glm_lpmf()call per site, which evaluates the linear predictor, the log-likelihood and its gradient in one pass instead of creating an autodiff variable per occasion. - With
random_fp = FALSEthe site effects on the false-positive rate enter as data rather than as parameters fixed at zero.
The gain grows with the number of occasion-level rows per site. Time per gradient evaluation with one thread, same parameter values:
| Data | Rows | 1.2.0 | 1.3.0 | Gain |
|---|---|---|---|---|
300 sites x 20 occasions, det = ~ 1 (rows collapsed) |
300 | 0.064 ms | 0.056 ms | 1.1x |
300 sites x 20 occasions, det = ~ bio + aci, recorder effect |
6,000 | 0.58 ms | 0.23 ms | 2.5x |
curiango, det = ~ bio + aci, recorder effect |
97,806 | 8.5 ms | 2.6 ms | 3.3x |
In a short run of the sampler on the curiango data (four chains), each leapfrog step took 2.3 times less with one thread and 2.6 times less with four threads per chain.
crywolf 1.2.0
-
fp_occu(random_fp = TRUE)adds a site random intercept to the logit of the false-positive rate, for rates that vary among sites in ways the covariates do not capture; its prior scale isfp_priors(fp_site_sd = ). It is off by default: it slows the fits and mixes less well, and it does not replace covariates when false positives follow an environmental gradient (see?fp_occu). With the option off, the draws are identical to those of crywolf 1.1.0. -
fp_calibrate_fit()checks the calibration of candidate models on data simulated from a fitted model, which keep the design of the real data (sites, covariates, occasions, recorders, and verification). -
simulate()method forfp_occufits, from the posterior means or from random posterior draws. - The summary of a calibration prints every occupancy slope, not only
occ_x.
crywolf 1.1.0
- The likelihood is summed over sites with Stan’s
reduce_sum(), and the model is compiled with threading, sofp_occu(threads_per_chain = )can split each chain among several cores. On the curiango data (97,806 automated occasions) a fit with four chains of four threads each took 16.5 minutes instead of 70, and each gradient evaluation was 2.7 times faster than with the previous model in a short benchmark on the same computer. The log density and its gradient are unchanged up to floating-point rounding, and the automated occasions usey * lp - n * log1p_exp(lp), an equivalent form of the binomial log-likelihood with half the transcendental functions. Executables compiled by earlier versions are rebuilt once.
crywolf 1.0.0
First release, accompanying the simulation study of Provete et al. (fpcalib research compendium, v0.1.0, doi:10.5281/zenodo.23379100).
Models
-
fp_occu()fits the multiple-methods false-positive occupancy model of Miller et al. (2011) in Stan, with any number of occupancy, detection, and false-positive covariates, an optional recorder random intercept, and configurable priors (fp_priors()).fp = NULLgives the standard occupancy model. - Observation-confirmation design of Chambert et al. (2015): argument
confirmedoffp_data()andfrac_confirmedofsimulate_fp(). - Methods
print,summary,coef,predict,loo, andas_draws_df. -
fp_ppc(): posterior predictive check with a Bayesian p-value.
Simulation and calibration
-
simulate_fp()generates homogeneous, unstructured, and structured false-positive regimes; with the same seed it returns the same datasets as the simulator of the fpcalib compendium. -
fp_calibrate()andfp_verification_curve()report the coverage and bias of credible intervals for a design, with aplot()method and a progress bar that shows the time remaining (needs ‘progressr’). They fit the recorder random intercept only when the simulated design has one, which avoids divergent transitions.
Data and documentation
-
curiangodataset: acoustic monitoring of the Common Pauraque in the Pantanal (Piatti et al. 2026). - Articles: introduction, simulation, calibration, a case study with the
curiangodata, coming fromunmarked::occuFP(), and the Stan model.