From 358881e62a72be36344a30b8551276c1b9ca06c0 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Sun, 16 Aug 2020 10:47:17 +0200 Subject: [PATCH] More documentation work... --- R/InsuranceParameters.R | 2 ++ R/ProfitParticipation.R | 7 +++++ R/ProfitParticipation_Functions.R | 14 ++++++++++ man/InsuranceContract.ParametersFallback.Rd | 3 +++ man/ProfitParticipationFunctions.Rd | 30 +++++++++++++++++++++ man/filterProfitRates.Rd | 16 +++++++++++ 6 files changed, 72 insertions(+) create mode 100644 man/filterProfitRates.Rd diff --git a/R/InsuranceParameters.R b/R/InsuranceParameters.R index 3fac537..95cf945 100644 --- a/R/InsuranceParameters.R +++ b/R/InsuranceParameters.R @@ -489,6 +489,8 @@ InsuranceContract.ParametersFill = function(params = InsuranceContract.Parameter #' will be filled with the corresponding entry from \code{fallback}. #' @param fallback Fallback values that will be used when the corresponding #' entry in \code{params} is NULL. +#' @param ppParameters Whether profit participation parameters should also be +#' filled (default is TRUE) #' #' @export InsuranceContract.ParametersFallback = function(params, fallback, ppParameters = TRUE) { diff --git a/R/ProfitParticipation.R b/R/ProfitParticipation.R index 3f162b3..c6c2d7c 100644 --- a/R/ProfitParticipation.R +++ b/R/ProfitParticipation.R @@ -6,6 +6,13 @@ NULL # Shut up the package checker: # if (getRversion() >= "2.15.1") utils::globalVariables(c("profitClass")) +#' Filter the whole data.frame of profit rates for the given profit classes +#' +#' This is a rather trivial helper function, which just calls [dplyr::filter()]. +#' +#' @param rates data.frame containing all profit rates for multiple profit classes +#' @param classes the profit classes, for which rates should be extracted +#' #' @export filterProfitRates = function(rates, classes) { dplyr::filter(.data = rates, .data$profitClass %in% classes) diff --git a/R/ProfitParticipation_Functions.R b/R/ProfitParticipation_Functions.R index d36f61a..c53790f 100644 --- a/R/ProfitParticipation_Functions.R +++ b/R/ProfitParticipation_Functions.R @@ -16,6 +16,11 @@ NULL #' scheme and the contract) #' @param values Contract values calculated so far (guaranteed component of the #' insurance contract, including cash flows, premiums, reserves etc.). +#' @param ... Other values that might be used for the calculation (currently unused) +#' +#' @param base The profit calculation base, on which the rate is to be applied +#' @param rate The profit participation rate +#' @param waiting A possible waiting period NULL shiftBy = function(rate, n = 1) { @@ -91,6 +96,8 @@ PP.base.sumInsured = function(rates, params, values, ...) { #' @describeIn ProfitParticipationFunctions #' Basis for Terminal Bonus Fund Assignment: total profit assignment of the year +#' +#' @param res the data.frame of reserves. #' @export PP.base.totalProfitAssignment = function(res, ...) { res[,"totalProfitAssignment"] @@ -180,6 +187,13 @@ PP.rate.interestProfit2 = function(rates, ...) { # TODO +#' @describeIn ProfitParticipationFunctions +#' +#' Calculate the terminal bonus reserve. +#' @param profits The data.frame of profits assigned +#' @param terminalBonus The terminal bonus calculated +#' @param terminalBonusAccount The terminal bonus account (like a bank account, +#' where terminal bonuses are accrued, potentiall discounted from the maturity) getTerminalBonusReserve = function(profits, rates, terminalBonus, terminalBonusAccount, params, values, ...) { n = length(terminalBonusAccount) terminalBonusAccount * 1/(1.07) ^ ((n - 1):0) diff --git a/man/InsuranceContract.ParametersFallback.Rd b/man/InsuranceContract.ParametersFallback.Rd index 12f96b1..155ba46 100644 --- a/man/InsuranceContract.ParametersFallback.Rd +++ b/man/InsuranceContract.ParametersFallback.Rd @@ -12,6 +12,9 @@ will be filled with the corresponding entry from \code{fallback}.} \item{fallback}{Fallback values that will be used when the corresponding entry in \code{params} is NULL.} + +\item{ppParameters}{Whether profit participation parameters should also be +filled (default is TRUE)} } \description{ Provide default values for the insurance contract parameters if any of the diff --git a/man/ProfitParticipationFunctions.Rd b/man/ProfitParticipationFunctions.Rd index efbf420..7b53f37 100644 --- a/man/ProfitParticipationFunctions.Rd +++ b/man/ProfitParticipationFunctions.Rd @@ -22,6 +22,7 @@ \alias{PP.rate.totalInterest} \alias{PP.rate.totalInterest2} \alias{PP.rate.interestProfit2} +\alias{getTerminalBonusReserve} \alias{PP.calculate.RateOnBase} \alias{PP.calculate.RateOnBaseMin0} \alias{PP.calculate.RatePlusGuaranteeOnBase} @@ -80,6 +81,16 @@ PP.rate.totalInterest2(rates, ...) PP.rate.interestProfit2(rates, ...) +getTerminalBonusReserve( + profits, + rates, + terminalBonus, + terminalBonusAccount, + params, + values, + ... +) + PP.calculate.RateOnBase(base, rate, waiting, rates, params, values, ...) PP.calculate.RateOnBaseMin0(base, rate, waiting, rates, params, values, ...) @@ -137,6 +148,23 @@ scheme and the contract)} \item{values}{Contract values calculated so far (guaranteed component of the insurance contract, including cash flows, premiums, reserves etc.).} + +\item{...}{Other values that might be used for the calculation (currently unused)} + +\item{res}{the data.frame of reserves.} + +\item{profits}{The data.frame of profits assigned} + +\item{terminalBonus}{The terminal bonus calculated} + +\item{terminalBonusAccount}{The terminal bonus account (like a bank account, +where terminal bonuses are accrued, potentiall discounted from the maturity)} + +\item{base}{The profit calculation base, on which the rate is to be applied} + +\item{rate}{The profit participation rate} + +\item{waiting}{A possible waiting period} } \description{ Various helper functions for the \code{ProfitParticipation} class that @@ -185,6 +213,8 @@ the rates and how the assigned profit is calculated. \item \code{PP.rate.interestProfit2}: Rate for interest on past profits: second interest profit rate (not including guaranteed interest), keyed by year +\item \code{getTerminalBonusReserve}: Calculate the terminal bonus reserve. + \item \code{PP.calculate.RateOnBase}: Calculate profit by a simple rate applied on the basis (with an optional waiting vector of values 0 or 1) \item \code{PP.calculate.RateOnBaseMin0}: Calculate profit by a simple rate applied on the basis (with an optional waiting vector of values 0 or 1), bound below by 0 diff --git a/man/filterProfitRates.Rd b/man/filterProfitRates.Rd new file mode 100644 index 0000000..b6a8b26 --- /dev/null +++ b/man/filterProfitRates.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ProfitParticipation.R +\name{filterProfitRates} +\alias{filterProfitRates} +\title{Filter the whole data.frame of profit rates for the given profit classes} +\usage{ +filterProfitRates(rates, classes) +} +\arguments{ +\item{rates}{data.frame containing all profit rates for multiple profit classes} + +\item{classes}{the profit classes, for which rates should be extracted} +} +\description{ +This is a rather trivial helper function, which just calls \code{\link[dplyr:filter]{dplyr::filter()}}. +} -- GitLab