From a7ec545752fc41dbf9e500484f9d53071040384f Mon Sep 17 00:00:00 2001
From: Reinhold Kainhofer <reinhold@kainhofer.com>
Date: Sat, 25 Nov 2023 23:47:12 +0100
Subject: [PATCH] Fix Docs syntax error

---
 R/InsuranceParameters.R                     |  4 ++--
 R/InsuranceTarif.R                          |  5 +++--
 man/InsuranceContract.ParameterDefaults.Rd  |  3 ++-
 man/InsuranceContract.ParameterStructure.Rd |  2 +-
 man/InsuranceTarif.Rd                       |  2 ++
 vignettes/using-the-lifeinsurer-package.Rmd | 17 +++++++++++------
 6 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/R/InsuranceParameters.R b/R/InsuranceParameters.R
index f58adae..22f85b8 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 0b95b2f..aefcd3c 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 6058f9b..50e0ed1 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 a058cf4..e025116 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 0de7e6e..558f212 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 609f3f5..420dd62 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:
 
-- 
GitLab