emp: Computes the standard weight equation using the...

View source: R/emp.R

empR Documentation

Computes the standard weight equation using the empirical-percentile method.

Description

Computes the standard weight equation using the empirical-percentile (EmP) method when given populations of length-weight data.

Usage

emp(
  df,
  pops,
  len,
  wt,
  min,
  max,
  w = 10,
  n.cutoff = 3,
  cutoff.tail = TRUE,
  qtype = 8,
  probs = 0.75,
  method = c("lm", "rq"),
  quadratic = TRUE
)

## S3 method for class 'emp'
coef(object, ...)

## S3 method for class 'emp'
summary(object, ...)

## S3 method for class 'emp'
predict(object, ...)

## S3 method for class 'emplm'
anova(object, ...)

## S3 method for class 'emp'
plot(
  x,
  pch = 16,
  col.pop = "rainbow",
  col.Ws = "black",
  lwd.Ws = 3,
  lty.Ws = 1,
  jitterX = TRUE,
  jitter.factor = 3,
  ...
)

## S3 method for class 'emp'
fitPlot(
  object,
  pch = 16,
  col.pt = "black",
  col.Ws = "red",
  lwd.Ws = 3,
  lty.Ws = 1,
  xlab = "log10(midpt Length)",
  ylab = paste(100 * object$probs, "Percentile of mean log10(Weight)"),
  main = "EMP Equation Fit",
  ...
)

Arguments

df

A data frame that contains the length-weight data for each population.

pops

A string or numeric that indicates which column in df contains the variable that identifies the different populations.

len

A string or numeric that indicates which column in df contains the variable with the length data.

wt

A string or numeric that indicates which column in df contains the variable with the weight data.

min

A number that indicates the midpoint value of the smallest X-mm length category.

max

A number that indicates the midpoint value of the largest X-mm length category.

w

A number that indicates the widths for which to create length categories.

n.cutoff

A numeric that indicates the minimum sample size (i.e., number of populations) in a length category that should be included in the regression.

cutoff.tail

A logical that indicates if all length categories larger than the lowest length category with a number of populations below n.cutoff should be excluded =TRUE or just those length categories with sample sizes lower than n.cutoff.

qtype

Type of quantile method to use. See description of types of quantile calculation methods in quantile.

probs

A number that indicates the probability of the quantile. Must be between 0 and 1.

method

A string that indicates whether a linear regression (lm or quantile regression (rq) should be used to construct the standard weight equation. See details.

quadratic

A logical that indicates whether a quadratic regression should be fit (=TRUE or not.

...

Additional arguments for methods.

x, object

An object saved from the emp call (i.e., of class emp).

pch

A single numeric that indicates what plotting character codes should be used for the points in plot or fitPlot.

col.pop

A string that indicates the type of color or palette to use for the population of length-weight regression lines. See details.

col.Ws

A string that indicates the type of color to use for the standard length-weight regression line.

lwd.Ws

A numeric that indicates the width of the line to use for the standard length-weight regression line.

lty.Ws

A numeric that indicates the type of line to use for the standard length-weight regression line.

jitterX

A logical that indicates whether the x values in plot should be jittered.

jitter.factor

A numeric that indicates the relative magnitude of the jittering in x (sent to factor argument in jitter.

col.pt

A string used to indicate the color of the plotted points.

xlab

A label for the x-axis of fitPlot.

ylab

A label for the y-axis of fitPlot.

main

A label for the main title of fitPlot.

Details

The main function follows the steps of the empirical percentile method (EmP) detailed in Gerow et al. (2005). In general, the mean log_{10} weight for each population within all length categories is computed, length categories from fewer than ncutoff populations are eliminated (see cutoff.tail description above), the 100probth quantile of mean log_{10} weights for the remaining categories are found, and a n-weighted regression (quadratic regression if quadratic=TRUE) is then fit to the 100probsth quantile of mean log_{10} weights and the length category midpoint value.

Gerow et al. (2005) suggested using a quantile definition that is basically the same as qtype=9.

coef returns log_{10}(a) and b values for the resultant standard weight equation. Similarly, summary, anova, and predict returns the typical results for the linear regression model used to create the standard weight equation.

plot method plots the mean log10 weights versus length category midpoint for each population represented in the data frame with the resultant standard weight equation superimposed in black. If the col.pop argument is is one of "rainbow", "heat", "topo", "terrain", "cm", "default", or "grey" and order.pop=TRUE then the populations plotted should form a general color gradient from smallest to largest weight in the initial length category. This will make it easier to identify populations that “cross over” other populations.

fitPlot shows the log-transformed linear regression result; i.e., fitted line superimposed on the log-transformed 100probth percentile predicted weights versus log-transformed midpoint length category value. The examples show how to make a corresponding residual plot.

Value

The main function returns a list with the following items:

  • pop.by.len is a table of the number of populations represented in each length category.

  • ind.by.len is a table of the number of individual fish in each length category.

  • sumdata is a data.frame of the mean log_{10} weight and length category midpoints for each population.

  • regdata is the data.frame used for the Ws regression (i.e., 100probth quantiles of mean log_{10} weight and length category midpoints).

  • quadratic is a logical that indicates whether the quadratic regression was used.

  • probs the numeric given in probs.

  • Ws is the Ws regression model results.

Author(s)

Derek H. Ogle, DerekOgle51@gmail.com

References

Gerow, K.G., R.C. Anderson-Sprecher, and W.A. Hubert. 2005. A new method to compute standard-weight equations that reduces length-related bias. North American Journal of Fisheries Management 25:1288-1300.

See Also

rlp, FroeseWs, and wsValidate.

Examples

## Walleye Ws equation for comparison to Gerow's Excel Tool
# Gerow's results were -- -4.624269, 2.477718, and 0.1461490 for the intercept,
#   linear term, and quadratic term for 75th percentile Ws equation
# and -- -4.950281, 2.698470, and 0.1052352 for the intercept,
#   linear term, and quadratic term for 50th percentile Ws equation

# Ws75 results
wae1 <- emp(WalleyeGerowLW,"popn","len","wt",min=155,max=955,cutoff.tail=FALSE)
coef(wae1)
# Ws75 results -- using same quantile type?
wae2 <- emp(WalleyeGerowLW,"popn","len","wt",min=155,max=955,qtype=9,cutoff.tail=FALSE)
coef(wae2)

# Ws50 results; note use of all length categories
wae1a <- emp(WalleyeGerowLW,"popn","len","wt",min=155,max=955,n.cutoff=1,probs=0.5)
coef(wae1a)
# Ws50 results -- using same quantile type?
wae2a <- emp(WalleyeGerowLW,"popn","len","wt",min=155,max=955,qtype=9,n.cutoff=1,probs=0.5)
coef(wae2a)

# It appears that the quantiles computed here are different than Gerow's quantiles.
#   This is seen by comparing regdata to his 'summarized' worksheet. From
#   Gerow et al. (2005) it appears that he used 'qtype=9'; however, 'qtype=5'
#   provides the closest values to his Excel worksheet.
wae1$regdata

## Demonstrate other extractor functions
summary(wae1)
anova(wae1)
predict(wae1)
10^predict(wae1,data.frame(logmidpt=log10(c(200,400))))

plot(wae1)
fitPlot(wae1)
# a residual plot for the linear regression
plot(wae1$Ws$residuals~wae1$Ws$fitted.values,pch=19)
abline(h=0,lty=3)
## use quantile regression method
wae1rq <- emp(WalleyeGerowLW,"popn","len","wt",min=155,max=955,cutoff.tail=FALSE,method="rq") 
coef(wae1rq)
plot(wae1rq)


droglenc/FSAWs documentation built on Feb. 3, 2023, 8:48 a.m.