calcLikeSegments: Calculate MLEs and 95\ of a data set

View source: R/likelihood.R

calcLikeSegmentsR Documentation

Calculate MLEs and 95\ of a data set

Description

Rather than trying to estimate a single MLE of b across an entire data set, it may make more sense fitting the PLB distribution independently across segments (distinct ranges) of the data. For example, if the full range of body sizes are not collected using the same sampling protocols, such as when combining phytoplankton and zooplankton data. Data are input as EITHER vectors w and d of bin breaks and bin counts, OR as a tibble with one row for each bin and columns as described below.

Usage

calcLikeSegments(
  p = -1.5,
  w = NULL,
  d = NULL,
  bin_tibble = NULL,
  segmentIndices,
  ...
)

Arguments

p

initial value of b for the numerical optimisation

w

vector of length J+1 giving the bin breaks ⁠w_1, w_2, ..., w_{J+1}⁠

d

vector of length J giving the count in each bin; must have d_1, d_J > 0

bin_tibble

data as a tibble, with each row representing a bin and columns:

  • wmin: minimum body mass of that bin

  • wmax: maximum body mass of that bin

  • binCount: count in that bin

segmentIndices

the indices of w or bin_tibble$wmin to use as breakpoints to separate the range of body masses into distinct segments to be fit separately; must have first element 1 and last element the value of J+1. MAYBE CHANGE? CHECK ME: Segments are assigned based on minima of bins being ⁠>= w[segmentIndices]⁠, so we end up with S = length(segmentIndices) - 1 segments. Thus, w[segmentIndices[i]] is the minimum of segment i.

...

further inputs to negLL.PLB.binned *** TODO maybe?

Value

list containing:

  • bins_in_segs: tibble with a row for each bin and columns (this is bin_tibble with the extra column segment):

    • wmin: minimum body mass of that bin

    • wmax: maximum body mass of that bin

    • binCount: count in that bin

    • segment: which segment the bin falls in, an integer from 1 to S

  • b_segs: tibble of results with a row for each segment and columns:

    • segment: integer indicating the segment being fitted

    • segMin: mininum body mass of that segment

    • segMax: maximum body mass of that segment

    • confMin: minimum of 95\

    • b: MLE for b for that segment

    • confMax: maximum of 95\

Author(s)

Andrew Edwards


andrew-edwards/sizeSpectra documentation built on June 28, 2023, 7:09 p.m.