Calculate annualized rate of change from one vector which includes numeric year and another vector which includes values of some measure for those years.
arc(years, values, denominator = 100)
years | [ |
---|---|
values | [ |
denominator | [ |
[numeric()
]
Annualized rate of change for the intervals between elements of years
.
ARC for the period between years i and j is calculated as:
$$arc[i,j] = 100 * ln(value_j / value_i) / (year_j - year_i)$$
Index is such that for index i, output[i]
is arc for period years[i - 1]
to years[i]
and the first entry in the output is NA
.
This function does not sort years
so users should check inputs are
ordered correctly.
Preston Demography textbook Chapter 1
https://www.un.org/esa/sustdev/natlinfo/indicators/methodology_sheets/demographics/population_growth_rate.pdf
#> [1] NA 13.862944 4.462871# data.table library(data.table) dt <- data.table( year = c(2000, 2005, 2010), val = c(10, 20, 25) ) dt[, arc := arc(years = year, values = val)]#> year val arc #> 1: 2000 10 NA #> 2: 2005 20 13.862944 #> 3: 2010 25 4.462871