Learn R Programming

rosario (version 0.1.0)

pianka_index: Pianka's niche-overlap index

Description

Computes Pianka's symmetric index of overlap between two non-negative activity profiles \(p\) and \(q\): $$\frac{\sum_i p_i q_i}{\sqrt{\left(\sum_i p_i^2\right)\left(\sum_i q_i^2\right)}}.$$

Usage

pianka_index(p, q)

Value

A single numeric value in [0, 1]; larger values indicate greater overlap.

Arguments

p

Numeric vector of non-negative values (counts or relative frequencies) for the first biological identity data 1 (e.g. activity, population size, etc) across ordered time bins.

q

Numeric vector of non-negative values (same length as p) for the second biological identity (e.g. activity, population size, etc) across ordered time bins.

Details

Pianka's index does not require inputs to sum to 1, but both vectors must be non-negative and not all zero.

Examples

Run this code
set.seed(1)
n <- 10
p <- rpois(n, 3); q <- rpois(n, 3)
pianka_index(p, q)

Run the code above in your browser using DataLab