Skip to contents

The recommended workflow to wrangle together data for analysis in wildrtrax is as follows. Once you have your data from wt_download_report().

# Start by getting everything you need
Sys.setenv(WT_USERNAME = 'guest', WT_PASSWORD = 'Apple123')
wt_auth()
my_report <- wt_download_report(project_id = 620, sensor_id = 'ARU', reports = "main", weather_cols = F)

Data wrangling

Let’s use some of the functins that are available to start cleaning up a data set. For this question, we don’t need certain abiotic and mammal codes so let’s remove those with wt_tidy_species(),

my_tidy_data <- wt_tidy_species(my_report, remove = c("mammal"), zerofill=F)

# Difference in rows
round((nrow(my_tidy_data)/nrow(my_report)),2)
#> [1] 0.85

So about 15% of detections were mammals. Next, convert TMTT (too many to tag) counts to numeric:

my_tmtt_data <- wt_replace_tmtt(data = my_tidy_data, calc = "round")

and finally, widen the data into a species matrix.

my_wide_data <- wt_make_wide(data = my_tmtt_data, sound = "all")

head(my_wide_data)
#> # A tibble: 6 × 77
#>   organization project_id location  location_id location_buffer_m longitude
#>   <chr>             <int> <chr>           <int>             <dbl>     <dbl>
#> 1 BU                  620 CHPP-WP-1       94515                NA     -110.
#> 2 BU                  620 CHPP-WP-1       94515                NA     -110.
#> 3 BU                  620 CHPP-WP-1       94515                NA     -110.
#> 4 BU                  620 CHPP-WP-1       94515                NA     -110.
#> 5 BU                  620 CHPP-WP-2       94518                NA     -110.
#> 6 BU                  620 CHPP-WP-2       94518                NA     -110.
#> # ℹ 71 more variables: latitude <dbl>, equipment_make <chr>,
#> #   equipment_model <chr>, recording_id <dbl>, recording_date_time <dttm>,
#> #   task_id <dbl>, aru_task_status <chr>, task_duration <dbl>,
#> #   task_method <chr>, AMCR <dbl>, AMRE <dbl>, AMRO <dbl>, BAOR <dbl>,
#> #   BBMA <dbl>, BCCH <dbl>, BHCO <dbl>, BHGR <dbl>, CANG <dbl>, CEDW <dbl>,
#> #   CHSP <dbl>, CONI <dbl>, COPO <dbl>, CORA <dbl>, COYE <dbl>, DEJU <dbl>,
#> #   DUFL <dbl>, EAPH <dbl>, GCKI <dbl>, GHOW <dbl>, HAWO <dbl>, LAZB <dbl>, …

Offsets

Now you can calculate statistical offsets to account for imperfect detection following the QPAD method. Ensure you have QPAD downloaded before proceeding and installed via devtools::install_github("psolymos/QPAD").

library(QPAD)

if (!requireNamespace("QPAD", quietly = TRUE)) {
  stop("QPAD package required for this vignette")
}

my_offset_data <- wt_qpad_offsets(data = my_wide_data, species = "all", version = 3, together = TRUE)

head(my_offset_data)

Occupancy modelling

You can also perform a single-season, single-species occupancy work flow using wt_format_occupancy() once the data is downloaded.

dat.occu <- wt_format_occupancy(my_report, species="WCSP", siteCovs=NULL)
mod <- unmarked::occu(~ 1 ~ 1, dat.occu)
mod
#> 
#> Call:
#> unmarked::occu(formula = ~1 ~ 1, data = dat.occu)
#> 
#> Occupancy (logit-scale):
#>  Estimate    SE    z P(>|z|)
#>      1.22 0.893 1.36   0.172
#> 
#> Detection (logit-scale):
#>  Estimate    SE      z P(>|z|)
#>    -0.297 0.333 -0.891   0.373
#> 
#> AIC: 66.07266 
#> Number of sites: 8