Skip to contents

Collects the automated detections, the verified detections, and the site table into one object that fp_occu() can fit. All tables are in long format, one row per occasion, which accommodates unequal numbers of occasions per site without padding. Use fp_data_wide() if your data are detection matrices, as in 'unmarked'.

Usage

fp_data(
  auto,
  sites,
  verified = NULL,
  site = "site",
  y = "y",
  recorder = NULL,
  confirmed = NULL,
  season = NULL,
  season_covs = NULL,
  species = NULL
)

Arguments

auto

Data frame of the automated method (the one that can return false positives), one row per site and occasion. It needs a site column and a 0/1 detection column, and may hold observation covariates for the true-detection process and a recorder (or observer) identifier.

sites

Data frame with one row per site: the site identifier plus any site covariates used in the occupancy (occ) or false-positive (fp) formulas of fp_occu(). Sites with no automated occasions are allowed and contribute only through their verified data, if any.

verified

Optional data frame of the verified method (detections checked by an expert and therefore free of false positives), one row per site and occasion, with the same site and detection columns. Without it the false-positive rate is identified only by the priors, and fp_occu() warns about it.

site, y

Names of the site and detection columns, shared by all tables. Detections are 0/1, given as numbers, logicals, the strings "0" and "1", or a factor with those labels (read by its labels, not its level codes); rows with a missing detection are dropped.

recorder

Optional name of a column of auto that identifies the recorder or observer, used for a random intercept on true detection.

confirmed

Optional names of two columns of auto holding, for the occasions whose observations were checked by an expert, the number of observations confirmed as the target species and the number confirmed as something else, in that order (the observation-confirmation design of Chambert et al. 2015). Use NA in both for occasions that were not checked. All observations of a checked occasion must have been checked, so an occasion with a detection has at least one confirmed observation, and one without has none. See Details of fp_occu().

season

Optional name of a column of auto (and of verified, if given) holding the season, or primary period, of each occasion, for the dynamic model. Seasons are ordered by the levels of a factor, and otherwise by sorting their values, so numbers, dates and ISO dates as text (such as night or recording_date of a 'sheepdog' export) all work. When the seasons are dates (Date, or text as YYYY-MM-DD or YYYYMMDD), the dates missing between the first and the last are added as seasons without data, in steps of the shortest interval between seasons, so that every transition spans the same time (one night, for nightly seasons, even when no site recorded on some nights). Other seasons (numbers, factors, other text) are taken as they come: consecutive seasons are one transition apart, whatever the time between them. A site without data in a season contributes to that season only through the transitions of its occupancy state. fp_occu() ignores this column.

season_covs

Optional data frame of covariates of the seasons, for the colonization, extinction and initial occupancy formulas of fp_occu_dyn() (and its detection and false-positive formulas). It has the season column named by season and, for covariates that vary among sites too, the site column; one row per season, or per site and season. Seasons added between dates need rows only if a formula uses them.

species

Optional name of a column of auto (and of verified, if given) holding the species, for the multispecies model fp_occu_ms(). The tables are then in long format by species too: one row per occasion and species, with every surveyed occasion present for every species (y = 0 where the species was not detected), since the non-detections are data. The species are the levels of a factor, and otherwise the sorted values of auto and verified. It cannot be combined with season yet, and the single-species models refuse such data.

Value

An object of class fp_data: a list with the tables auto, verified and sites (rows with a missing detection dropped), the column names site, y, recorder, confirmed and season, the vector known_present, which flags sites with at least one verified detection or confirmed true observation, and, with season, the seasons in time order in seasons, the step between dates in days in season_step (NULL for seasons that are not dates) and the table season_covs. With species, the species in species_names, and known_present is a matrix of sites by species.

Details

Besides errors for data that cannot be fitted, fp_data() warns about data that can be fitted but are probably not what was meant: sites with no automated occasion (often a failed join of auto and sites), very unequal automated effort among sites (ten times or more), automated occasions that are all detections or all non-detections, verified data without any detection, and confirmed occasions without any false observation. With season, it also warns about seasons without data at any site (unused levels of a factor, or dates added between the first and the last), about seasons without verified or confirmed data, in which colonization and extinction are hard to tell from false positives, and about seasons at unequal intervals that could not be filled in. With species, it warns about species never detected by the automated method, species without any verified detection, whose false-positive rates are then informed only by the other species and the priors, and sites where the species have unequal numbers of occasions (often occasions without a detection left out for some species). With verified and confirmed, it warns about occasions present in verified and as confirmed rows of auto, which enter the likelihood twice. That is correct only for two independent reviews, not for one verdict copied to both tables. Occasions are compared by site and occasion_id, and also by species with species and by season with season, only when both tables have an occasion_id column. fp_aggregate() builds auto from classifier output.

Missing values. A missing detection (NA in y) marks an occasion that was not surveyed (or, in verified, not checked), so its row is dropped: an unsurveyed occasion carries no information about detection, and the occupancy likelihood is the same with or without it. No other missing value is dropped or imputed. Missing recorders, seasons or species stop with an error here, and missing covariates stop the fit in fp_occu(), because the model cannot tell how they arose.

References

Chambert, T., Miller, D. A. W., & Nichols, J. D. (2015). Modeling false positive detections in species occurrence data under different study designs. Ecology, 96, 332–339. doi:10.1890/14-1507.1

Examples

sim <- simulate_fp(nsite = 50, nocc = 5, seed = 1)
sim$data
#> <fp_data>
#>   sites:                  50
#>   automated occasions:    250 (naive occupancy 0.68)
#>   verified sites:         18 (54 occasions; verified detections at 10 sites)
#>   sites known occupied:   10
#>   recorders:              5
#>   site covariates:        x, w 
#>   observation covariates: bio, aci 

# the same structure built by hand
d <- fp_data(auto = sim$data$auto, sites = sim$data$sites,
             verified = sim$data$verified, recorder = "recorder")
d
#> <fp_data>
#>   sites:                  50
#>   automated occasions:    250 (naive occupancy 0.68)
#>   verified sites:         18 (54 occasions; verified detections at 10 sites)
#>   sites known occupied:   10
#>   recorders:              5
#>   site covariates:        x, w 
#>   observation covariates: bio, aci