Skip to contents

One value per period of one grain, from a first period on, optionally extended past its last period at a constant annual rate: a CPI, a wage index or a claims-inflation index (issue #979, design note docs/design/reserving-inflation.md). Python's CalendarIndex. calendar_index_value() reads the index of the period that contains each month.

Usage

calendar_index(first, values, future_rate = NULL)

calendar_index_value(index, month)

Arguments

first

The first period: "2020" (or the number 2020), "2020H2", "2020Q3" or "2020-07". Its grain is the index's grain.

values

The index in first, then one value per period: finite and positive.

future_rate

The annual rate past the last period, compounded by months from the last period's start: finite and above -1. NULL (the default) leaves a period past the last an error.

index

A calendar_index.

month

Months as "YYYY-MM" labels or dates.

Value

calendar_index(): a calendar_index with the properties first, values, future_rate and periods (the given periods, one per value). calendar_index_value(): a numeric vector, one value per month; an error for a month before the first period, or after the last when there is no future rate.

Examples

cpi <- calendar_index("2020", c(100, 104, 110), future_rate = 0.05)
cpi@periods
#> [1] "2020" "2021" "2022"
calendar_index_value(cpi, c("2021-06", "2024-01"))
#> [1] 104.000 121.275