Calculate the relative percent difference between two population structures. A returned value of zero means that the two population have identical structure.

IRD(pop1, pop2, log = FALSE)

## Arguments

pop1 numeric. Vector of counts from population 1. numeric. Vector of counts from population 2. logical. Default FALSE. Shall we take the mean of the natural log of ratios?

## Value

The value of the index ranging from 0 to infinity.

## Details

Input populations are assumed to be ordered in the same way prior to calling the function. It is only checked that the vectors are of the same length. The input arguments could indeed be populations structured on multiple variables (more than just age), as long as they are ordered in the same way. It is advised to lower the open age group for this method because each age has the same weight. Ages where one population has a zero count and the other does not are thrown out.

If log = TRUE then we return a simple mean of the absolute of the log of the element-wise ratios between pop1 and pop2. In this case it doesn't matter which vector is which. This result is also on a percent scale, and the max is greater than 100.

## Examples

pop1                     <- c(7.38,14.16,14.79,17.36,15.11,10.14,8.50,7.28,5.28)
pop2                     <- c(6.48,12.27,15.25,15.10,14.66,10.80,8.95,9.28,7.21)
IRD(pop1, pop2)     # 6.7 reproduces table 7.20 of Siegel & Swanson (2004)
#>  6.693219IRD(pop1,pop1)      # identical pops  = 0
#>  0IRD(pop1, pop1 * 2) # only structure matters
#>  0pop3                     <- pop1
pop3[1:7]                <- 0
IRD(pop1, pop3)     # theoretical max > 100
#>  116.242