The utility function diet_obj_func computes the distance between an
observed fatty acid signature and a modeled signature computed as a mixture
of mean prey signatures.
diet_obj_func(diet, obs_sig, mean_sigs, dist_meas = 1, gamma = 1)A numeric vector of diet composition.
A numeric vector containing an observed fatty acid signature.
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 distance between the observed and modeled signatures.
This is an internal utility function. Consequently, to increase execution
speed, no numeric error checking is performed within diet_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 fatty acid signature that has
been prepared for analysis, which is best accomplished by a call to the
function prep_sig with the predator data frame. Similarly,
the contents of mean_sig should be mean signatures computed from
signatures that were prepared for analysis by 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.