updateOccModel: Update a Multi-scale Occupancy Model

View source: R/updateeDNAoccModel.R

updateOccModelR Documentation

Update a Multi-scale Occupancy Model

Description

This function computes additional iterations of a Markov chain Monte Carlo algorithm that was used to fit a multi-scale occupancy model to a data set.

Usage

updateOccModel(fit, niter, niterInterval)

Arguments

fit

object of class occModel that contains data and previous state of the model's Markov chain

niter

no. iterations of MCMC algorithm

niterInterval

no. iterations for reporting progress of MCMC algorithm

Details

This function is used to update a multi-scale occupancy model fitted using occModel. The model is fitted using Bayesian methods (specifically, a Markov chain Monte Carlo (MCMC) algorithm that is run for a finite number of iterations). Output from the MCMC algorithm is stored in the file "mc.csv" and can be summarized using functions plotTrace, plotACF, and posteriorSummary.

Value

A list (object of class occModel) containing the following objects:

niterations:

total number of iterations MCMC algorithm was run

state:

the value of each model parameter after the last iteration of the MCMC algorithm

y:

M x J matrix of numbers of detections per sample

K:

M x J matrix of numbers of replicates per sample

X:

matrix of regressors associated with model parameter beta

W:

array of regressors associated with model parameter alpha

V:

array of regressors associated with model parameter delta

siteEffectInW:

logical indicator of whether model parameter alpha contains M elements (that is, one element per site)

colNamesOfX:

vector of names of regressors in X

colNamesOfW:

vector of names of regressors in W

colNamesOfV:

vector of names of regressors in V

where M = no. sites and J = maximum no. samples per site

See Also

occModel, scaleData

Examples

data(gobyDetectionData)
detections = occData(gobyDetectionData, "site", "sample")
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)


RobertDorazio/eDNAoccupancy documentation built on Sept. 5, 2023, 9:57 a.m.