Package 'growthbreaks'

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

Help Index


Load, check and plot input data for use in breakpoint detection

Description

Load, check and plot input data for use in breakpoint detection

Usage

check_data(dat, sex = FALSE, showPlot = TRUE)

Arguments

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?

Value

plots


Check whether the CI of the derivative includes zero or not

Description

Check whether the CI of the derivative includes zero or not

Usage

check_Deriv(x, d, upper, lower, eval = 0, crit.eval)

Arguments

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

Value

vector of confidence intervals of same length as object.


Calculate confidence interval of derivative.

Usage

confint_Deriv(object, term, alpha = 0.05, ...)

Arguments

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.

Description

Evaluate first derivative of GAM smooth(s), adapted from Gavin Simpson.

Usage

Deriv(mod, n = 200, eps = 1e-04, newdata, term)

Arguments

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

Value

a vector of derivative values of length n


Wrapper function to to fit gams & evaluate first derivatives

Description

Wrapper function to to fit gams & evaluate first derivatives

Usage

get_Breaks(dat, ages_to_use = c(5, 10), sex = FALSE, axes = 0, showPlot = TRUE)

Arguments

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.

Value

matrix of detected breakpoints and plots


Hello, World!

Description

Prints 'Hello, world!'.

Usage

hello()

Examples

hello()

Show breakpoints (and optionally data) on a map

Description

Show breakpoints (and optionally data) on a map

Usage

plot_Breaks(dat, breakpoints, showData = TRUE)

Arguments

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?

Value

Map

p1

plot of Alaska with dashed breakpoints and (optionally) raw length observations


Re-fit growth data at putative breaks and return estimates for validation

Description

Re-fit growth data at putative breaks and return estimates for validation

Usage

refit_Growth(dat = simulated_data, breakpoints, selex = FALSE, showPlot = TRUE)

Arguments

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?

Value

Von B growth parameters at input breakpoints; plots with uncertainty of growth curves:

$split_tables

list of tables of input data split by strata specified in breakpoints

$fits_df

input data, estimates and associated standard errors as single dataframe

$pars_df

Parameter estimates and associated standard errors

$fits_plot

input observations and fitted growth curves, by strata

$pars_plot

Parameter estimates and associated standard errors; red lines indicate statistically significant differences