occ_mod: Fit the single species, single season site occupancy model.

Description Usage Arguments Details Value Examples

View source: R/occ_functions.R

Description

This function fits the single species, single season site occupancy model first developed by MacKenzie et al. (2002).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
occ_mod(
  occupancy,
  detection,
  data,
  niter = 1000,
  nchains = 3,
  seed = NULL,
  save_model = FALSE,
  model_name = paste0("occ_model_", Sys.Date()),
  beta_prior = "dnorm(0, 1/2)"
)

Arguments

occupancy

model declaration for the occupancy portion of the model using standard linear model syntax

detection

model declaration for the detection portion of the model using standard linear model syntax

data

data from which to create the detection and covariate matrices. Each row should represent a single visit to a site. See details and examples for proper formatting

niter

number of MCMC iterations

nchains

number of MCMC chains

seed

optional seed

save_model

logical; should a text file containing the model be exported?

model_name

character string defining the name of the text file describing the model if save_model = TRUE

beta_prior

character string defining prior distribution for regression coefficients at the occupancy and detection levels. Priors should be specified using distributions available in NIMBLE. See available distributons in NIMBLE

Details

This function fits the single season, single species site occupancy model using the logit link function. The data should contain columns named site, visit, and y. See examples.

Value

an object of class list containing the following:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# simulate data
sim <- sim_occ(M = 100, max_j = 10, seed = 01012021, rand_visits = FALSE)
data <- sim$data

# note structure of data frame
names(data)
head(data)

# fit model
ex <- occ_mod(occupancy = ~ psi_cov1, detection = ~ p_cov1, data = data,
              niter = 4000, beta_prior = "dunif(-5, -2)")

# results
ex
summary(ex)
str(ex)

StrattonCh/occupancy documentation built on Feb. 17, 2021, 6:36 a.m.