muCritical {eDNAjoint}R Documentation

Calculate mu_critical

Description

This function uses the full posterior distributions of parameters estimated by jointModel() to calculate mu_critical, or the expected catch rate at which the probabilities of a false positive eDNA detection and true positive eDNA detection are equal. See more examples in the Package Vignette.

Usage

muCritical(modelfit, cov.val = NULL, ci = 0.9)

Arguments

modelfit

An object of class stanfit

cov.val

A numeric vector indicating the values of site-level covariates to use for prediction. Default is NULL.

ci

Credible interval calculated using highest density interval (HDI). Default is 0.9 (i.e., 90% credible interval).

Value

A list with median mu_critical and lower and upper bounds on the credible interval. If multiple gear types are used, a table of mu_critical and lower and upper credible interval bounds is returned with one column for each gear type.

Note

Before fitting the model, this function checks to ensure that the function is possible given the inputs. These checks include:

If any of these checks fail, the function returns an error message.

Examples


# Ex. 1: Calculating mu_critical 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 mu_critical at the mean covariate values (covariates are
# standardized, so mean = 0)
muCritical(fit.cov$model, cov.val = c(0,0), ci = 0.9)

# Calculate mu_critical at habitat size 0.5 z-scores greater than the mean
muCritical(fit.cov$model, cov.val = c(0,0.5), ci = 0.9)

# Ex. 2: Calculating mu_critical 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 mu_critical
muCritical(fit.q$model, cov.val = NULL, ci = 0.9)



[Package eDNAjoint version 0.2 Index]