plot_mat_ogive: Fit and plot maturity ogives

View source: R/maturity.R

fit_mat_ogiveR Documentation

Fit and plot maturity ogives

Description

Fit and plot maturity ogives

Usage

fit_mat_ogive(
  dat,
  type = c("age", "length"),
  sample_id_re = FALSE,
  year_re = FALSE,
  months = seq(1, 12),
  custom_maturity_at = NULL,
  ageing_method_codes = NULL,
  usability_codes = c(0, 1, 2, 6),
  link = c("logit", "probit", "cloglog", "cauchit", "log")
)

plot_mat_ogive(
  object,
  col = c(M = "grey50", F = "black"),
  xlab = if (object$type[[1]] == "age") "Age (years)" else "Length (cm)",
  title = if (object$type[[1]] == "age") "Age at maturity" else "Length at maturity",
  rug = TRUE,
  rug_n = 1500,
  x_max = 1.75,
  prediction_type = c("all", "male", "female", "none"),
  text_label_size = 3,
  show_quant_text = TRUE,
  french = FALSE
)

plot_mat_annual_ogives(
  object,
  xlab = if (object$type[[1]] == "age") "Age (years)" else "Length (cm)",
  title = if (object$type[[1]] == "age") "Age at maturity" else "Length at maturity",
  rug = TRUE,
  rug_n = 1500,
  x_max = 1.75,
  prediction_type = c("all", "male", "female", "none"),
  french = FALSE
)

Arguments

dat

Data from gfdata::get_survey_samples().

type

Should this be an age or length fit?

sample_id_re

If TRUE then the model will include random intercepts for sample ID.

year_re

If TRUE the model will include random intercepts for year.

months

A numeric vector indicating which months to include when fitting the maturity ogive. Defaults to all months.

custom_maturity_at

A numeric vector of two threshold codes to define maturity at with the first being for males and the second for females. Defaults to NULL, which brings in default values from maturity assignment dataframe included with this package. NA in either position will also retain the default.

ageing_method_codes

A numeric vector of ageing method codes to filter on. Defaults to NULL, which brings in all valid ageing codes. See gfdata::get_age_methods().

usability_codes

An optional vector of usability codes. All usability codes not in this vector will be omitted. Set to NULL to include all samples.

link

The link function for the binomial GLM (by default, "logit").

object

Output from fit_mat_ogive().

col

A named character vector declaring the colors for F and M.

xlab

X axis label.

title

Title for the plot.

rug

Logical indicating whether rug lines should be added.

rug_n

The number of rug lines to sample from the total number of fish.

x_max

Used in determining the right axis limit.

prediction_type

The prediction lines to show. Useful if you only want to show model fits when you have sufficient data.

text_label_size

Font size for the labels showing the age-at- values for either age or length on the plot panel

show_quant_text

Logical. If TRUE, show the quantile values for each sex on the panel

french

Translate to French?

Examples

# d <- gfdata::get_survey_samples("pacific ocean perch", ssid = 1)
d <- pop_samples

m <- fit_mat_ogive(d, type = "age", sample_id_re = FALSE)
plot_mat_ogive(m)

m <- fit_mat_ogive(d, type = "length", sample_id_re = FALSE)
plot_mat_ogive(m)
## Not run: 
## with random intercepts for sample ID:
m <- fit_mat_ogive(d, type = "length", sample_id_re = TRUE)
plot_mat_ogive(m)

## End(Not run)

pbs-assess/gfplot documentation built on April 3, 2024, 2:10 p.m.