Rescales a so that a length-weight pair published against fork, standard or
another length type reads as a pair against total length, using the
length-length conversions from the same expansion.
Arguments
- length_weight
Length-weight rows as returned by
get_length_weight_coeffs(). Must carryspecies_found,server,Type,aandb.- length_length
Length-length rows as returned by
get_length_length_coeffs(), from the same expansion so thatspecies_foundandserverare keyed consistently. Build them withlength_types = NULL: the defaultc("TL", "FL")keeps no standard-length pair, andSLis where the correction is largest.- max_intercept
Numeric. Conversions whose intercept
aLexceeds this in absolute value are discarded before the median is taken. Defaults to1(cm); a large intercept means the fit is not well approximated by the pure ratio applied here.
Value
length_weight with a restated and Type set to "TL" for every
row that had a usable conversion. Rows with no conversion are returned
unchanged, still carrying their original Type, so nothing is silently
dropped. Filter on Type == "TL" afterwards if only restated pairs are
wanted.
Details
Given W = a * L_type^b and L_type ~= ratio * TL, substitution gives
W = a * ratio^b * TL^b. So b is unchanged and only a moves.
The ratio comes from the POPLL table, which fits
Length1 = aL + bL * Length2 — the second column is the predictor. A row
with Length2 == "TL" therefore gives ratio = bL for Length1, and a row
with Length1 == "TL" gives ratio = 1 / bL for Length2. Reading that fit
backwards inverts every ratio and moves weight by roughly (1/r)^b / r^b —
about 1.1x for fork length and 1.8x for standard length — so the direction is
asserted in the tests rather than left to the reader. Where several published
conversions exist for a species and type, the median is taken.
Restating rather than filtering matters for coverage: keeping only
Type == "TL" was measured to discard more than half the matched species for
several taxon codes. Which rows to feed in is the caller's decision — pass
everything to restate every convertible pair, or pass only the taxa that have
no native total-length pair to leave the rest untouched.
Examples
if (FALSE) { # \dontrun{
m <- get_taxa_morphometrics(taxa, length_types = NULL)
lw_tl <- convert_lw_to_tl(m$length_weight, m$length_length)
# Restate only the taxa that have no native total-length pair
covered <- unique(m$length_weight$alpha3_code[m$length_weight$Type == "TL"])
lw_tl <- convert_lw_to_tl(
dplyr::filter(m$length_weight, !alpha3_code %in% covered),
m$length_length
)
} # }
