Package 'multiocc'

Title: Fits Multivariate Spatio-Temporal Occupancy Model
Description: Spatio-temporal multivariate occupancy models can handle multiple species in occupancy models. This method for fitting such models is described in Hepler and Erhardt (2021) "A spatiotemporal model for multivariate occupancy data" <https://onlinelibrary.wiley.com/doi/abs/10.1002/env.2657>.
Authors: Staci Hepler [aut, cre], Rob Erhardt [aut]
Maintainer: Staci Hepler <[email protected]>
License: GPL-2
Version: 0.2.0
Built: 2024-11-20 04:05:26 UTC
Source: https://github.com/heplersa/multiocc

Help Index


Coords

Description

site by x coordinate by y coordinate

Usage

data(coords)

Format

An object of class data.frame with 267 rows and 3 columns.


Detection

Description

site by season by survey, for six species. Also contains the standardized covariate duration.

Usage

data(detection)

Format

An object of class data.frame with 8010 rows and 10 columns.


This function runs the MCMC.

Description

This function runs the MCMC.

Usage

GibbsSampler(
  M.iter,
  M.burn = NULL,
  M.thin = NULL,
  model.input,
  q = NULL,
  sv = FALSE,
  every = 1000,
  WAIC = FALSE,
  param2keep = c("alpha", "beta", "gamma", "rho", "sigma", "psi")
)

Arguments

M.iter

The total number of iterations in MCMC

M.burn

The length of the burn in

M.thin

The number to thin the chain. Thinning by 10 only stores every 10th run.

model.input

A list of output created by running the create.data.R function

q

Desired number of Moran's I basis functions in the restricted spatial regression model

sv

A TRUE/FALSE on whether or not the MCMC output should be saved as 'MCMC.Rdata' and overwritten every 1000 iterations. Defaults to false.

every

A number to determine how frequently MCMC output is saved along the chain. Defaults to 1000.

WAIC

A TRUE/FALSE on whether or not the MCMC should compute and save WAIC. Defaults to false.

param2keep

A character vector that governs which outputs are saved. Permissible entries are "alpha", "beta", "gamma", "rho", "sigma", "psi", "z", "p", and "loglik"

Value

A list with all standard MCMC output

Examples

head(detection)
head(occupancy)
head(coords)
DataNames = list("species"=colnames(detection)[4:9],
"detection"=c("duration"),"occupancy"=c("forest","elev"))
model.input = multioccbuild(detection, occupancy, coords, DataNames, threshold = 15000)
out = GibbsSampler(M.iter=3, M.burn=1, M.thin=1, model.input, q=10, sv=FALSE)

This function constructs basis functions. It assumes coordinates form a metric.

Description

This function constructs basis functions. It assumes coordinates form a metric.

Usage

MakeBasis(q = q, model.input)

Arguments

q

The desired number of basis functions. Must be an integer greater than or equal to 1.

model.input

A list of output created by running the create.data.R function

Value

A list with

  • K spatial basis functions

  • KtQK which is literally the matrix operation transpose(K) times Q times K, and is the variance of the multivariate #' random effect gamma.


This function creates model.input for the GibbsSampler() function

Description

This function creates model.input for the GibbsSampler() function

Usage

multioccbuild(detection, occupancy, coords, DataNames, threshold)

Arguments

detection

A data frame that has one row for every site X season X survey combination. Must contain columns exactly named 'site', 'season', and 'survey' within season. Must also contain all covaraites in the detection process of the model, and binary indicators of detections for all species to be modeled. It is permissible for this data frame to have columns for species and/or variables that will not be used in model.

occupancy

A data frame that is one row for every site x season combination. Must contain columns for the 'site' and 'season', and these must be named 'site' and 'season' exactly. Also must contain all covariates to be used in the latent occupancy process of the model. It is permissible for this data frame to have columns for species and/or variables that will not be used in model.

coords

A data frame that is one row for every site included in the study. Contains columns for the 'site', and location coordinates x and y. These are used to output the adjacency matrix A based on Euclidean distance threshold the user provides as an input in the 'DataNames' argument.

DataNames

A list with elements "species", "detection", and "occupancy" DataNames$species is a vector with the name of every species to be included in the model. Must be a subset of names of columns of 'detection'. DataNames$detection is a vector with the names of the detection covariates to be included in the model. These names must be a subset of column names of 'detection'. DataNames$occupancy is a vector with the names of the occupancy covariates to be included in the model. These names must be a subset of column names of 'occupancy'.

This list 'DataNames' is required because it: (1) allows for modeling subsets of species and/or variables in varioys input data frames, which means the user does not need to modify either data frame for different runs of the model. (2) this list also determines the order of covariates in X and W.

threshold

The distance which determines if two locations are neighbors in the adjacency matrix or not. This threshold is the Euclidean distance based on the x and y coordinates input in 'coords'.

Value

model.input a list with

  • DataNames, the list with elements "species", "detection", and "occupancy".

  • X, the design matrix for occupancy. Contains a column of 1s for the intercept, and one column for each variable in names$occupancy.

  • W, design matrix for detection. Contains a column of 1s for the intercept, and one column for each variable in names$detection.

  • y, observed occupancy data. Contains one column for each species listed in names$species.

  • A, the adjacency matrix containing either a 0 or 1 indicating if two locations are neighbors based on their distances and the 'threshold' argument.

  • detection.info, details for detection.

  • occupancy.info, details for occupancy.


Occupancy

Description

site by season with covariate forest (standardized percentage forest cover) and elevation (standardized).

Usage

data(occupancy)

Format

An object of class data.frame with 2670 rows and 4 columns.