# \donttest{
# Ex. 1: Implementing the joint model
# Load data
data(goby_data)
# Examine data in list
names(goby_data)
# Note that the surveyed sites (rows) should match in all data
dim(goby_data$pcr_n)[1]
dim(goby_data$count)[1]
# Fit a basic model with paired eDNA and traditional survey data.
# Count data is modeled using a poisson distribution.
fit <- joint_model(data = goby_data, family = "poisson",
p10_priors = c(1, 20),
multicore = FALSE)
# Ex. 2: Implementing the joint model with site-level covariates
# With the same data, fit a model including 'Filter_time' and 'Salinity'
# site-level covariates
# These covariates will scale the sensitivity of eDNA sampling relative to
# traditional surveys
# Count data is modeled using a poisson distribution.
fit_cov <- joint_model(data = goby_data, cov = c('Filter_time','Salinity'),
family = "poisson", p10_priors = c(1, 20),
multicore = FALSE)
# Ex. 3: Implementing the joint model with multiple traditional gear types
# Load data
data(green_crab_data)
# Examine data in list
names(green_crab_data)
# Note that the surveyed sites (rows) should match in all data
dim(green_crab_data$pcr_n)[1]
dim(green_crab_data$count)[1]
# Fit a model estimating a gear scaling coefficient for traditional survey
# gear types.
# This model does not assume all traditional survey methods have the same
# catchability.
# Count data is modeled using a negative binomial distribution.
fit_q <- joint_model(data = green_crab_data, cov = NULL, family = "negbin",
p10_priors = c(1, 20), q = TRUE,
phi_priors = c(0.25, 0.25),
multicore = FALSE, initial_values = NULL,
n_chain = 4, n_warmup = 500,
n_iter = 3000, thin = 1, adapt_delta = 0.9,
verbose = TRUE, seed = 123)
# }
Run the code above in your browser using DataLab