Run simulation:
## # A tibble: 1 × 13
## carrying_capacity infile last origin outdir overdispersion recruitment
## <dbl> <chr> <int> <dbl> <chr> <dbl> <dbl>
## 1 1000 "" 3 0.2 /var/folders… -1 2
## # ℹ 6 more variables: sample_size_adult <list>, sample_size_juvenile <list>,
## # seed <int>, years <int>, sample_family <list>, demography <list>
sample_family = result$sample_family[[1L]] |> print()
## # A tibble: 7,045 × 6
## id father_id mother_id birth_year location capture_year
## <int> <int> <int> <int> <int> <int>
## 1 95 0 0 -4 NA NA
## 2 96 0 0 -4 NA NA
## 3 94 95 96 1 NA NA
## 4 98 0 0 -4 NA NA
## 5 99 0 0 -4 NA NA
## 6 97 98 99 1 NA NA
## 7 93 94 97 6 NA NA
## 8 102 0 0 -4 NA NA
## 9 103 0 0 -4 NA NA
## 10 101 102 103 1 NA NA
## # ℹ 7,035 more rows
Extract kinship with degree≤4:
kinship = find_kinship(sample_family, 4L) |> print()
## # A tibble: 66 × 5
## from to path degree label
## <int> <int> <chr> <int> <fct>
## 1 1 6 1100_1 4 HC
## 2 1 51 1100_1 4 HC
## 3 2 9 1100_1 4 HC
## 4 2 12 0_1 1 PO
## 5 4 13 1100_1 4 HC
## 6 4 28 1100_1 4 HC
## 7 4 57 10_1 2 HS
## 8 4 59 10_1 2 HS
## 9 5 18 100_1 3 HUN
## 10 5 30 1100_1 4 HC
## # ℹ 56 more rows
kinship |> dplyr::count(label, .drop = FALSE)
## # A tibble: 11 × 2
## label n
## <fct> <int>
## 1 PO 4
## 2 HS 10
## 3 FS 0
## 4 GG 2
## 5 GGG 0
## 6 HUN 14
## 7 UN 0
## 8 HC 29
## 9 C 0
## 10 HGUN 7
## 11 GUN 0
Bind other information to kinship data.frame:
sampled = sample_family |>
dplyr::filter(!is.na(capture_year)) |>
dplyr::mutate(age = capture_year - birth_year) |>
dplyr::select("id", "location", "capture_year", "age") |>
print()
## # A tibble: 80 × 4
## id location capture_year age
## <int> <int> <int> <int>
## 1 1 0 98 6
## 2 2 0 98 5
## 3 3 0 98 5
## 4 4 0 98 4
## 5 5 0 98 4
## 6 6 0 98 4
## 7 7 0 98 5
## 8 8 0 98 4
## 9 9 0 98 4
## 10 10 0 98 4
## # ℹ 70 more rows
kinship |>
dplyr::left_join(sampled, by = c(from = "id")) |>
dplyr::left_join(sampled, by = c(to = "id"), suffix = c("_from", "_to"))
## # A tibble: 66 × 11
## from to path degree label location_from capture_year_from age_from
## <int> <int> <chr> <int> <fct> <int> <int> <int>
## 1 1 6 1100_1 4 HC 0 98 6
## 2 1 51 1100_1 4 HC 0 98 6
## 3 2 9 1100_1 4 HC 0 98 5
## 4 2 12 0_1 1 PO 0 98 5
## 5 4 13 1100_1 4 HC 0 98 4
## 6 4 28 1100_1 4 HC 0 98 4
## 7 4 57 10_1 2 HS 0 98 4
## 8 4 59 10_1 2 HS 0 98 4
## 9 5 18 100_1 3 HUN 0 98 4
## 10 5 30 1100_1 4 HC 0 98 4
## # ℹ 56 more rows
## # ℹ 3 more variables: location_to <int>, capture_year_to <int>, age_to <int>