WTcMC: Monte Carlo resampling of WIC/TNW for the continuous case

View source: R/WTcMC.R

WTcMCR Documentation

Monte Carlo resampling of WIC/TNW for the continuous case


The program calculates the Total Niche Width (TNW), and breaks TNW down into its Between Individual Component (BIC) and Within Individual Component (WIC). It reports these three statistics and the proportion WIC/TNW. Niche widths of the population, within individuals, and among individuals are calculated following Roughgarden's formulas (1974).

A Monte Carlo resampling routine is used to calculate a null distribution for each of these statistics and generate a p-value testing the null hypothesis that all individuals sample equally from the population diet distribution.


WTcMC(dataset, replicates = 999, weight = "equal", print.ris=TRUE)



Object of class RInSp with data of type “double”.


Number of replicates for the Monte Carlo resampling.


The weighting scheme for individuals. Default value is “equal”. Alternative value is “N_items”.


Printing results to screen. Default is TRUE.


Roughgarden (1972) suggested that the total niche width of a population (TNW) can be broken down into two components: the variation in resource use within individuals (within-individual component, WIC), and the variance between individuals (between-individual component, BIC) so that TNW = WIC + BIC. Originally developed for within- and between-phenotype (or between-sex) variation, it can be applied at the individual level. Assuming that variation in niche parameters can be expressed along a single continuous dimension x (e.g., prey size), let X be a matrix of diet data where each element x_{ij} is the size (or other measure) of the jth prey item in individual i's diet. Then,

TNW = Var(x_{ij})

WIC = E(Var(x_j | i))

BIC = Var(E(x_j | i))

The relative degree of individual specialization can be measured as the proportion of TNW explained by within-individual variation, WIC/TNW. As this value approaches 1, all individuals utilize the full range of the population's niche, whereas smaller values indicate decreasing inter-individual overlap and hence higher individual specialization.

Roughgarden's WIC/TNW is limited to continuous diet data. To carry this approach over to discrete data such as the frequency of alternate prey taxa in the diet, Roughgarden (1979:510) proposed a measure that uses the Shannon-Weaver index as a proxy for variance (See WTdMC for details).

In case of a marked presence of individuals with one or few prey items, the relation TNW = BIC + WIC may not hold. In this case there is the option to weight the number of items per individuals following two alternatives:

- “equal”: weighting by the number of items in each individual's diet, so those with more data contribute more to estimating parameters;
- “N_items”: weighting each individual equally regardless of diet items number; requires weighting each diet item by the inverse of the number of items in the individual's diet for calculating TNW.

The Monte Carlo resampling procedure first determines the number of prey used by each individual, n_i. Subsequently, the procedure randomly reassigns each individual n_i prey items drawn from the population distribution of items. This is repeated a user-specified number of times. Hence, the resampled population yields a null model corresponding to a population composed of generalists that sample randomly from the population's diet, and have diet sizes equal to those of the observed data set. The original statistics are merged into the Monte Carlo set.


The result is a list of class “RInSp”composed of:


The value of WIC/TNW for the dataset “dataset”.


The Monte Carlo resampling probability value for the calculated WIC/TNW ratio.


is a matrix with the replicate number ‘REP’, the value of ‘WIC’, the value of ‘BIC’, the value of ‘TNW’ and the derived value for ‘WonT’. The first line holds the values for the provided dataset, and the following lines the results of the Monte Carlo resampling.


The weighting scheme for individuals used.


An index used in sumMC.RInSp to point to the column of the matrix ‘montecarlo’ for plotting results.


Dr. Nicola ZACCARELLI. Please note that the C code is partially based on the C++ source of IndSpec from Bolnick et al. (2002). For the “weight” option Travis Ingram is acknowledged (Ingram et al. 2011).

The original source code of IndSpec1.0 is available from the “Ecological Archives” of the Ecological Society of America ( identifier E083-056-S1;


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.

Ingram,T., Stutz, W.E., Bolnick, D.I. 2011. Does intraspecific size variation in a predator affects its diet diversity and top-down control of prey? PLoS ONE 6: e20782.

Roughgarden, J. 1974. Niche width: biogeographic patterns among Anolis lizard populations. American Naturalist 108: 429-411.

See Also

Function sumMC.RInSp.


# Example of analysis with the trout data from Finland
TroutRIS <- import.RInSp(Trout, col.header=TRUE, row.names=1, info.cols=2, data.type="double")
# Warning, the number of replicates is set low to speed up he example!
# Note, for real analyses we recommend to set replicates => 999
TroutRIS_MC <- WTcMC(TroutRIS, replicates = 99)

RInSp documentation built on May 20, 2022, 9:06 a.m.