The function returns the likelihood of the observed diet (\(\lambda_i\)) the associated probability , and the value of the Petraitirs' W.
The likelihood of the observed diet of individual i is:
$$\lambda_i = \prod_j (\frac{q_j}{p_{ij}})^{n_{ij}}$$
where \(q_j\) is the population proportion of the resource j, \(p_{ij}\) is the proportion of the resource j in the diet of the individual i, and \(n_{ij}\) is the number of items for the individual i and the resource j.
This can be used to calculate a p-value to test the significance of the diet specialization, as \(-2ln(\lambda)\) is distributed as a chi-square with (r-1) degrees of freedom, where r is the number of resource categories.
The generalised likelihood ratio test rejects the null hypothesis for a unilateral alternative hypotesis using significance level \(\alpha\) if:
$$-2ln(\lambda) > \chi^2_{(r-1)}$$
Petraitis' W is computed following:
$$W_i = \lambda_i^{(1/D_i)}$$
where \(D_i\) is the number of diet items recorded in the diet of individual i. This index is a measure of niche width relative to a specified distribution. For a complete generalist individual, \(W_i = 1\), and the value decreases with greater specialization.