abapToSpOcc_multi: ABAP to spOccupancy (multi-season)

View source: R/abapToSpOcc_multi.R

abapToSpOcc_multiR Documentation

ABAP to spOccupancy (multi-season)

Description

This function transforms a raw ABAP data frame (returned by getAbapData) into an list which can be used to fit single-species occupancy models using spPGOcc (spatial) or PGOcc (non-spatial). The spOccupancy package fits single-species, multi-species, and integrated non-spatial and spatial occupancy models using Markov Chain Monte Carlo (MCMC).

Usage

abapToSpOcc_multi(
  abap_data,
  pentads = NULL,
  proj_coords = TRUE,
  seasons = NULL
)

Arguments

abap_data

multi-season ABAP data downloaded using getAbapData.

pentads

an sf object returned by getRegionPentads. Defaults to NULL.

proj_coords

logical value indicating whether pentad coordinates are projected (TRUE) or kept in decimal degree format (FALSE). Defaults to TRUE. See details below for coordinate reference system used during transformation.

seasons

string indicating the name of the variable in abap_data that should be used to define seasons in multi-season models.

Details

The spPGOcc function takes coords as an argument with X and Y coordinates included for each site. Within the context of ABAP, these coords are the centroid of each sampling pentad. In order to provide these spatial data to this function, simply use getRegionPentads and provide the same inputs for .region_type and .region that are specified in corresponding getAbapData call. If proj_coords is set to TRUE then the coordinates will be transformed using the African Albers Equal Area coordinate system (see here for details). This projection is best suited for land masses extending in an east-to-west orientation at mid-latitudes making it suitable for projecting pentads in Southern Africa. The functions in the spOccupancy package assume that coordinates are projected so for best results it is recommended to always project the data.

If pentads are specified then the output can be automatically used in stPGOcc. If no spatial data are provided the output can be used in tPGOcc.

In addition to reformatting the detection/non-detection ABAP data for use in spOccupancy occupancy models, this function also extracts two survey-level covariates and adds them to the output list: hours and jday. The hours variable is the total number of hours spent atlassing which is recorded on the pentad card and jday is the Julian day corresponding to the first day of atlassing for that card.

Value

A list containing data necessary for model fitting in spOccupancy. List elements are y (detection/non-detection data), det.covs (survey-level covariates), and coords (x and y centroids of pentads if spatial data are supplied).

Author(s)

Dominic Henry dominic.henry@gmail.com
Pachi Cervantes

See Also

stPGOcc, tPGOcc

Examples

abap_data <- getAbapData(.spp_code = 212,
                         .region_type = "province",
                         .region = "Eastern Cape",
                         .years = 2012:2014)

abap_pentads <- getRegionPentads(.region_type = "province",
                                 .region = "Eastern Cape")
# We will use years as occupancy reference seasons
abap_data$year <- format(abap_data$StartDate, "%Y")

## Return list for spatial occupancy model
stOcc <- abapToSpOcc_multi(abap_data, abap_pentads, seasons = "year")
str(stOcc)

## Return list for spatial occupancy model (without coordinate projection)
stOcc <- abapToSpOcc_multi(abap_data, abap_pentads, proj_coords = FALSE, "year")
str(stOcc)

## List for non-spatial occupancy model
tOcc <- abapToSpOcc_multi(abap_data, seasons = "year")
str(tOcc)



AfricaBirdData/ABAP documentation built on Aug. 4, 2024, 4:41 p.m.