Run simulation:
## # A tibble: 1 × 17
## carrying_capacity fishing_coef fishing_mortality last migration_matrices
## <dbl> <list> <list> <int> <list>
## 1 2000 <list [0]> <dbl [84]> 3 <dbl [9 × 4 × 4]>
## # ℹ 12 more variables: natural_mortality <list>, origin <int>, outdir <chr>,
## # overdispersion <dbl>, recruitment <dbl>, sample_size_adult <list>,
## # sample_size_juvenile <list>, seed <int>, weight_for_age <list>,
## # years <int>, sample_family <list>, demography <list>
sample_family = result$sample_family[[1L]] |> print()
## # A tibble: 6,712 × 6
## id father_id mother_id birth_year location capture_year
## <int> <int> <int> <int> <int> <int>
## 1 133 0 0 -4 NA NA
## 2 132 133 133 0 NA NA
## 3 134 133 133 0 NA NA
## 4 131 132 134 5 NA NA
## 5 136 133 133 0 NA NA
## 6 135 136 134 5 NA NA
## 7 130 131 135 10 NA NA
## 8 139 133 133 0 NA NA
## 9 140 133 133 0 NA NA
## 10 138 139 140 7 NA NA
## # ℹ 6,702 more rows
Extract kinship with degree≤4:
kinship = find_kinship(sample_family, 4L) |> print()
## # A tibble: 91 × 5
## from to path degree label
## <int> <int> <chr> <int> <fct>
## 1 1 57 1100_1 4 HC
## 2 1 91 110_1 3 HUN
## 3 3 60 1110_1 4 HGUN
## 4 4 63 1100_1 4 HC
## 5 5 21 1100_1 4 HC
## 6 6 26 1100_1 4 HC
## 7 6 118 110_1 3 HUN
## 8 7 38 110_1 3 HUN
## 9 7 40 110_1 3 HUN
## 10 7 74 1110_1 4 HGUN
## # ℹ 81 more rows
kinship |> dplyr::count(label, .drop = FALSE)
## # A tibble: 11 × 2
## label n
## <fct> <int>
## 1 PO 8
## 2 HS 4
## 3 FS 0
## 4 GG 2
## 5 GGG 1
## 6 HUN 23
## 7 UN 0
## 8 HC 43
## 9 C 0
## 10 HGUN 9
## 11 GUN 1
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: 120 × 4
## id location capture_year age
## <int> <int> <int> <int>
## 1 1 0 78 0
## 2 2 0 78 0
## 3 3 0 78 0
## 4 4 0 78 0
## 5 5 0 78 0
## 6 6 0 78 0
## 7 7 0 78 0
## 8 8 0 78 0
## 9 9 0 78 0
## 10 10 0 78 0
## # ℹ 110 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: 91 × 11
## from to path degree label location_from capture_year_from age_from
## <int> <int> <chr> <int> <fct> <int> <int> <int>
## 1 1 57 1100_1 4 HC 0 78 0
## 2 1 91 110_1 3 HUN 0 78 0
## 3 3 60 1110_1 4 HGUN 0 78 0
## 4 4 63 1100_1 4 HC 0 78 0
## 5 5 21 1100_1 4 HC 0 78 0
## 6 6 26 1100_1 4 HC 0 78 0
## 7 6 118 110_1 3 HUN 0 78 0
## 8 7 38 110_1 3 HUN 0 78 0
## 9 7 40 110_1 3 HUN 0 78 0
## 10 7 74 1110_1 4 HGUN 0 78 0
## # ℹ 81 more rows
## # ℹ 3 more variables: location_to <int>, capture_year_to <int>, age_to <int>