You can load actuaryr
package with:
First and last days of months, quarters and years are of special meaning for business reporting.
The business reports are usually created for the last day of some period, like a month or a year. They enclose data for the first day of this period up to the last. If you create your report in the middle of the period, you may need to quickly refer to these dates.
The dref_
prefix stands for date reference functions. The functions with the dref_
prefix return a reference date to the base date.
The functions work within three types of periods:
The functions return one of the four types of reference dates:
The names of functions combine the dref_
prefix and the first letters of the chosen reference date.
For example, dref_fdoy()
returns the first day of an year.
The table summarizes all date reference functions.
of month | of quarter | of year | |
---|---|---|---|
first day | dref_fdom() |
dref_fdoq() |
dref_fdoy() |
first working day | dref_fwdom() |
dref_fwdoq() |
dref_fwdoy() |
last day | dref_ldom() |
dref_ldoq() |
dref_ldoy() |
last working day | dref_lwdom() |
dref_lwdoq() |
dref_lwdoy() |
All functions take the argument date
, which is the base date. The functions return the result in reference to the base date. The functions always work within a specific period: a month, a quarter or an year.
The reference dates in the image below can be retrieved with the following functions:
dref_fdom()
- dark bluedref_fwdom()
- light bluedref_ldom()
- light greendref_lwdom()
- dark greenThe base date has been marked with orange.
The reference dates in the image below can be retrieved with the following functions:
dref_fdoq()
- dark bluedref_fwdoq()
- light bluedref_ldoq()
- light greendref_lwdoq()
- dark greenThe base date has been marked with orange.
Watch out! The first day in this time period is the same as the first working day in this time period. The last day of this time period is the same as the last working day of this time period. Hence, the same day is marked with two colors (darker and lighter).
The reference dates in the image below can be retrieved with the following functions:
dref_fdoy()
- dark bluedref_fwdoy()
- light bluedref_ldoy()
- light greendref_lwdoy()
- dark greenThe base date has been marked with orange.
Watch out! The first day in this time period is the same as the first working day in this time period. The last day of this time period is the same as the last working day of this time period. Hence, the same day is marked with two colors (darker and lighter).
The functions return the last day of the previous month, quarter or year. These functions might be of use if you are preparing, for example, the results for the first quarter of 2020 (Q1 2020) and want to compare them against the year-end results (YE 2019).
The functions are:
dref_mtd()
- returns month-to-datedref_qtd()
- returns quarter-to-datedref_ytd()
- returns year-to-dateThere is no distinction between days and working days. dref_mtd()
, dref_qtd()
and dref_ytd()
always return the last day of the preceding time period.
In the images below, the base dates have been marked with orange and the reference dates have been marked with green.
A big chunk of actuarial life consists of comparing things.
After preparing assumptions tables and policy data for valuation models, it’s useful to check how they change over a reporting period to understand the magnitude of movements.
Also during the model development, it’s important to understand the impact of the development on the results. The regression analysis helps to understand the impact of each step.
The following approach is used within compare()
:
the_same
or different
is returned.