Open ahhurlbert opened 3 years ago
Actually, it will not be appropriate to divide by the total number of other diet analyses in all cases, because some of those analyses may have been at a taxonomically coarse resolution (e.g. % animal vs % plant; or % insecta) where a given prey item could potentially be included but cannot be broken out.
Thus, it seems the options are:
Concrete example: 3 studies (with 4 analyses) have examined Red-eyed vireo diet by % Occurrence:
If asked for a summary regarding the importance of caterpillars in the diet, the mean % occurrence returned should simply be 56.8%, rather than (56.8 + 0 + 0 + 0)/4 = 14%.
Updated code now calculates a species mean using all studies that identified at least some prey down to the taxonomic level of the preyName. Thus, in the example above, Parrish and Blake & Loiselle would not be included in the calculation of mean.
One potential problem would be a case that only identified arthropods down to "Insecta", but identified fruits down to Family. The current code would include that study in the count of studies to divide by even though "Lepidoptera" should not be considered to be 0% in that study.
The most appropriate solution would be to identify the taxonomic entity immediately above preyName, and then include the study in the denominator only if there is at least one record of a prey item that belongs to a group at the level of preyLevel within that higher taxonomic entity. (E.g., if there was an entry for Coleoptera, but not Lepidoptera, then Lepidoptera could properly be interpreted as 0%.)
Currently,
dietSummaryByPrey()
The problem is that this average does not take into account all of the analyses for the focal bird species where the specified prey item was not consumed at all.
Take the example of Cedar Waxwings consuming caterpillars:
They appear to be at the top of the list because there is one study with two analyses finding 84% and 89% caterpillars in the diet (a spruce budworm outbreak).
However,
speciesSummary()
Because there were 18 other diet analyses where caterpillars made up 0%, the species summary accurately suggests that caterpillars only make up 8.65%.
Dealing with this in
dietSummaryByPrey()
will be potentially be slow because we will have to almost rundietSummary()
for every bird species that has ever eaten the specified prey...