Skip to contents

Indexing payments to another year

Usage

apply_index(payments, original_cal_years, new_cal_years, indices)

Arguments

payments

numeric vector of payments to index

original_cal_years

vector containing payments' original calendar years

new_cal_years

vector containing calendar years to index to

indices

dataframe containing transition factors for each element of original_cal_years and new_cal_years, see details

Value

numeric vector with indexed payments

Details

The Dataframe indices must contain at least the two columns 'Calendar_year' and 'Transition_factor'.
The transition_factor for year j indexes a payment of year j to the niveau of payments in a fixed index year i.

Examples

# for a constant inflation of 2% and index year 2022
indices <- data.frame(Calendar_year = 2015:2023,
                      Index_gross = rep(0.02, 9))
indices$Transition_factor <- cumprod(1 + indices$Index_gross) /
                               cumprod(1 + indices$Index_gross)[indices$Calendar_year == 2022]
indices
#>   Calendar_year Index_gross Transition_factor
#> 1          2015        0.02         0.8705602
#> 2          2016        0.02         0.8879714
#> 3          2017        0.02         0.9057308
#> 4          2018        0.02         0.9238454
#> 5          2019        0.02         0.9423223
#> 6          2020        0.02         0.9611688
#> 7          2021        0.02         0.9803922
#> 8          2022        0.02         1.0000000
#> 9          2023        0.02         1.0200000
apply_index(1000, 2022, 2023, indices)
#> [1] 1020
apply_index(payments = rep(1000, 5),
            original_cal_years = 2017:2021,
            new_cal_years = rep(2020, 5),
            indices = indices)
#> [1] 1061.2080 1040.4000 1020.0000 1000.0000  980.3922