Fit eDNA model
eDNA_lm(
formula,
data,
std_curve_alpha,
std_curve_beta,
upper_Cq = 40,
prior_intercept = normal(location = -15, scale = 10),
priors = normal(),
...
)eDNA_lmer(
formula,
data,
std_curve_alpha,
std_curve_beta,
upper_Cq = 40,
prior_intercept = normal(location = -15, scale = 10),
priors = normal(),
prior_random_variance = exponential(),
...
)
eDNA_zinf_lm(
formula,
data,
std_curve_alpha,
std_curve_beta,
upper_Cq = 40,
probability_zero = 0.08,
prior_intercept = normal(location = -15, scale = 10),
priors = normal(),
...
)
eDNA_zinf_lmer(
formula,
data,
std_curve_alpha,
std_curve_beta,
upper_Cq = 40,
probability_zero = 0.08,
prior_intercept = normal(location = -15, scale = 10),
priors = normal(),
prior_random_variance = exponential(),
...
)
a formula, specifying the relationship between the predictors and the latent variable eDNA concentration.
data.frame, with the response and predictors
the alpha (intercept) value for the formula for converting between log(eDNA concentration) and CQ value
the beta (slope) value for the formula for converting between log(eDNA concentration) and CQ value
numeric, the upper limit on CQ detection. Any value of log(concentration) which would result in a value greater than this limit is instead recorded as the limit.
named list such as created by
rstanarm::normal
. The list must contain elements named
"location" and "scale", which are the location and scale for a
normal prior over the intercept. Ignored when the intercept is
omitted in the model formula.
named list such as created by
rstanarm::normal
. The list must contain elements named
"location" and "scale", which are the location and scale for a
normal prior over the betas, and "autoscale". If a single
value is provided, this value will be repeated for each
beta. If autoscale = TRUE
, the scale of the priors is
scaled by the sd of the predictors similar to rstanarm handles
them.
additional arguments passed to
sampling
the prior on variance of the random effects. Defaults to exponential distribution with rate 1.
numeric, between 0 and 1. The probability of a non-detection from a source other than low concentration of eDNA, e.g. a filter failure. Defaults to 8 was the estimated p(zero) from a daily sampling experiment.
S4 object, with the following slots:
matrix, the posterior samples for the latent variable, eDNA concentration
matrix, the posterior prediction for the observed response
array, the posterior estimates for the betas for the linear model
array, the posterior estimates for the measurement error of ln_eDNA
formula, the original formula used in the model
data.frame, the model matrix used in the model
numeric, the std. curve intercept value used
numeric, the std. curve slope value used
numeric, the upper limit for observed CQ used
stanfit, the original results from
rstan::sampling
The models have been written in Stan with key focus on robustness
and speed. However, it is possible that users might encounter
issues. Typically, these issues will be highlighted by warning
messages coming from rstan::sampling
. Often times, these
warnings can be resolved by increasing the number of iterations
that the HMC algorithm runs by specifying iters
to be a
larger value. This should be the first action attempted, as
increasing the iters
increases both the warm-up and
sampling iterations. If users continue to have issues, additional
control arguments can be passed to rstan::sampling
via the
...
argument.
These functions fit a Bayesian latent variable model to data collected from a eDNA sampling experiment. These data have a few particular characteristics that justify using a specialized model. More details on these characteristics and the model structure, please refer to the "Getting Started" vignette for the artemis package.
There are four different modeling functions in the artemis
package, eDNA_lm
, eDNA_lmer
, eDNA_zinf_lm
,
eDNA_zinf_lmer
. eDNA_lm
is for fitting a fixed
effects model, while eDNA_lmer
is for fitting a mixed or
random effects model. The *_zinf versions implement a
zero-inflated version of their respective lm function. All models
are fit using the rstan::sampling
function, which uses a
Hamiltonian Monte Carlo algorithm to estimate parameters for the
model. Users are encouraged to refer to the documentation for Stan
and RStan at https://mc-stan.org/users/documentation/ for
details about how models are fit.
# NOT RUN {
## Fixed effect model
ans = eDNA_lm(Cq ~ Distance_m, eDNA_data,
std_curve_alpha = 21.2, std_curve_beta = -1.5)
# }
# NOT RUN {
## Mixed-effect model
## This takes a while to run
ans2 = eDNA_lmer(Cq ~ Distance_m + (1|FilterID), eDNA_data,
std_curve_alpha = 21.2, std_curve_beta = -1.5)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab