knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

This vignette presents :

  1. Data preparation
  2. CDS analysis
  3. Kriging

1. Data Preparation

Analysis are performed on data collected with SAMMOA software. This software allows observers to collect data while there are in aircraft or on boat. The outputs of this software are structured as below:

library(geffaeR)
library(dplyr)
library(DT)
library(htmltools)
div(
  observation_example %>% 
    datatable(options = list(pageLength = 5, scrollX = T), width = 700)
)
library(geffaeR)
library(dplyr)
library(DT)
library(htmltools)
div(
  effort_example %>% 
    datatable(options = list(pageLength = 5, scrollX = T), width = 700)
)



1.1 Change column names

To perform analysis on thoose data, it is necessary to modify its column name to match the need of packages (Distance, dsm). To do so, there are 2 functions change_effort_varName() and change_obs_varName().

standard_effort <- change_effort_varName(effort_example)
standard_obs <- change_obs_varName(observation_example)

1.2 verify matching between observation and effort

A facultative step can be added at this stage of the analysis. We can perform a verification to be sure that each observation have a corresponding values in the effort data. To do so, it is necessary to give which column we want to verifiy if they have their equivalent in effort.

colum_to_test <- c("segId","legId")
verif_effort_obs(
  var = colum_to_test,
  standard_obs = standard_obs,
  standard_effort = standard_effort
)

This means that for "segId" and "legId" all values of observation data have an equivalent in effort data with non missing values.

1.2 Change data format

Then, it is necessary to modify the data structure in a way to have the proper sub-dataframe for distance function. For this, effort dataframe is devided into 2 sub-dataframes :

knitr::include_graphics("effort_schema_prepare_data.png")
prepared_effort <- prepare_data_effort(effort_base = standard_effort, 
                                       shape = shape_example,
                                       optimal = T,
                                       block_area = data.frame(Block = c("ATL_N"), 
                                                               Area = c(shape_example$area)), 
                                       New_projection = lbrt93_proj,
                                       covariable = NULL)
str(prepared_effort)

Observation dataframe is splitted into 4 sub-dataframes.

sp1 <- unique(observation_example$species)[1]
legdata <- prepared_effort$legdata
segdata <- prepared_effort$segdata
# Projection used for shape (shape_example in this case)
projection <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

observation_output_TURTRU <- prepare_data_obs(sp = sp1, 
                                              obs_base = standard_obs, 
                                              legdata = legdata, 
                                              segdata = segdata, 
                                              shape = shape_example, 
                                              shape_layer = shape_layer, 
                                              projection = projection
                                              )
str(observation_output_TURTRU)

2. Cds analysis

2.1 Case of non seabird

After preparing and formatting the data, the next step consist in adjusting a detection function on the data with the function plot_detection(). It is possible to choose between a half-normal function or hazard-rate one. It is necessary to inform the distance between which we want to apply the detection function.

detection_TURTRU <- plot_detection(distdata = observation_output_TURTRU$distdata,
                                   bin = seq(0.0,1.0, 0.05),
                                   key = "halfnorm",
                                   upper = 1.0,
                                   is_seabird = F)

This function as several outputs, it gives : the esw (effective strip width),

detection_TURTRU$esw

its coefficient of variation (CV),

detection_TURTRU$esw_cv

the output of distance function from the package Distance

detection_TURTRU$distFit
summary(detection_TURTRU$distFit)

and gives the detetction plot, on the graph the red-dashed line correspond to the effective strip width (esw)

detection_TURTRU$graph

2.2 Case of seabird

For Seabirds a strip-transect is applied, that means there is no distance assigned for seabirds observation, it is set to 0.2km. To apply a detection function, it is necessary to "hack" the method for estimating seabirds abundance. The "hacking" method consist in setting distance of observation as 0 or 0.2km with a sample function. There will be as many 0 as there are 0.2 in the distance column. That means from a distance of 0 to 0.2km all seabirds will be detected. Then the detection function is a uniform function from 0 to 0.2km with a detection probability of 1.

sp2 <- unique(observation_example$species)[2]
legdata <- prepared_effort$legdata
segdata <- prepared_effort$segdata
projection <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

observation_output_LARMEL <- prepare_data_obs(sp = sp2, 
                                              obs_base = standard_obs, 
                                              legdata = legdata, 
                                              segdata = segdata, 
                                              shape = shape_example, 
                                              shape_layer = shape_layer, 
                                              projection = projection)
temp <- observation_output_LARMEL$distdata

fit <- plot_detection(temp,
                      is_seabird = T)
plot(fit$distFit)


MathieuGenu/geffaeR documentation built on March 23, 2022, 7:50 p.m.