Species richness of each site from a multispecies model
Source:R/fp_occu_ms-outputs.R
fp_richness.RdCounts, for each site, the species of an fp_occu_ms() model that are
present, from the posterior of the occupancy state of every species at
the site. In development, as fp_occu_ms().
Value
A data frame, one row per site, with the site columns of the data,
richness (posterior mean number of species present, with
richness_lower and richness_upper, quantiles of its posterior
distribution), richness_psi (expected number of species from the
occupancy covariates alone, before the data of the site), detected
(number of species with automated detections) and verified (number of
species whose presence a verified detection proves).
Details
For each posterior draw, the state of each species at each site is drawn
from its conditional posterior given the data of that species at that site
(as in fp_sites()), and the richness of the site is the number of
species drawn as present. The species are those of the model: a species
never detected anywhere is not in the list and is not counted.
Examples
# \donttest{
s <- simulate_fp_ms(nspecies = 5, nsite = 60, seed = 1)
m <- fp_occu_ms(s$data, occ = ~ x, det = ~ bio, random_recorder = FALSE,
chains = 2, threads_per_chain = 1)
#> Parametrization (5 species at 60 sites): centered = FALSE, centered_occ = FALSE; see ?fp_occu_ms.
#> Running MCMC with 2 parallel chains, with 1 thread(s) per chain...
#>
#> Chain 1 finished in 147.1 seconds.
#> Chain 2 finished in 149.4 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 148.3 seconds.
#> Total execution time: 149.5 seconds.
#>
r <- fp_richness(m)
plot(rowSums(s$truth$z), r$richness)
# }