| Title: | Spatio-temporal Growth Anomaly Detection |
|---|---|
| Description: | Implements the GAM-based breakpoint detection method for length-at-age observations as described Kapur et. al. 2019. |
| Authors: | Maia S. Kapur |
| Maintainer: | Maia S. Kapur <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-05-16 08:20:57 UTC |
| Source: | https://github.com/afsc-assessments/growthbreaks |
Load, check and plot input data for use in breakpoint detection
check_data(dat, sex = FALSE, showPlot = TRUE)check_data(dat, sex = FALSE, showPlot = TRUE)
dat |
data.frame with columns year, age, length, sex (optional) |
sex |
logical. does your data frame include a sex column? |
showPlot |
logical. do you want to visualize your input data? |
plots
Check whether the CI of the derivative includes zero or not
check_Deriv(x, d, upper, lower, eval = 0, crit.eval)check_Deriv(x, d, upper, lower, eval = 0, crit.eval)
x |
vector of values over which derivatives were evaluated |
d |
vector output of Deriv() |
upper |
upper confidence interval; output of confint_Deriv() |
lower |
lower confidence interval; output of confint_Deriv() |
eval |
the value that you would like to examine. default 0 |
vector of confidence intervals of same length as object.
confint_Deriv(object, term, alpha = 0.05, ...)confint_Deriv(object, term, alpha = 0.05, ...)
object |
vector output of Deriv() |
term |
string smooth name, i.e. "year". must match values in mod and newdata |
alpha |
confidence threshold. default 0.05 (for 95 |
vector of confidence intervals of same length as object.
Calculate confidence interval of derivative.
Evaluate first derivative of GAM smooth(s), adapted from Gavin Simpson.
Deriv(mod, n = 200, eps = 1e-04, newdata, term)Deriv(mod, n = 200, eps = 1e-04, newdata, term)
mod |
the output of mgcv::gam() |
n |
number of intervals over which to evaluate each smooth. default 200. |
eps |
tolerance threshold. default 1e-4. |
newdata |
optional; data.frame of new smooth parameters to evaluate |
term |
string smooth name, i.e. "year". must match values in mod and newdata |
a vector of derivative values of length n
Wrapper function to to fit gams & evaluate first derivatives
get_Breaks(dat, ages_to_use = c(5, 10), sex = FALSE, axes = 0, showPlot = TRUE)get_Breaks(dat, ages_to_use = c(5, 10), sex = FALSE, axes = 0, showPlot = TRUE)
dat |
data.frame with columns year, age, length, lat, long, sex (optional) |
ages_to_use |
optional. vector of age(s) to evaluate for breakpoints. |
sex |
logical. |
axes |
do you want to evaluate axes for space only (0, default), time only (1), or both simultaneously (2)? |
showPlot |
logical. do you want to see the detected break(s) on a map? Applicable only for axes options 0 or 2. |
matrix of detected breakpoints and plots
Show breakpoints (and optionally data) on a map
plot_Breaks(dat, breakpoints, showData = TRUE)plot_Breaks(dat, breakpoints, showData = TRUE)
dat |
data.frame with columns year, age, length, lat, long, sex (optional) |
breakpoints |
data.frame with columns year (optional) lat and long. can be output of get_Breaks(). Use -Inf to turn off a break. |
showData |
logical. do you want to see your datapoints? |
Map
p1plot of Alaska with dashed breakpoints and (optionally) raw length observations
Re-fit growth data at putative breaks and return estimates for validation
refit_Growth(dat = simulated_data, breakpoints, selex = FALSE, showPlot = TRUE)refit_Growth(dat = simulated_data, breakpoints, selex = FALSE, showPlot = TRUE)
dat |
data.frame with columns year, age, length, lat, long, sex (optional) |
breakpoints |
data.frame with columns year and/or lat and long. can be output of get_Breaks(). |
showPlot |
logical. do you want to see plots of the fitted curves? |
Von B growth parameters at input breakpoints; plots with uncertainty of growth curves:
$split_tableslist of tables of input data split by strata specified in breakpoints
$fits_dfinput data, estimates and associated standard errors as single dataframe
$pars_dfParameter estimates and associated standard errors
$fits_plotinput observations and fitted growth curves, by strata
$pars_plotParameter estimates and associated standard errors; red lines indicate statistically significant differences