period_to_months {insurancerating} | R Documentation |
Split period to months
Description
The function splits rows with a time period longer than one month to multiple rows with a time period of exactly one month each. Values in numeric columns (e.g. exposure or premium) are divided over the months proportionately.
Usage
period_to_months(df, begin, end, ...)
Arguments
df |
data.frame |
begin |
column in |
end |
column in |
... |
numeric columns in |
Details
In insurance portfolios it is common that rows relate to periods longer than one month. This is for example problematic in case exposures per month are desired.
Since insurance premiums are constant over the months, and do not depend on the number of days per month, the function assumes that each month has the same number of days (i.e. 30).
Value
data.frame with same columns as in df
, and one extra column
called id
Author(s)
Martin Haringa
Examples
library(lubridate)
portfolio <- data.frame(
begin1 = ymd(c("2014-01-01", "2014-01-01")),
end = ymd(c("2014-03-14", "2014-05-10")),
termination = ymd(c("2014-03-14", "2014-05-10")),
exposure = c(0.2025, 0.3583),
premium = c(125, 150))
period_to_months(portfolio, begin1, end, premium, exposure)