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
)

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

integer(1) Maximum duration of the survey (in days, e.g. "7")

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")

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

datetime_primary

Timestamp of survey start (primary observation)

...

Any covariate attached to the dataset