Skip to contents

Somerton method

Usage

somerton(
  dat,
  xvar,
  yvar,
  log = FALSE,
  lower = NULL,
  upper = NULL,
  max_iter = 50
)

Arguments

dat

data frame or matrix containing the data

xvar

Name of column (integer or double) of measurements for the x - axis variable (e.g., carapace width).

yvar

Name of column (integer or double) of measurements for the y-axis variable (e.g., claw height).

log

Boolean; should both variables be log-transformed before performing the regression? Defaults to FALSE.

lower

Integer or double; the lower bound for possible SM50 values. Must be on the same trans of the data. Defaults to the 20th percentile of the x-variable.

upper

Integer or double; the upper bound for possible SM50 values. Must be on the same trans of the data. Defaults to the 80th percentile of the x-variable.

max_iter

Maximum number of iterations

Value

Output is a list that also includes the input data frame with a column specifying which maturity group each point was assigned to, vectors of the R-squared and residual sum of squares for each iteration, and the linear model objects corresponding to each maturity group.

Examples

set.seed(12)
fc <- fake_crustaceans(n = 100, L50 = 100, allo_params = c(1, 0.2, 1.1, 0.2))
out_df <- somerton(fc, xvar = "x", yvar = "y")[[1]]
mod <- glm(data = out_df, pred_mat_num ~ x, family = binomial(link = "logit"))
unname(-coef(mod)[1] / coef(mod)[2])
#> [1] 102.37