detectionCalculate {eDNAjoint} | R Documentation |
This function calculates the number of survey effort units to necessary detect species presence using median estimated parameter values from jointModel(). Detecting species presence is defined as producing at least one true positive eDNA detection or catching at least one individual. See more examples in the Package Vignette.
detectionCalculate(modelfit, mu, cov.val = NULL, probability = 0.9, qPCR.N = 3)
modelfit |
An object of class |
mu |
A numeric vector of species densities/capture rates. If multiple traditional gear types are represented in the model, mu is the catch rate of gear type 1. |
cov.val |
A numeric vector indicating the values of site-level covariates to use for prediction. Default is NULL. |
probability |
A numeric value indicating the probability of detecting presence. The default is 0.9. |
qPCR.N |
An integer indicating the number of qPCR replicates per eDNA sample. The default is 3. |
A summary table of survey efforts necessary to detect species presence, given mu, for each survey type.
Before fitting the model, this function checks to ensure that the function is possible given the inputs. These checks include:
Input model fit is an object of class 'stanfit'.
Input mu is a numeric vector.
Input probability is a univariate numeric value.
If model fit contains alpha, cov.val must be provided.
Input cov.val is numeric.
Input cov.val is the same length as the number of estimated covariates.
Input model fit has converged (i.e. no divergent transitions after warm-up).
If any of these checks fail, the function returns an error message.
# Ex. 1: Calculating necessary effort for detection with site-level
# covariates
# Load data
data(gobyData)
# Fit a model including 'Filter_time' and 'Salinity' site-level covariates
fit.cov <- jointModel(data = gobyData, cov = c('Filter_time','Salinity'),
family = "poisson", p10priors = c(1,20), q = FALSE,
multicore = FALSE)
# Calculate at the mean covariate values
# (covariates are standardized, so mean = 0)
detectionCalculate(fit.cov$model, mu = seq(from = 0.1, to = 1, by = 0.1),
cov.val = c(0,0), qPCR.N = 3)
# Calculate mu_critical at salinity 0.5 z-scores greater than the mean
detectionCalculate(fit.cov$model, mu = seq(from = 0.1, to = 1, by = 0.1),
cov.val = c(0,0.5), qPCR.N = 3)
# Ex. 2: Calculating necessary effort for detection with multiple traditional
# gear types
# Load data
data(greencrabData)
# Fit a model with no site-level covariates
fit.q <- jointModel(data = greencrabData, cov = NULL, family = "negbin",
p10priors = c(1,20), q = TRUE, multicore = FALSE)
# Calculate
detectionCalculate(fit.q$model, mu = seq(from = 0.1, to = 1, by = 0.1),
cov.val = NULL, qPCR.N = 3)
# Change probability of detecting presence to 0.95
detectionCalculate(fit.q$model, mu = 0.1, cov.val = NULL,
probability = 0.95, qPCR.N = 3)