Skip to content

Following releases and days don't work correctly for the extraction of adult surveys when there are multiple releases

library(tidyverse)
library(sit)

(
  surv_prototype <- sit_survival(
    sit_prototype,
    following_releases = sit_revents(sit_prototype),
    following_days = 5
  )
)
#> 
#> ── Survival ────────────────────────────────────────────────────────────────────
#> 
#> 
#> population    N_released    PDS    ALE   RRx1e3     SR
#> -----------  -----------  -----  -----  -------  -----
#> blue               10000   0.77   3.89     2.79   0.78
#> red                10000   0.77   3.89     1.96   0.84
#> yellow             10000   0.77   3.89     1.89   0.77

## Why this plot still shows up to 14 days of age?
plot(surv_prototype)




surv_data <- attr(surv_prototype, 'surv_data')


## The issue seems to stem from dispersal
dispersal_dat <- dispersal(
  sit_prototype,
  following_releases = sit_revents(sit_prototype, type = 'point'),
  following_days = 5
)
summary(dispersal_dat$age)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>   1.000   2.000   4.000   5.739   9.000  15.000

## If you use data from a single release, then it works
dispersal_dat <- dispersal(
  sit_prototype,
  following_releases = sit_revents(sit_prototype, type = 'point')[1,],
  following_days = 5
)
summary(dispersal_dat$age)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>       1       2       3       3       4       5


(
  surv_prototype <- sit_survival(
    sit_prototype,
    following_releases = sit_revents(sit_prototype)[1,],
    following_days = 5,
    pool = TRUE
  )
)
#> 
#> ── Survival ────────────────────────────────────────────────────────────────────
#> 
#> 
#> population    N_released    PDS    ALE   RRx1e3     SR
#> -----------  -----------  -----  -----  -------  -----
#> pooled             10000   0.64   2.25     3.17   0.64

# This gives an error, since we only have one population.
# No, it does not.
plot(surv_prototype)


## It seems that following releases and days don't work correctly for the
## extraction of adult surveys when there are multiple releases
sa <- survey_ages(
  sit_adult_surveys(
    sit_prototype,
    following_releases = sit_revents(sit_prototype),
    following_days = 5
  ),
  releases = sit_revents(sit_prototype)
)

Created on 2023-11-12 with reprex v2.0.2