diff --git a/R/InsuranceParameters.R b/R/InsuranceParameters.R index f58adaef5b5562bd4bd1b69cc115f46fbfe0aa1b..22f85b802b8a467bf710bb59aab43c4cd3b5f462 100644 --- a/R/InsuranceParameters.R +++ b/R/InsuranceParameters.R @@ -359,7 +359,7 @@ InsuranceContract.Values = list( #' the end of the contract, a vector of numeric values indicates #' yearly survival benefits (not neccessarily with a survival #' payment at the end of the contract). Can be set to a \code{function(len, -#' params, values)} returning the benefit as a numeric value or vector. +#' params, values)} returning the benefit as a numeric value or vector.} #' \item{\code{$benefitParameter}}{(optional) Tariff-specific parameter to #' indicate special benefit conditions (e.g. for non-constant benefits #' the initial starting value, or a minimum benefit, etc.). This @@ -570,7 +570,7 @@ InsuranceContract.Values = list( #' \item{\code{$adjustPremiums}}{Adjust the resulting premiums. \code{function(premiums = list(premiums, coefficients, sumInsured), params, values)}} #' \item{\code{$adjustPVForReserves}}{Adjust the absolute present value vectors used to derive reserves (e.g. when a sum rebate is subtracted from the gamma-cost reserves without influencing the premium calculation). \code{function(absPV, params, values)}} #' \item{\code{$premiumRebateCalculation}}{Calculate the actual premium rebate from the rebate rate (e.g. when the premium rate is given as a yearly cost reduction applied to a single-premium contract). \code{function(premiumRebateRate, params = params, values = values)}} -#' \item{\code{$Rounding}}{A [RoundingHelper] object to specify rounding of intermediate values. Alternatively, a named list of rounding specifications can be given, which is used to construct a new [RoundingHelper] object.}} +#' \item{\code{$Rounding}}{A [RoundingHelper] object to specify rounding of intermediate values. Alternatively, a named list of rounding specifications can be given, which is used to construct a new [RoundingHelper] object.} #' } #' #' diff --git a/R/InsuranceTarif.R b/R/InsuranceTarif.R index 0b95b2fb3ff2370608297785b1c555ad7ffe15d3..aefcd3c82dde2de6fa2f67d3c8a43dde8955764f 100644 --- a/R/InsuranceTarif.R +++ b/R/InsuranceTarif.R @@ -501,6 +501,7 @@ InsuranceTarif = R6Class( #' - a single numeric value indicates a single survival payment at the end of the contract #' - a vector of numeric values indicates potentially multiple survival payments for the whole contract period (paddded with 0 to the full contract length if shorter) #' @details Not to be called directly, but implicitly by the [InsuranceContract] object. + #' @param len The desired length of the returned data frame (the number of contract periods desired) getSurvivalCF = function(len, params, values) { if (getOption('LIC.debug.getSurvivalCF', FALSE)) { browser(); @@ -509,11 +510,11 @@ InsuranceTarif = R6Class( if (is.null(benefit)) { benefit = 1 } - + if (is.vector(benefit) && length(benefit) == 1) { c(rep(0, len - 1), benefit) } else { - # If survivalBenefit is (or returns) a vector, treat it as yearly + # If survivalBenefit is (or returns) a vector, treat it as yearly # survival payments, pad it to the desired length pad0(benefit, len) } diff --git a/man/InsuranceContract.ParameterDefaults.Rd b/man/InsuranceContract.ParameterDefaults.Rd index 6058f9b55d98bc915828e2fde1ce25a3df0f8a4b..50e0ed14a1cf77955a27632ec3c1cb9849675d54 100644 --- a/man/InsuranceContract.ParameterDefaults.Rd +++ b/man/InsuranceContract.ParameterDefaults.Rd @@ -117,7 +117,7 @@ A single numeric value indicates a single survival benefit at the end of the contract, a vector of numeric values indicates yearly survival benefits (not neccessarily with a survival payment at the end of the contract). Can be set to a \code{function(len, - params, values)} returning the benefit as a numeric value or vector. + params, values)} returning the benefit as a numeric value or vector.} \item{\code{$benefitParameter}}{(optional) Tariff-specific parameter to indicate special benefit conditions (e.g. for non-constant benefits the initial starting value, or a minimum benefit, etc.). This @@ -331,6 +331,7 @@ participation rates are defined at the level of profit classes.} \item{\code{$adjustPremiums}}{Adjust the resulting premiums. \code{function(premiums = list(premiums, coefficients, sumInsured), params, values)}} \item{\code{$adjustPVForReserves}}{Adjust the absolute present value vectors used to derive reserves (e.g. when a sum rebate is subtracted from the gamma-cost reserves without influencing the premium calculation). \code{function(absPV, params, values)}} \item{\code{$premiumRebateCalculation}}{Calculate the actual premium rebate from the rebate rate (e.g. when the premium rate is given as a yearly cost reduction applied to a single-premium contract). \code{function(premiumRebateRate, params = params, values = values)}} +\item{\code{$Rounding}}{A \link{RoundingHelper} object to specify rounding of intermediate values. Alternatively, a named list of rounding specifications can be given, which is used to construct a new \link{RoundingHelper} object.} } } } diff --git a/man/InsuranceContract.ParameterStructure.Rd b/man/InsuranceContract.ParameterStructure.Rd index a058cf4c3db6a9ebef2f81df33a33293fdf2ced9..e02511618bc07ea13ac930e92c1a763a8fa23343 100644 --- a/man/InsuranceContract.ParameterStructure.Rd +++ b/man/InsuranceContract.ParameterStructure.Rd @@ -5,7 +5,7 @@ \alias{InsuranceContract.ParameterStructure} \title{Full insurance contract parameter structure.} \format{ -An object of class \code{list} of length 10. +An object of class \code{list} of length 9. } \usage{ InsuranceContract.ParameterStructure diff --git a/man/InsuranceTarif.Rd b/man/InsuranceTarif.Rd index 0de7e6e8a14623f73bee73832a21d2881d1e2cba..558f212117b6b9a34a235fa0dbef68aeb81b2adb 100644 --- a/man/InsuranceTarif.Rd +++ b/man/InsuranceTarif.Rd @@ -548,6 +548,8 @@ period (after potential deferral period!) \subsection{Arguments}{ \if{html}{\out{<div class="arguments">}} \describe{ +\item{\code{len}}{The desired length of the returned data frame (the number of contract periods desired)} + \item{\code{params}}{Contract-specific, full set of parameters of the contract (merged parameters of the defaults, the tariff, the profit participation scheme and the contract)} diff --git a/vignettes/using-the-lifeinsurer-package.Rmd b/vignettes/using-the-lifeinsurer-package.Rmd index 609f3f59e56d2331e1f40c9a0910cb0dd5b10845..420dd6274f9ac48813da02e393e637068c267e01 100644 --- a/vignettes/using-the-lifeinsurer-package.Rmd +++ b/vignettes/using-the-lifeinsurer-package.Rmd @@ -1178,9 +1178,10 @@ one can use the setting `Rounding = list("Premium gross" = 0, "Premium net" = 2) ```{r RoundingHelper.Contract} Tarif.EndowmentSI = InsuranceTarif$new( - type = "endowment", + type = "pureendowment", tarif = "Endow1", age = 40, policyPeriod = 20, + premiumRefund = 1, mortalityTable = mort.AT.census.2011.unisex, cost = initializeCosts(alpha = 0.04, gamma.contract = 0.0005), @@ -1189,19 +1190,23 @@ Tarif.EndowmentSI = InsuranceTarif$new( contractClosing = as.Date("2020-09-01") ) Tarif.EndowmentSI.rounded = Tarif.EndowmentSI$createModification( - Rounding = list("Premium gross" = 0, "Premium net" = 2) + Rounding = list("Premium gross unit" = 3, "Premium net unit" = 6, "Premium net" = 2) ) Contract.sumInsured = InsuranceContract$new(tarif = Tarif.EndowmentSI) Contract.sumInsured.rounded = InsuranceContract$new(tarif = Tarif.EndowmentSI.rounded) # premiums of the original tariff: -Contract.sumInsured$Values$premiums[c("unit.net", "net", "unit.gross", "gross")] -# premiums of the tariff with rounding applied: -Contract.sumInsured.rounded$Values$premiums[c("unit.net", "net", "unit.gross", "gross")] - +Contract.sumInsured$Values$premiums[c("unit.net", "-1et", "unit.gross", "gross")] ``` +This rounding is applied immediately when the corresponding entity is calculated. +As a consequence, all further calculations depending on the entity will also be +affected. This means that e.g. rounding only the gross premium will also have a +slight effect on the net premium with contracts that grant premium refunds in +case of death, as the example above shows. + + Here is a list of all rounding IDs used throughout the InsuranceTarif class. Each of them can be used to adjust rounding just one particular value/vector: