## Error in get(paste0(generic, ".", class), envir = get_method_env()) :
## object 'type_sum.accel' not found
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: 7,273 × 6
## id father_id mother_id birth_year location capture_year
## <int> <int> <int> <int> <int> <int>
## 1 132 0 0 -4 NA NA
## 2 131 132 132 0 NA NA
## 3 133 132 132 0 NA NA
## 4 130 131 133 5 NA NA
## 5 136 132 132 0 NA NA
## 6 137 132 132 0 NA NA
## 7 135 136 137 4 NA NA
## 8 139 132 132 0 NA NA
## 9 140 132 132 0 NA NA
## 10 138 139 140 4 NA NA
## # ℹ 7,263 more rows
Extract kinship with degree≤4:
kinship = find_kinship(sample_family, 4L) |> print()
## # A tibble: 95 × 5
## from to path degree label
## <int> <int> <chr> <int> <fct>
## 1 2 10 1100_1 4 HC
## 2 3 43 100_1 3 HUN
## 3 3 86 1100_1 4 HC
## 4 3 90 1100_1 4 HC
## 5 5 92 1100_1 4 HC
## 6 5 112 1100_1 4 HC
## 7 6 103 1100_1 4 HC
## 8 7 79 1100_1 4 HC
## 9 8 23 10_1 2 HS
## 10 9 27 1100_1 4 HC
## # ℹ 85 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 1
## 5 GGG 1
## 6 HUN 18
## 7 UN 0
## 8 HC 53
## 9 C 0
## 10 HGUN 8
## 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: 120 × 4
## id location capture_year age
## <int> <int> <int> <int>
## 1 1 0 78 4
## 2 2 0 78 4
## 3 3 0 78 4
## 4 4 0 78 5
## 5 5 0 78 5
## 6 6 0 78 5
## 7 7 0 78 6
## 8 8 0 78 5
## 9 9 0 78 5
## 10 10 0 78 4
## # ℹ 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: 95 × 11
## from to path degree label location_from capture_year_from age_from
## <int> <int> <chr> <int> <fct> <int> <int> <int>
## 1 2 10 1100_1 4 HC 0 78 4
## 2 3 43 100_1 3 HUN 0 78 4
## 3 3 86 1100_1 4 HC 0 78 4
## 4 3 90 1100_1 4 HC 0 78 4
## 5 5 92 1100_1 4 HC 0 78 5
## 6 5 112 1100_1 4 HC 0 78 5
## 7 6 103 1100_1 4 HC 0 78 5
## 8 7 79 1100_1 4 HC 0 78 6
## 9 8 23 10_1 2 HS 0 78 5
## 10 9 27 1100_1 4 HC 0 78 5
## # ℹ 85 more rows
## # ℹ 3 more variables: location_to <int>, capture_year_to <int>, age_to <int>