The function make_diet_rand
generates a specified number of random
diet compositions to support simulation-based research of the performance
of QFASA diet estimation procedures. Given a diet composition, predator
fatty acid signatures can be generated using the
function make_pred_sigs
. The diets of such simulated predators
can then be estimated, and the diet estimates can be compared to the
known diet composition to evaluate bias, variance, and perhaps other
properties.
The algorithm starts by generating a uniformly distributed random number
between 0 and 1 as the diet proportion for the first prey type. The algorithm
then considers each additional prey type in turn, generating a uniform random
number between zero and 1 minus the sum of the proportions assigned to the
preceding prey types. The diet proportion for the last prey type is 1 minus
the sum of the other diet proportions. As a hedge against limitations in the
random number generator, the proportions are then randomly ordered among prey
types.
It is critical that the prey-type names match those in the prey library. The
easiest way to ensure this happens is to pass the object uniq_types returned
a call to the function prep_sig
as the uniq_types argument.
Alternatively, and more risky, a vector of unique prey names can be created
using the concatenate function and cast as a factor, i.e.,
uniq_types <- as.factor(c("Prey_1", "Prey_2", ..., "Prey_P)).