Package 'actuaryr'

Title: Develop Actuarial Models
Description: Actuarial reports are prepared for the last day of a specific period, such as a month, a quarter or a year. Actuarial models assume that certain events happen at the beginning or end of periods. The package contains functions to easily refer to the first or last (working) day within a specific period relative to a base date to facilitate actuarial reporting and to compare results.
Authors: Zuzanna Chmielewska [aut, cre]
Maintainer: Zuzanna Chmielewska <[email protected]>
License: MIT + file LICENSE
Version: 1.1.1
Built: 2025-02-17 05:46:39 UTC
Source: https://github.com/cran/actuaryr

Help Index


Create an interest rates curve

Description

Creates an object of class ircurve which represents in interest rates curve. The curve cosists of interest rates and is of type either "forward" or "spot". The interest rates curve can be for monthly or yearly periods.

Usage

as_ircurve(rates = double(), type = "forward", period = "year")

Arguments

rates

vector of rates

type

"forward" or "spot"

period

"year" or "month"

Value

Interest rates curve, an object of class ircurve.

Examples

as_ircurve(c(0.01, 0.015))
as_ircurve(c(0.002, 0.001), type = "spot", period = "month")

Change the period of an interest rates curve

Description

Changes the period of an interest rates curve (object of class ircurve) from year to monthl or vice versa.

Usage

change_period(ircurve, to)

Arguments

ircurve

an object of class ircurve

to

"year" or "month"

Value

An object of class ircurve with changed type.

Examples

my_ircurve <- as_ircurve(rep(0.01, 12), period = "month")
change_period(my_ircurve, to = "year")

Change the type of an interest rates curve

Description

Changes the type of an interest rates curve (object of class ircurve) from forward to spot or vice versa.

Usage

change_type(ircurve, to)

Arguments

ircurve

an object of class ircurve

to

"forward" or "spot"

Value

An object of class ircurve with changed type.

Examples

my_ircurve <- as_ircurve(c(0.1, 0.2, 0.3), type = "spot")
change_type(my_ircurve, to = "forward")

Compare two tables

Description

Returns the effect of comparison of the two tables. It gets common columns and number of rows of the two tables. In case of type mismatches, it coerces the weaker type into a stronger type. The output contains the absolute difference for numerical values and the_same/different for characters.

Usage

compare(x, y)

Arguments

x

the first data frame

y

the second data frame

Value

data frame

Examples

x <- data.frame(
  a = rep(1, 3),
  b = rep(2, 3)
)
y <- data.frame(
  a = rep(2, 3),
  b = rep(2, 3)
)
compare(x, y)

First day of a month

Description

Returns the first day of a month in reference to the base date.

Usage

dref_fdom(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_fdom("2020-09-21")

First day of a quarter

Description

Returns the first day of a quarter in reference to the base date.

Usage

dref_fdoq(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_fdoq("2020-09-21")

First day of an year

Description

Returns the first day of a year in reference to the base date.

Usage

dref_fdoy(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_fdoy("2020-09-21")

First working day of a month

Description

Returns the first working day of a month in reference to the base date.

Usage

dref_fwdom(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_fwdom("2020-11-21")

First working day of a quarter

Description

Returns the first working day of a quarter in reference to the base date.

Usage

dref_fwdoq(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_fwdoq("2020-09-21")

First working day of an year

Description

Returns the first working day of a year in reference to the base date.

Usage

dref_fwdoy(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_fwdoy("2022-09-21")

Last day of a month

Description

Returns the last day of a month in reference to the base date.

Usage

dref_ldom(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_ldom("2020-09-21")

Last day of a quarter

Description

Returns the last day of a month in reference to the base date.

Usage

dref_ldoq(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_ldoq("2020-09-21")

Last day of an year

Description

Returns the last day of a year in reference to the base date.

Usage

dref_ldoy(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_ldoy("2020-09-21")

Last working day of a month

Description

Returns the last working day of a month in reference to the base date.

Usage

dref_lwdom(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_lwdom("2020-10-21")

Last working day of a quarter

Description

Returns the last working day of a quarter in reference to the base date.

Usage

dref_lwdoq(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_lwdoq("2020-09-21")

Last working day of an year

Description

Returns the last working day of a year in reference to the base date.

Usage

dref_lwdoy(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_lwdoy("2022-09-21")

Month to date

Description

Returns the last day of the previous month.

Usage

dref_mtd(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_mtd("2020-09-21")

Quarter to date

Description

Returns the last day of the previous quarter.

Usage

dref_qtd(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_qtd("2020-09-21")

Year to date

Description

Returns the last day of the previous year.

Usage

dref_ytd(date)

Arguments

date

base date in format YYYY-MM-DD

Value

date

Examples

dref_ytd("2020-09-21")

Print ircurve

Description

Print ircurve

Usage

## S3 method for class 'ircurve'
print(x, ...)

Arguments

x

an object of class ircurve

...

further arguments passed to or from other methods

Value

Prints the interest rates curve.

Examples

my_ircurve <- as_ircurve(c(0.022, 0.018))
print(my_ircurve)