| Title: | Tools for Boreal Caribou Demography |
|---|---|
| Description: | Spatial and demographic tools for caribou survival, recruitment, movement, and population growth rate estimation. Developed for Northwest Territories boreal caribou system as a part of CIMP247. |
| Authors: | Chloe Beaupre [aut, cre] (GITHUB: chlobeau) |
| Maintainer: | Chloe Beaupre <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.0.9000 |
| Built: | 2026-06-07 10:49:04 UTC |
| Source: | https://github.com/chlobeau/taigatools |
Buffers each point by half of buffer_dist, unions overlapping buffers within each biological year, and assigns a unique bufferID to each resulting polygon. Points are then spatially joined to their buffer group and returned as an sf with centroid coordinates. Used to group composition survey observations that were collected in the same area within a biological year.
addBufferID(sf, buffer_dist = 500)addBufferID(sf, buffer_dist = 500)
sf |
sf of point locations with column bioYear |
buffer_dist |
numeric; total buffer diameter in metres (default 500); halved internally so each point is buffered by a 250m radius |
sf with added columns bufferID, x, and y (buffer centroid coordinates)
Add proportion of time assigned to study area
addPropAssigned(df)addPropAssigned(df)
df |
one-row data frame (typically a single row from countPtsInPolygons output) with columns assigned_new and total_days |
df with added column prop_assigned
Assign boundary labels to individuals by lifetime and annual mean location
assignBounds(mean_sf, annual_mean_sf, bounds_sf, col_name)assignBounds(mean_sf, annual_mean_sf, bounds_sf, col_name)
mean_sf |
sf of lifetime mean locations with column ID |
annual_mean_sf |
sf of annual mean locations with columns ID and bioYear |
bounds_sf |
sf multipolygon boundary layer |
col_name |
unquoted name of the column in bounds_sf identifying unique polygons |
a list with two data frames:
lifetime |
ID and boundary assignment based on lifetime mean location |
annual |
ID, bioYear, and boundary assignment based on annual mean location |
Calculates calf:cow ratios and recruited female rates from aerial composition surveys using the NWT method:
calculateRecruitment(comp_sf, grouping_col = "StudyArea")calculateRecruitment(comp_sf, grouping_col = "StudyArea")
comp_sf |
sf of composition survey locations with columns bioYear, Cow, Bull, Calf, Yearling, Unk |
bounds2_sf |
sf multipolygon of study area boundaries with column StudyArea2 |
Totals observations by sex and age class per year
Apportions unknown adults to cows and bulls based on a 50/50 sex ratio
Apportions unknown age-sex animals among cows, bulls, and calves
Calculates calf:cow ratio using adjusted cow and calf counts
Calculates SE of calf:cow ratio using the binomial approximation (Cochran 1977 p. 52 Eq 3.11; Krebs 1999 Eq 8.13, excluding sampling)
Note: sex ratio apportionment follows Allicia Klapatiuk (GNWT) 50/50 method rather than the Rettie proportion-based approach.
data frame with one row per study area per biological year with columns Years, GroupsObs, Bulls, Cows, Calves, Total, CalfCow, CalfCow_SE, RecruitedFemales, RecruitedFem_SE, BullCow, Rrm
Merge movement and survival data
combineMoveMort(movement_data, survival_data)combineMoveMort(movement_data, survival_data)
movement_data |
sf of GPS locations with columns ID, Time, Lon, Lat |
survival_data |
data frame with columns ID, startDate, endDate, Status |
sf of point locations trimmed to each animal's monitoring period, with added columns deathDate and Death (TRUE on the date of mortality or undetermined fate censoring)
Counts how many locations each animal has within polygon boundaries. Useful for validating study area assignments or identifying where animals spend most of their time.
countPtsInPolygons( pts_sf, bounds, bounds_col, time_col = "Time", assigned_col = "study_site" )countPtsInPolygons( pts_sf, bounds, bounds_col, time_col = "Time", assigned_col = "study_site" )
pts_sf |
sf of point locations; must contain an ID column plus the columns named by time_col and assigned_col |
bounds |
sf multipolygon boundary layer |
bounds_col |
character; name of the column in bounds identifying unique polygons |
time_col |
character; name of the POSIXct datetime column (default "Time") |
assigned_col |
character; name of the study area assignment column (default "study_site") |
data frame with columns: ID, start, end, assigned, total_pts, polygon_pts for each boundary, total_days, and polygon_days for each boundary
Estimate beta distribution parameters from mean and variance
estBetaParams(mu, var)estBetaParams(mu, var)
mu |
numeric; mean of the distribution |
var |
numeric; variance of the distribution |
list with elements alpha and beta
Estimate lognormal distribution parameters from mean and variance
estLogNormalParams(mean, var)estLogNormalParams(mean, var)
mean |
numeric; mean of the distribution |
var |
numeric; variance of the distribution |
list with elements mu and sigma2
Multiplies monthly survival estimates across the biological year (April-March) to yield an annual product-limit estimate, with variance approximated by the sum of monthly variances weighted by the squared annual survival.
getAnnualSurvival(monthly_survival, grouping_col = "StudyArea")getAnnualSurvival(monthly_survival, grouping_col = "StudyArea")
monthly_survival |
data frame from getSurvTable with columns survival, survival_var, n.total, month, Year, and a grouping column |
grouping_col |
character; name of the grouping column (default "StudyArea") |
data frame with one row per group per biological year with columns Years, km_survival, km_var, km_se, survival_LCL, survival_UCL, n_survival, n_survival_max, km_95ci_finite
Get mean location and attributes per individual
getMean(x, id.col = "ID")getMean(x, id.col = "ID")
x |
sf or data frame with an ID column |
id.col |
character; name of the ID column (default "ID") |
sf or data frame with one row per individual containing mean numeric values, first value for character/factor columns, and mean timestamp for POSIXct columns
Fit Kaplan-Meier survival model and return monthly estimates
getSurvTable(df)getSurvTable(df)
df |
data frame from setupMonthlySurvival with columns month_start, month_end, DeadInMonth |
data frame with columns n.total, n.dead, survival, survival_se, survival_var, survival_LCL, survival_UCL
Resample to one random location per individual per day
resampleDaily(move_mort_sf)resampleDaily(move_mort_sf)
move_mort_sf |
sf of point locations with columns ID and Time |
sf with one randomly selected location per individual per day
Approximates uncertainty in population growth rate (lambda) by drawing 10,000 times from annual survival and recruitment distributions following Hood (2009) and Morris and Doak (2002). Survival is drawn from a beta distribution (bounded 0-1) using estBetaParams; recruited females from a lognormal distribution (bounded at 0) using estLogNormalParams. Lambda is calculated as S / (1 - Rrm) where Rrm is the recruited female rate. Uncertainty is summarized as the SD of the MCMC draws.
runLambdaMCMC(df, reps = 10000)runLambdaMCMC(df, reps = 10000)
df |
one-row data frame with columns km_survival, km_var, RecruitedFemales, RecruitedFem_SE, and lambda |
reps |
integer; number of Monte Carlo draws (default 10,000) |
df with added columns lambda.mcmc, lambda.sd, lambda.se, lambda.var, lambda_LCL, lambda_UCL
Expand individual survival records to monthly intervals
setupMonthlySurvival(mort.df)setupMonthlySurvival(mort.df)
mort.df |
one-row data frame for a single individual with columns ID, Status, startDate, endDate |
data frame with one row per month of monitoring, with columns month_start, month_end, Animal_ID, Fate, startDate, endDate, end, StartInMonth, DeadInMonth, CensInMonth, month, Year