The utility function pm_obj_func
computes the total distance between
observed predator signatures and vector of mean diet proportions common to
all predators.
pm_obj_func(diet, obs_sig, mean_sigs, dist_meas = 1, gamma = 1)
A numeric vector of mean diet composition.
A numeric matrix containing observed predator signatures, in column-major format.
A numeric matrix of the mean fatty acid signature for each prey type in the prey library, in column-major format.
An integer indicator of the distance measure to compute. Default value 1.
The power parameter of the chi-square distance measure. Default value 1.
The total distance between observed and modeled signatures.
This is an internal utility function. Consequently, to increase execution
speed, no numeric error checking is performed within pm_obj_func
.
Rather, error checking is presumed to have occurred at a higher level in the
calling sequence.
The argument obs_sig
is presumed to be a matrix of predator
signatures that has been prepared for analysis, which is best accomplished
by a call to the function prep_sig
with the predator data.
Similarly, the contents of mean_sigs
should be mean signatures computed
from signatures that were prepared for analysis by a call to the function
prep_sig
.
The argument diet
is presumed to contain non-negative proportions that
sum to 1.0.
The arguments dist_meas
and gamma
must be compatible with the
function dist_between_2_sigs
.
Please refer to the vignette and documentation for the functions
prep_sig
, sig_scale
, and
dist_between_2_sigs
for additional details.
diet_obj_func
models a predator signature as a mixture of the mean
prey-type signatures, with the diet proportions as the mixture proportions,
returning the distance between the observed and modeled signatures. The
diet composition of a predator is estimated by minimizing this function with
respect to the diet
using the function Rsolnp::solnp.