occModel | R Documentation |
This function specifies and fits a multi-scale occupancy model.
occModel(formulaSite = ~1, formulaSiteAndSample = ~1,
formulaReplicate = ~1, detectionMats, siteData = NULL,
siteAndSampleData = NULL, niter = 1100, niterInterval = 100,
siteColName = "site", sampleColName = "sample")
formulaSite |
model of occurrence at a site |
formulaSiteAndSample |
model of occurrence in different samples of a site |
formulaReplicate |
model of detection in replicates of a sample |
detectionMats |
list containing
where M = no. sites and J = maximum no. samples per site |
siteData |
data frame containing site-level covariates |
siteAndSampleData |
data frame containing site- and sample-level covariates |
niter |
no. iterations of MCMC algorithm |
niterInterval |
no. iterations for reporting progress of MCMC algorithm |
siteColName |
column of data frame siteData (or column of data frame siteAndSampleData) containing sites (i.e., primary sample units) |
sampleColName |
column of data frame siteData (or column of data frame siteAndSampleData) containing sample numbers (i.e., integers 1, 2, ...) for each site |
This function is used to specify and fit a multi-scale occupancy model (with or without covariates). The model is fitted using Bayesian methods (specifically, a Markov chain Monte Carlo (MCMC) algorithm that is run for a finite number of iterations). Additional MCMC iterations may be computed using the function updateOccModel
. Output from the MCMC algorithm is stored in the file "mc.csv" and can be summarized using functions plotTrace
, plotACF
, and posteriorSummary
.
A list (object of class occModel) containing the following objects:
total number of iterations MCMC algorithm was run
the value of each model parameter after the last iteration of the MCMC algorithm
M x J matrix of numbers of detections per sample
M x J matrix of numbers of replicates per sample
matrix of regressors associated with model parameter beta
array of regressors associated with model parameter alpha
array of regressors associated with model parameter delta
logical indicator of whether model parameter alpha contains M elements (that is, one element per site)
vector of names of regressors in X
vector of names of regressors in W
vector of names of regressors in V
where M = no. sites and J = maximum no. samples per site
Before fitting the model, this function checks to ensure that the model specification is possible given the data files. These checks include:
Value of siteColName matches that in data frame siteData.
Values of siteColName and sampleColName match those in data frame siteAndSampleData.
Values in sampleColName contain consecutive positive integers (1, 2, ...) for each site.
Only one data frame (siteData or siteAndSampleData) is specified for survey data.
If any of these checks fail, the function returns an error message.
updateOccModel
, scaleData
data(gobyDetectionData)
detections = occData(gobyDetectionData, "site", "sample")
# Fit a model without covariates of occurrence or detection.
fit.simplest = occModel(detectionMats=detections)
# Fit a model which assumes that probability of occurrence in samples differs with site,
# but the differences are not a function of site-level covariates.
data(gobySurveyData)
fit = occModel(~1, ~factor(site)-1, ~1,
detectionMats=detections,
siteData=gobySurveyData,
siteColName="site")
# Fit a model assuming occurrence and detection probabilities
# are functions of site-level covariates.
data(gobySurveyData)
gobySurveyData = scaleData(gobySurveyData) # center and scale numeric covariates
fit1 = occModel(formulaSite = ~ veg,
formulaSiteAndSample = ~ sal + twg,
formulaReplicate = ~ sal + fish,
detectionMats = detections,
siteData = gobySurveyData,
niter = 110,
niterInterval = 10,
siteColName = 'site',
)
# Update the Markov chain of the model specified in fit1
fit2 = updateOccModel(fit1, niter=50, niterInterval=10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.