vignettes/a0vignette.Rmd
      a0vignette.RmdThe SRKW orca data is included as a dataframe. Each row is an individual, with birth and death information.
#>     X animal birth death  pod matriline  mom sexF1M2 includeFec includeSurv
#> 1 485   J001  1951  2010 J001      J002 <NA>       2          1           1
#> 2 486   J002  1911  2017 J001      J002 <NA>       1          1           1
#> 3 487   J003  1953  1995 J001      J016 <NA>       2          1           1
#> 4 488   J004  1957  1995 J001      J008 <NA>       1          1           1
#> 5 489   J005  1938  1997 J001      J009 <NA>       1          0           1
#> 6 490   J006  1956  1998 J001      J008 <NA>       2          1           1
#>   population
#> 1       SRKW
#> 2       SRKW
#> 3       SRKW
#> 4       SRKW
#> 5       SRKW
#> 6       SRKW
But for modeling, it’s more useful to work with an expanded version, where every animal-year combination gets its own row. The expand() function does this step,
Then we can do all kinds of filtering for various analyses – e.g.
whaleData = whaleData[whaleData$birth > 1970,]
# A handful of unknown sexes need to be randomly filled in
whaleData$sexF1M2[which(whaleData$sexF1M2==0)] = sample(c(1,2), size=length(which(whaleData$sexF1M2==0)), replace=T)
whales_since76 = as.character(orca$animal[orca$birth > 1970])
sub = whaleData[which(whaleData$animal%in%whales_since76 & whaleData$population=="SRKW" & !is.na(whaleData$gave_birth) & whaleData$sexF1M2=="1" & whaleData$age>=10 & whaleData$age< 43), ]
sub$animal = as.factor(sub$animal)
# filter out females alive in current year
currently_alive = dplyr::filter(sub, year == year.end, is.na(death))
knitr::kable(currently_alive)| year | animal | X | birth | death | pod | matriline | mom | sexF1M2 | includeFec | includeSurv | population | age | alive | gave_birth | 
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2025 | J022 | 506 | 1985 | NA | J001 | J009 | J010 | 1 | 1 | 1 | SRKW | 40 | 1 | 0 | 
| 2025 | J031 | 515 | 1995 | NA | J001 | J008 | J011 | 1 | 1 | 1 | SRKW | 30 | 1 | 0 | 
| 2025 | J036 | 521 | 1999 | NA | J001 | J016 | J016 | 1 | 1 | 1 | SRKW | 26 | 1 | 0 | 
| 2025 | J037 | 522 | 2001 | NA | J001 | J002 | J014 | 1 | 1 | 1 | SRKW | 24 | 1 | 0 | 
| 2025 | J040 | 525 | 2004 | NA | J001 | J002 | J014 | 1 | 1 | 1 | SRKW | 21 | 1 | 0 | 
| 2025 | J042 | 527 | 2007 | NA | J001 | J016 | J016 | 1 | 1 | 1 | SRKW | 18 | 1 | 0 | 
| 2025 | J046 | 531 | 2009 | NA | J001 | J009 | J028 | 1 | 1 | 1 | SRKW | 16 | 1 | 0 | 
| 2025 | J053 | 538 | 2015 | NA | J001 | J009 | J017 | 1 | 1 | 1 | SRKW | 10 | 1 | 0 | 
| 2025 | K016 | 558 | 1985 | NA | K001 | K003 | K003 | 1 | 1 | 1 | SRKW | 40 | 1 | 0 | 
| 2025 | K020 | 562 | 1986 | NA | K001 | K007 | K013 | 1 | 1 | 1 | SRKW | 39 | 1 | 0 | 
| 2025 | K022 | 564 | 1987 | NA | K001 | K004 | K012 | 1 | 1 | 1 | SRKW | 38 | 1 | 0 | 
| 2025 | K027 | 569 | 1994 | NA | K001 | K007 | K013 | 1 | 1 | 1 | SRKW | 31 | 1 | 0 | 
| 2025 | K042 | 584 | 2008 | NA | K001 | K003 | K014 | 1 | 1 | 1 | SRKW | 17 | 1 | 0 | 
| 2025 | K043 | 585 | 2010 | NA | K001 | K004 | K012 | 1 | 1 | 1 | SRKW | 15 | 1 | 0 | 
| 2025 | L072 | 648 | 1986 | NA | L001 | L026 | L043 | 1 | 1 | 1 | SRKW | 39 | 1 | 0 | 
| 2025 | L077 | 653 | 1987 | NA | L001 | L012 | L011 | 1 | 1 | 1 | SRKW | 38 | 1 | 0 | 
| 2025 | L082 | 658 | 1990 | NA | L001 | L004 | L055 | 1 | 1 | 1 | SRKW | 35 | 1 | 0 | 
| 2025 | L083 | 659 | 1990 | NA | L001 | L021 | L047 | 1 | 1 | 1 | SRKW | 35 | 1 | 0 | 
| 2025 | L086 | 662 | 1991 | NA | L001 | L004 | L004 | 1 | 1 | 1 | SRKW | 34 | 1 | 0 | 
| 2025 | L091 | 667 | 1995 | NA | L001 | L021 | L047 | 1 | 1 | 1 | SRKW | 30 | 1 | 0 | 
| 2025 | L094 | 670 | 1995 | NA | L001 | L012 | L011 | 1 | 1 | 1 | SRKW | 30 | 1 | 0 | 
| 2025 | L103 | 679 | 2003 | NA | L001 | L004 | L055 | 1 | 1 | 1 | SRKW | 22 | 1 | 0 | 
| 2025 | L113 | 689 | 2009 | NA | L001 | L012 | L094 | 1 | 1 | 1 | SRKW | 16 | 1 | 0 | 
| 2025 | L118 | 694 | 2011 | NA | L001 | L004 | L055 | 1 | 1 | 1 | SRKW | 14 | 1 | 0 | 
| 2025 | L119 | 695 | 2012 | NA | L001 | L012 | L077 | 1 | 1 | 1 | SRKW | 13 | 1 | 0 | 
# find last birth for each of these
last_birth = group_by(dplyr::filter(sub, gave_birth==1), animal) %>% 
  dplyr::summarise(last_birth = max(year[which(gave_birth==1)]))
last_birth$last_birth[!is.finite(last_birth$last_birth)] = NA
currently_alive = dplyr::left_join(currently_alive, last_birth) %>% 
  dplyr::mutate(unlikely_future_mom="") %>%
  dplyr::select(animal,age,last_birth,unlikely_future_mom) %>% data.frame()As a cautionary note, there may be interest in using these data to test correlations with prey (salmon) indices or other environmental drivers. There are several very nuanced and important things to note about different subsets of these data.
First, ages on animals in the beginning of the surveys were often
‘guessed’, and in the cases of females, assigned an age of 40 based on
the last observed birth. This procedure will generate bias (many of the
animals being < 40 during their last birth), so these animals have
been excluded from fecundity-at-age analyses, or only used in
stage-based survival estimates. The includeSurv and
includeFec columns are used to designate most of these
cases (1 = include, 0 = exclude).
Second, a handful of deaths are either tied to human disturbance (direct or indirectly associated with ship strikes) or are not independent. Calves that died at the same time as their moms are not independent (J24, J54, K39, L97, L104). Other animals are associated with vessel strikes (L98), satellite tag infections (L95) or unknown trauma (L112). For the latter three animals, it is possible to include the years they survive as data, and replace the death data with an NA. For example: