Takes a camera trap dataset as input (site ID, timestamp and species name) and return a recurrent event dataset. The function creates a survey after each observation of the primary species for a defined maximum duration. Within each survey, all the observations of the secondary species are converted into recurrent events. The returned dataframe can be directly used for recurrent event analysis.

ct_to_recurrent(
  data,
  primary,
  secondary,
  survey_duration = 10,
  datetime_var = "DateTime",
  species_var = "Species",
  site_var = "Site",
  tertiary = NULL,
  survey_end_date = NULL,
  time_unit = "days"
)

Arguments

data

A dataframe containing the site, the timestamp and the species information

primary

character A vector of one or several species names considered to affect the secondary species

secondary

character(1) Name of the species affected by the primary (only one name allowed).

survey_duration

numeric(1) Maximum duration of the survey in the unit specified by time_unit (e.g. 7 for 7 days or 48 for 48 hours).

datetime_var

Name of the variable that contains date time information.

species_var

character(1) Name of the variable that contains species information.

site_var

Name of the variable that contains Site ID.

tertiary

character Names of the species in species_var that should not be considere primary or secondary.

survey_end_date

Date Date of study end (e.g. "01-01-2001")

time_unit

character(1) Time unit for survey_duration and the resulting t.start/t.stop columns. One of "days" (default), "hours", "mins", "secs", or "weeks".

Value

A dataframe containing:

Site

Camera-trap site ID

ID

Survey ID

primary

primary species starting the survey

datetime_primary

Timestamp of the start of the survey (i.e. of the primary species observation)

DateTime

Timestamp of the recurrent event (i.e. of the secondary species observation)

t.start

Time since the start of the survey

t.stop

Time since the last event, which can be the primary species or a previous secondary species

event

Binary, 1 = recurrent event, 0 = censoring event

enum

Event number within the survey

Event_type

Either the recurrent event, giving the name of the secondary species, or a censoring event and the reason of censoring

...

Any covariate attached to the dataset