getCommunitySlope: Calculate the slope of the community abundance

View source: R/summary_methods.R

getCommunitySlopeR Documentation

Calculate the slope of the community abundance

Description

Calculates the slope of the community abundance through time by performing a linear regression on the logged total numerical abundance at weight and logged weights (natural logs, not log to base 10, are used). You can specify minimum and maximum weight or length range for the species. Lengths take precedence over weights (i.e. if both min_l and min_w are supplied, only min_l will be used). You can also specify the species to be used in the calculation.

Usage

getCommunitySlope(sim, species = NULL, biomass = TRUE, ...)

Arguments

sim

A MizerSim object

species

The species to be selected. Optional. By default all target species are selected. A vector of species names, or a numeric vector with the species indices, or a logical vector indicating for each species whether it is to be selected (TRUE) or not.

biomass

Boolean. If TRUE (default), the abundance is based on biomass, if FALSE the abundance is based on numbers.

...

Arguments passed on to get_size_range_array

min_w

Smallest weight in size range. Defaults to smallest weight in the model.

max_w

Largest weight in size range. Defaults to largest weight in the model.

min_l

Smallest length in size range. If supplied, this takes precedence over min_w.

max_l

Largest length in size range. If supplied, this takes precedence over max_w.

Value

A data.frame with four columns: time step, slope, intercept and the coefficient of determination R^2.

See Also

Other functions for calculating indicators: getMeanMaxWeight(), getMeanWeight(), getProportionOfLargeFish()

Examples

# Slope based on biomass, using all species and sizes
slope_biomass <- getCommunitySlope(NS_sim)
slope_biomass[1, ] # in 1976
slope_biomass[idxFinalT(NS_sim), ] # in 2010

# Slope based on numbers, using all species and sizes
slope_numbers <- getCommunitySlope(NS_sim, biomass = FALSE)
slope_numbers[1, ] # in 1976

# Slope based on biomass, using all species and sizes between 10g and 1000g
slope_biomass <- getCommunitySlope(NS_sim, min_w = 10, max_w = 1000)
slope_biomass[1, ] # in 1976

# Slope based on biomass, using only demersal species and 
# sizes between 10g and 1000g
dem_species <- c("Dab","Whiting", "Sole", "Gurnard", "Plaice",
                 "Haddock", "Cod", "Saithe")
slope_biomass <- getCommunitySlope(NS_sim, species = dem_species, 
                                   min_w = 10, max_w = 1000)
slope_biomass[1, ] # in 1976

sizespectrum/mizer documentation built on April 14, 2024, 3:08 a.m.