From c540370c63c32dd74fd34f6b0ecfd3e7d8098cf0 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Sun, 11 Sep 2022 12:33:45 +0200 Subject: [PATCH] V0.0.4: Update rosygen, fix periods -) Premium, commission and deferral periods must be at most equal to the contract period => add check and use min to cut off --- DESCRIPTION | 2 +- NAMESPACE | 5 ++ R/InsuranceContract.R | 18 ++++++- man/ProfitParticipationFunctions.Rd | 80 ++++++++++++++--------------- man/makeContractGridDimname.Rd | 6 +-- 5 files changed, 65 insertions(+), 46 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 08a2f56..4dbb540 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -35,7 +35,7 @@ Imports: pander, tidyr License: GPL (>= 2) -RoxygenNote: 7.2.0 +RoxygenNote: 7.2.1 Collate: 'HelperFunctions.R' 'InsuranceParameters.R' diff --git a/NAMESPACE b/NAMESPACE index a751a21..497e9a3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,6 +6,7 @@ S3method(makeContractGridDimname,default) S3method(makeContractGridDimname,double) S3method(makeContractGridDimname,mortalityTable) S3method(makeContractGridDimname,numeric) +export(CalculationEnum) export(InsuranceContract) export(InsuranceContract.ParameterDefaults) export(InsuranceContract.ParameterStructure) @@ -50,7 +51,11 @@ export(PP.rate.terminalBonus) export(PP.rate.terminalBonusFund) export(PP.rate.totalInterest) export(PP.rate.totalInterest2) +export(PaymentTimeEnum) +export(ProfitComponentsEnum) export(ProfitParticipation) +export(SexEnum) +export(TariffTypeEnum) export(age.exactRounded) export(age.yearDifference) export(applyHook) diff --git a/R/InsuranceContract.R b/R/InsuranceContract.R index 5b25699..17dfb94 100644 --- a/R/InsuranceContract.R +++ b/R/InsuranceContract.R @@ -979,18 +979,32 @@ InsuranceContract = R6Class( self$Parameters$ContractData$premiumPeriod = valueOrFunction( self$Parameters$ContractData$premiumPeriod, params = self$Parameters, values = self$Values); - # At least 1 year premium period! - self$Parameters$ContractData$premiumPeriod = max(self$Parameters$ContractData$premiumPeriod, 1); + # At least 1 year premium period, at most contract duration! + self$Parameters$ContractData$premiumPeriod = + min( + max(self$Parameters$ContractData$premiumPeriod, 1), + self$Parameters$ContractData$policyPeriod + ); self$Parameters$Loadings$commissionPeriod = valueOrFunction( self$Parameters$Loadings$commissionPeriod, params = self$Parameters, values = self$Values); + self$Parameters$Loadings$commissionPeriod = + min( + self$Parameters$Loadings$commissionPeriod, + self$Parameters$ContractData$policyPeriod + ) # Evaluate deferral period, i.e. if a function is used, calculate its numeric value from the other parameters self$Parameters$ContractData$deferralPeriod = valueOrFunction( self$Parameters$ContractData$deferralPeriod, params = self$Parameters, values = self$Values); + self$Parameters$ContractData$deferralPeriod = + min( + self$Parameters$ContractData$deferralPeriod, + self$Parameters$ContractData$policyPeriod + ) #### # # AGES for multiple joint lives: diff --git a/man/ProfitParticipationFunctions.Rd b/man/ProfitParticipationFunctions.Rd index 810b4bd..c1d6db1 100644 --- a/man/ProfitParticipationFunctions.Rd +++ b/man/ProfitParticipationFunctions.Rd @@ -181,57 +181,57 @@ the rates and how the assigned profit is calculated. } \section{Functions}{ \itemize{ -\item \code{PP.base.NULL}: Basis for profit: NONE (i.e. always returns 0) +\item \code{PP.base.NULL()}: Basis for profit: NONE (i.e. always returns 0) -\item \code{PP.base.PreviousZillmerReserve}: Basis for profit: Previous Zillmer reserve (no administration cost reserve) +\item \code{PP.base.PreviousZillmerReserve()}: Basis for profit: Previous Zillmer reserve (no administration cost reserve) -\item \code{PP.base.ZillmerReserveT2}: Basis for profit: Zillmer reserve (no administration cost reserve) at time t-2 +\item \code{PP.base.ZillmerReserveT2()}: Basis for profit: Zillmer reserve (no administration cost reserve) at time t-2 -\item \code{PP.base.contractualReserve}: Basis for profit: Contractual reserve (including administration costs) at time t +\item \code{PP.base.contractualReserve()}: Basis for profit: Contractual reserve (including administration costs) at time t -\item \code{PP.base.previousContractualReserve}: Basis for profit: Contractual reserve (including administration costs) at time t-1 +\item \code{PP.base.previousContractualReserve()}: Basis for profit: Contractual reserve (including administration costs) at time t-1 -\item \code{PP.base.meanContractualReserve}: Basis for profit: Contractual reserve (including administration costs) averaged over t and t-1 +\item \code{PP.base.meanContractualReserve()}: Basis for profit: Contractual reserve (including administration costs) averaged over t and t-1 -\item \code{PP.base.ZillmerRiskPremium}: Basis for risk/mortality profit: Zillmer Risk Premium of the past year +\item \code{PP.base.ZillmerRiskPremium()}: Basis for risk/mortality profit: Zillmer Risk Premium of the past year -\item \code{PP.base.sumInsured}: Basis for expense/sum profit: sum insured +\item \code{PP.base.sumInsured()}: Basis for expense/sum profit: sum insured -\item \code{PP.base.totalProfitAssignment}: Basis for Terminal Bonus Fund Assignment: total profit assignment of the year +\item \code{PP.base.totalProfitAssignment()}: Basis for Terminal Bonus Fund Assignment: total profit assignment of the year -\item \code{PP.rate.interestProfit}: Returns the array of interest profit rates (keyed by year) +\item \code{PP.rate.interestProfit()}: Returns the array of interest profit rates (keyed by year) -\item \code{PP.rate.riskProfit}: Returns the array of risk profit rates (keyed by year) +\item \code{PP.rate.riskProfit()}: Returns the array of risk profit rates (keyed by year) -\item \code{PP.rate.expenseProfit}: Returns the array of expense profit rates (keyed by year) +\item \code{PP.rate.expenseProfit()}: Returns the array of expense profit rates (keyed by year) -\item \code{PP.rate.sumProfit}: Returns the array of sum profit rates (keyed by year) +\item \code{PP.rate.sumProfit()}: Returns the array of sum profit rates (keyed by year) -\item \code{PP.rate.terminalBonus}: Returns the array of terminal bonus rates (keyed by year) +\item \code{PP.rate.terminalBonus()}: Returns the array of terminal bonus rates (keyed by year) -\item \code{PP.rate.terminalBonusFund}: Returns the array of terminal bonus rates (keyed by year) as the terminal bonus fund ratio +\item \code{PP.rate.terminalBonusFund()}: Returns the array of terminal bonus rates (keyed by year) as the terminal bonus fund ratio -\item \code{PP.rate.interestProfitPlusGuarantee}: Rate for interest on past profits: total credited rate, but at least the guarantee +\item \code{PP.rate.interestProfitPlusGuarantee()}: Rate for interest on past profits: total credited rate, but at least the guarantee -\item \code{PP.rate.interestProfit2PlusGuarantee}: Rate for interest on past profits: total creditedrate2, but at least the guarantee +\item \code{PP.rate.interestProfit2PlusGuarantee()}: Rate for interest on past profits: total creditedrate2, but at least the guarantee -\item \code{PP.rate.totalInterest}: Rate for interest on past profits: total interest rate +\item \code{PP.rate.totalInterest()}: Rate for interest on past profits: total interest rate -\item \code{PP.rate.totalInterest2}: Rate for interest on past profits: second total interest rate +\item \code{PP.rate.totalInterest2()}: Rate for interest on past profits: second total interest rate -\item \code{PP.rate.interestProfit2}: Rate for interest on past profits: second interest profit rate (not including guaranteed interest), keyed by year +\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{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.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 +\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 -\item \code{PP.calculate.RatePlusGuaranteeOnBase}: Calculate profit by a rate + guaranteed interest applied on the basis (with an optional waiting vector of values 0 or 1) +\item \code{PP.calculate.RatePlusGuaranteeOnBase()}: Calculate profit by a rate + guaranteed interest applied on the basis (with an optional waiting vector of values 0 or 1) -\item \code{PP.calculate.RateOnBaseSGFFactor}: Calculate profit by a simple rate applied on the basis (with only (1-SGFFactor) put into profit participation, and an optional waiting vector of values 0 or 1) +\item \code{PP.calculate.RateOnBaseSGFFactor()}: Calculate profit by a simple rate applied on the basis (with only (1-SGFFactor) put into profit participation, and an optional waiting vector of values 0 or 1) -\item \code{sumProfits}: Extract the given columns of the profit participation array of values and sum +\item \code{sumProfits()}: Extract the given columns of the profit participation array of values and sum them up. Columns that do not exist, because the profit scheme does not provide the corresponding profit component will be silently ignored. This allows generic benefit calculation functions to be written that do @@ -241,30 +241,30 @@ bonus fund is provided. This function is not meant to be called directly, but within a profit benefit calculation function. -\item \code{PP.benefit.ProfitPlusTerminalBonusReserve}: Calculate survival benefit as total profit amount plus the terminal bonus reserve +\item \code{PP.benefit.ProfitPlusTerminalBonusReserve()}: Calculate survival benefit as total profit amount plus the terminal bonus reserve -\item \code{PP.benefit.Profit}: Calculate benefit as total profit accrued so far +\item \code{PP.benefit.Profit()}: Calculate benefit as total profit accrued so far -\item \code{PP.benefit.ProfitPlusGuaranteedInterest}: Calculate accrued death benefit as total profit with (guaranteed) interest for one year +\item \code{PP.benefit.ProfitPlusGuaranteedInterest()}: Calculate accrued death benefit as total profit with (guaranteed) interest for one year -\item \code{PP.benefit.ProfitPlusTotalInterest}: Calculate accrued death benefit as total profit with total interest (interest on profit rate) for one year +\item \code{PP.benefit.ProfitPlusTotalInterest()}: Calculate accrued death benefit as total profit with total interest (interest on profit rate) for one year -\item \code{PP.benefit.ProfitPlusHalfTotalInterest}: Calculate accrued benefit as total profit with total interest (interest on profit rate) for half a year +\item \code{PP.benefit.ProfitPlusHalfTotalInterest()}: Calculate accrued benefit as total profit with total interest (interest on profit rate) for half a year -\item \code{PP.benefit.ProfitPlusHalfGuaranteedInterest}: Calculate death benefit as total profit with (guaranteed) interest for one year +\item \code{PP.benefit.ProfitPlusHalfGuaranteedInterest()}: Calculate death benefit as total profit with (guaranteed) interest for one year -\item \code{PP.benefit.ProfitPlusInterestMinGuaranteeTotal}: Calculate accrued benefit as total profit with interest for one year (max of guarantee and total interest) +\item \code{PP.benefit.ProfitPlusInterestMinGuaranteeTotal()}: Calculate accrued benefit as total profit with interest for one year (max of guarantee and total interest) -\item \code{PP.benefit.ProfitPlusHalfInterestMinGuaranteeTotal}: Calculate accrued benefit as total profit with interest for half a year (max of guarantee and total interest) +\item \code{PP.benefit.ProfitPlusHalfInterestMinGuaranteeTotal()}: Calculate accrued benefit as total profit with interest for half a year (max of guarantee and total interest) -\item \code{PP.benefit.ProfitGuaranteeSupporting}: Calculate accrued benefit as regular profit, but used to cover initial Zillmerization +\item \code{PP.benefit.ProfitGuaranteeSupporting()}: Calculate accrued benefit as regular profit, but used to cover initial Zillmerization -\item \code{PP.benefit.TerminalBonus5YearsProRata}: Calculate benefit from terminal bonus as 1/n parts of the terminal bonus reserve during the last 5 years +\item \code{PP.benefit.TerminalBonus5YearsProRata()}: Calculate benefit from terminal bonus as 1/n parts of the terminal bonus reserve during the last 5 years -\item \code{PP.benefit.TerminalBonus5Years}: Terminal bonus is only paid out during the last 5 years of the contract (but never during the first 10 years) +\item \code{PP.benefit.TerminalBonus5Years()}: Terminal bonus is only paid out during the last 5 years of the contract (but never during the first 10 years) -\item \code{PP.benefit.TerminalBonus}: Calculate benefit from terminal bonus (full bonus), either old-style terminal bonus reserve or Terminal Bonus Fund (TBF) +\item \code{PP.benefit.TerminalBonus()}: Calculate benefit from terminal bonus (full bonus), either old-style terminal bonus reserve or Terminal Bonus Fund (TBF) -\item \code{PP.benefit.None}: No benefit paid out -}} +\item \code{PP.benefit.None()}: No benefit paid out +}} diff --git a/man/makeContractGridDimname.Rd b/man/makeContractGridDimname.Rd index 1787609..b09d322 100644 --- a/man/makeContractGridDimname.Rd +++ b/man/makeContractGridDimname.Rd @@ -28,11 +28,11 @@ dimnames for all entries of the axes of a \code{\link[=contractGrid]{contractGri } \section{Functions}{ \itemize{ -\item \code{makeContractGridDimname}: Create a short, human-readable dimensional name for an object (default S3 method) +\item \code{makeContractGridDimname()}: Create a short, human-readable dimensional name for an object (default S3 method) -\item \code{makeContractGridDimnames}: Generate proper dimnames for all entries of the axes of a \code{\link[=contractGrid]{contractGrid()}} -}} +\item \code{makeContractGridDimnames()}: Generate proper dimnames for all entries of the axes of a \code{\link[=contractGrid]{contractGrid()}} +}} \examples{ library(MortalityTables) mortalityTables.load("Austria_Census") -- GitLab