The procedure calculates the estimation of likelihood measures of niche breadth and overlap described in Petraitis (1979).

1 | ```
like.Wi(dataset)
``` |

`dataset ` |
Object of class RInSp with data. |

The function returns the likelihood of the observed diet (*λ_i*) the associated probability , and the value of the Petraitirs' W.
The likelihood of the observed diet of individual *i* is:

*λ_i = ∏_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(λ)* 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 *α* if:

*-2ln(λ) > χ^2_{(r-1)}*

Petraitis' W is computed following:

*W_i = λ_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.

Return a list of class RInSp with:

`MeanWi` |
the mean population value of Wi; |

`ResCat` |
the number of resource categories; |

`ind.vals` |
A matrix with three columns: “Likelihood” with value of the likelihood index for the individual |

Dr. Nicola ZACCARELLI

Petraitis, P. S. 1979. Likelihood measures of niche breadth and overlap. *Ecology* **60**(4): 703-710.

Bolnick, D.I., L.H. Yang, J.A. Fordyce, J.M. Davis, and Svanback, R. 2002. Measuring individual-level resource specialization. *Ecology* **83**: 2936-2941.

1 2 3 4 5 6 7 8 | ```
# Likelihood and Wi example with stickleback data
# from Bolnick and Paull 2009
data(Stickleback)
# Select a single spatial sampling site (site D)
SiteD = import.RInSp(Stickleback, row.names = 1,
info.cols = c(2:13), subset.rows = c("Site", "D"))
Wi = like.Wi(SiteD)
rm(list=ls(all=TRUE))
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.