fitjsodm: Fit detection occupancy models using runjags.

View source: R/fitjsodm2.R

fitjsodmR Documentation

Fit detection occupancy models using runjags.

Description

Fit detection occupancy models using runjags.

Usage

fitjsodm(
  Xocc,
  Xobs,
  y,
  ModelSite,
  modeltype,
  ...,
  initsfunction = get0(paste0("paraminits.", modeltype)),
  MCMCparams = list(n.chains = 1, adapt = 2000, burnin = 25000, sample = 1000, thin =
    30),
  filename = NULL
)

Arguments

Xocc

A dataframe of covariates related to occupancy. One row per ModelSite. Must also include the ModelSiteVars columns to uniquely specify ModelSite.

ModelSite

A list of column names in y, Xocc and Xobs that uniquely specify the ModelSite. Can be simply a ModelSite index

MCMCparams

A named list containing values for n.chains, adapt, burnin, sample and thin (to pass to run.jags). Also include keep.jags.files to specify the directory that JAGS data will be saved.

filename

If non-null the runjags object (with some extra information) is saved to filename as an RDS.

yXobs

A dataframe of species observations (1 or 0) and covariates related to observations. One row per visit. Each column is either a covariate or a species. Must also include the ModelSiteVars columns to uniquely specify ModelSite.

species

A list of species names (corresponding to columns of yXobs) to model.

OccFmla

A formula specifying the occupancy model in terms of the covariates in Xocc.

ObsFmla

A formula specifying the model for detection in terms of the covariates in Xobs.

nlv

The number of latent variables

Value

A runjags object with some modifications:

  • the data slot is a in list.format, converted using as_list_format()

  • elements in the data slot have dimension names given by the input data frames

  • the slot XoccProcess is the process used to prepare the occupancy covariates (scaling and centering). It can be applied using apply.designmatprocess()

  • the slot XobsProcess is the process used to prepare the detection covariates (scaling and centering). It can be applied using apply.designmatprocess()

  • ModelSite slot is the list with values for each visit (row in detection covariates) giving the row of the ModelSite in the occupancy covariates.

  • species slot is the list of species names.


sustainablefarms/msod documentation built on March 6, 2023, 7:17 a.m.