Skip to contents

Fit a distribution to log ppmr observations

Usage

fit_log_ppmr(
  ppmr_data,
  species,
  distribution = c("normal", "trunc_exp", "gauss_mix"),
  min_w_pred = 0,
  power = 0
)

Arguments

ppmr_data

A data frame with log ppmr observations. See validate_ppmr_data() for details.

species

A character vector with one or more species names.

distribution

The distribution to fit. One of "normal", "trunc_exp" or "gauss_mix".

min_w_pred

The minimum predator weight to include. Default is 0.

power

Each observation is weighted by a power of the prey weight. The default is 0 which means that each prey individual contributes equally. power = 1 means each prey individual contributes in proportion to its biomass.

Value

A fit data frame with one row per species. See validate_fit() for details.

Examples

# Fit a normal distribution to one species
fit <- fit_log_ppmr(barnes_data, "Albacore", distribution = "normal")
fit
#>              mean       sd  species distribution power min_w_pred
#> Albacore 9.546003 1.146738 Albacore       normal     0          0

# Fit multiple species at once
fit <- fit_log_ppmr(barnes_data,
                    c("Albacore", "Atlantic cod"),
                    distribution = "normal")
fit
#>                  mean       sd      species distribution power min_w_pred
#> Albacore     9.546003 1.146738     Albacore       normal     0          0
#> Atlantic cod 5.725514 2.600442 Atlantic cod       normal     0          0

# \donttest{
# Fit a truncated exponential distribution
fit_te <- fit_log_ppmr(barnes_data, "Albacore", distribution = "trunc_exp")
fit_te
#>             alpha       ll       ul       lr       ur  species distribution
#> Albacore 1.520876 3.725438 22.40173 9.694653 3.385282 Albacore    trunc_exp
#>          power min_w_pred
#> Albacore     0          0
# }

# Fit a Gaussian mixture distribution
fit_gm <- fit_log_ppmr(barnes_data, "Albacore", distribution = "gauss_mix")
fit_gm
#>                     p         mean           sd  species distribution power
#> Albacore 0.070044.... 6.783777.... 1.554039.... Albacore    gauss_mix     0
#>          min_w_pred
#> Albacore          0