Package: LifeInsureR 1.0.2

LifeInsureR: Modelling Traditional Life Insurance Contracts

R6 classes to model traditional life insurance contracts like annuities, whole life insurances or endowments. Such life insurance contracts provide a guaranteed interest and are not directly linked to the performance of a particular investment vehicle, but they typically provide (discretionary) profit participation. This package provides a framework to model such contracts in a very generic (cash-flow-based) way and includes modelling profit participation schemes, dynamic increases or more general contract layers, as well as contract changes (like sum increases or premium waivers). All relevant quantities like premium decomposition, reserves and benefits over the whole contract period are calculated and potentially exported to 'Excel'. Mortality rates are given using the 'MortalityTables' package.

Authors:Reinhold Kainhofer [aut, cre, cph]

LifeInsureR_1.0.2.tar.gz
LifeInsureR_1.0.2.zip(r-4.7-any)LifeInsureR_1.0.2.zip(r-4.6-any)LifeInsureR_1.0.2.zip(r-4.5-any)
LifeInsureR_1.0.2.tgz(r-4.6-any)LifeInsureR_1.0.2.tgz(r-4.5-any)
LifeInsureR_1.0.2.tar.gz(r-4.7-any)LifeInsureR_1.0.2.tar.gz(r-4.6-any)
LifeInsureR_1.0.2.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
LifeInsureR/json (API)

# Install 'LifeInsureR' in R:
install.packages('LifeInsureR', repos = c('https://kainhofer.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/kainhofer/lifeinsurer/issues

On CRAN:

Conda:

5.90 score 2 stars 1 packages 22 scripts 436 downloads 96 exports 67 dependencies

Last updated from:2977e94194. Checks:7 ERROR, 2 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develERROR194
source / vignettesOK281
linux-releaseERROR199
macos-releaseERROR207
macos-oldrelERROR143
windows-develERROR155
windows-releaseERROR150
windows-oldrelERROR147
wasm-releaseOK127

Exports:age.exactRoundedage.yearDifferenceapplyHookCalculationEnumcontractGridcontractGridPremiumcosts.baseAlphacosts.scaleAlphacostsDisplayTabledeathBenefit.annuityDecreasingdeathBenefit.linearDecreasingexpect_equal_absexportInsuranceContract.xlsxexportInsuranceContractExamplefallbackFieldsfillFieldsfillNAgapsfilterProfitRatesfreqChargeget.tariffget.tariffshead0initializeCostsInsuranceContractInsuranceContract.ParameterDefaultsInsuranceContract.ParametersFallbackInsuranceContract.ParametersFillInsuranceContract.ParameterStructureInsuranceContract.ValuesInsuranceTarifisRegularPremiumContractisSinglePremiumContractLIC_debug_configuremakeContractGridDimnamemakeContractGridDimnamespad0padLastPaymentTimeEnumPP.base.contractualReservePP.base.meanContractualReservePP.base.meanZillmerReservePP.base.meanZillmerReserveForwardPP.base.NULLPP.base.previousContractualReservePP.base.PreviousZillmerReservePP.base.sumInsuredPP.base.totalProfitAssignmentPP.base.ZillmerReserveT2PP.base.ZillmerRiskPremiumPP.benefit.NonePP.benefit.ProfitPP.benefit.ProfitGuaranteeSupportingPP.benefit.ProfitPlusGuaranteedInterestPP.benefit.ProfitPlusHalfGuaranteedInterestPP.benefit.ProfitPlusHalfInterestMinGuaranteeTotalPP.benefit.ProfitPlusHalfTotalInterestPP.benefit.ProfitPlusInterestMinGuaranteeTotalPP.benefit.ProfitPlusTerminalBonusReservePP.benefit.ProfitPlusTotalInterestPP.benefit.TerminalBonusPP.benefit.TerminalBonus5YearsPP.benefit.TerminalBonus5YearsProRataPP.calculate.RateOnBasePP.calculate.RateOnBaseMin0PP.calculate.RateOnBaseSGFFactorPP.calculate.RatePlusGuaranteeOnBasePP.rate.expenseProfitPP.rate.interestProfitPP.rate.interestProfit2PP.rate.interestProfit2PlusGuaranteePP.rate.interestProfitPlusGuaranteePP.rate.riskProfitPP.rate.sumProfitPP.rate.terminalBonusPP.rate.terminalBonusFundPP.rate.totalInterestPP.rate.totalInterest2premiumRefundPeriod.defaultprepare.tariffProfitComponentsEnumProfitParticipationPVfactoryregister.companyregister.tariffrollingmeanround_half_upRoundingHelpersetCostSexEnumshowVmGlgExamplessumProfitsTariffTypeEnumtestProfitParticipationtestVmGlgExamplevalueOrFunctionvmGlgExample.generateTest

Dependencies:abindbase64encbslibcachemclicpp11digestdplyrevaluatefarverfastmapfontawesomefsgenericsggplot2gluegtablehighrhtmltoolsisobandjquerylibjsonlitekableExtraknitrlabelinglifecyclelubridatemagrittrmemoisemimeMortalityTablesobjectPropertiesobjectSignalsopenxlsxpanderpillarpkgconfigpracmapurrrR6rappdirsRColorBrewerRcpprlangrmarkdownrstudioapiS7sassscalesstringistringrsvglitesystemfontstextshapingtibbletidyrtidyselecttimechangetinytexutf8vctrsviridisLitewithrxfunxml2yamlzip

Using the LifeInsureR Package
General Overview of the Concepts | A simple example: Term life insurance | Product description | Tariff implementation (InsuranceTarif) | Creating a contract | Creating tables with various parameters | All possible parameters | Tarif and Contract Specification | Creating the tariff | Sample tariffs for the most common life insurance types | Determining Sum Insured from the premium | Providing additional capital at contract inception | Premium Waivers | Calculation Approach | Valuation | Cash Flows | Cost structure | Frequency charges | Security loadings | Rounding values | Creating premium and contract grids | Exporting contract data to Excel | Creating examples for the Austrian Financial Market Authority | Contracts combining multiple contract layers / slices | Dynamic increases | General biometric riders | Extending a contract beyond its maturity | Handling contracts with increases | Fixed yearly premium increases | Fixed yearly benefit increases with constant premium | Dynamic Increases | Profit participation | Advance profit participation (premium rebate) | The ProfitParticiption class | Existing functions to use | Example profit scheme | Using the profit scheme in a tariff or contract | Modifying the default calculation approach | Debugging LifeInsureR-based Tariffs

Last update: 2026-01-02
Started: 2023-10-22

Creating Company-Specific LifeInsureR Implementations (using an RStudio Package Template)
Creating an RStudio project from the template | Implementing a full portfolio calculation | Steps to implement batch-testing a whole (sub-)portfolio | General Overview of the batch-calculation procedure | Column Mapping

Last update: 2023-10-27
Started: 2023-09-13

Readme and manuals

Help Manual

Help pageTopics
Calculate the age of the insured based on exact age at contract closing, rounded to the nearest birthday.age.exactRounded
Calculate the age of the insured based on the difference of the bith year and contract closing year.age.yearDifference
If 'hook' is a function, apply it to 'val', otherwise return 'val' unchangedapplyHook
Enum to define how much of a contract needs to be calculated automatically.CalculationEnum CalculationSingleEnum-class
Create a grid of InsuranceContract objects or premiums with each axis representing one varying parametercontractGrid contractGridPremium
Helper function to define base costs with base alpha, but otherwise unchanged costscosts.baseAlpha
Helper function to modify alpha costs of an insurance contract individuallycosts.scaleAlpha
Helper function to display all cost definitions in a concise tablecostsDisplayTable
Convert the multi-dimensional costs array to a data.frame for output to a filecostValuesAsDF
Describes the death benefit of a decreasing whole life insurance (after a possible deferall period)deathBenefit.annuityDecreasing
Describes the death benefit of a linearly decreasing whole life insurance (after a possible deferall period)deathBenefit.linearDecreasing
Expect approximate equality by absolute toleranceexpect_equal_abs
Export an insurance contract (object of class InsuranceContract) to an 'Excel' fileexportInsuranceContract.xlsx
Export the example calculations of an insurance contractexportInsuranceContractExample
Replace missing values in ields by default fallback valuesfallbackFields
Overwrite all existing fields with default values givenfillFields
Replace all 'NA' entries of a vector with the previous non-NA valuefillNAgaps
Filter the whole data.frame of profit rates for the given profit classesfilterProfitRates
Defines a frequency charge (surcharge for monthly/quarterly/semiannual) premium paymentsfreqCharge
Retrieve a LifeInsureR tariff registered with the packageget.tariff
Retrieve a LifeInsureR tariff registered with the packageget.tariffs
Set all entries of the given vector to 0 up until index 'start'head0
Initialize or modify a data structure for the definition of InsuranceTarif costsinitializeCosts
Base Class for Insurance ContractsAInsuranceContract
Default parameters for the InsuranceContract class.InsuranceContract.ParameterDefaults
Use fallback values for missing contract parametersInsuranceContract.ParametersFallback
Initialize the insurance contract parameters from passed argumentsInsuranceContract.ParametersFill
Full insurance contract parameter structure.InsuranceContract.ParameterStructure
Data structure (filled only with NULL) for insurance contract class member values.InsuranceContract.Values
Base class for traditional Insurance Tarifs (with fixed guarantee, profit sharing and no unit-linked component)InsuranceTarif
Determine whether a contract (given all parameters) is a contract with regular premiumsisRegularPremiumContract
Determine whether a contract (given all parameters) is a single-premium contract or with regular premiumsisSinglePremiumContract
Configure LifeInsureR debug options interactivelyLIC_debug_configure
Create human-readable labels for the dimensions in a 'contractGrid()'makeContractGridDimname makeContractGridDimnames
Pad a vector with 0 to a desired lengthpad0
Pad the vector 'v' to length 'l' by repeating the last entry of the vector.padLast
Enum to describe when a benefit or premium payment is due (in advance or in arrears)PaymentTimeEnum PaymentTimeSingleEnum-class
Default premium refund period: for deferred contracts the deferral period, otherwise the whole contractpremiumRefundPeriod.default
Create template code files for a new tarifprepare.tariff
Enum to define the different components of profit participation.ProfitComponentsEnum ProfitComponentsMultipleEnum-class
Base Class for Profit Participation SchemesProfitParticipation
Helper functions for profit participationgetTerminalBonusReserve PP.base.contractualReserve PP.base.meanContractualReserve PP.base.meanZillmerReserve PP.base.meanZillmerReserveForward PP.base.NULL PP.base.previousContractualReserve PP.base.PreviousZillmerReserve PP.base.sumInsured PP.base.totalProfitAssignment PP.base.ZillmerReserveT2 PP.base.ZillmerRiskPremium PP.benefit.None PP.benefit.Profit PP.benefit.ProfitGuaranteeSupporting PP.benefit.ProfitPlusGuaranteedInterest PP.benefit.ProfitPlusHalfGuaranteedInterest PP.benefit.ProfitPlusHalfInterestMinGuaranteeTotal PP.benefit.ProfitPlusHalfTotalInterest PP.benefit.ProfitPlusInterestMinGuaranteeTotal PP.benefit.ProfitPlusTerminalBonusReserve PP.benefit.ProfitPlusTotalInterest PP.benefit.TerminalBonus PP.benefit.TerminalBonus5Years PP.benefit.TerminalBonus5YearsProRata PP.calculate.RateOnBase PP.calculate.RateOnBaseMin0 PP.calculate.RateOnBaseSGFFactor PP.calculate.RatePlusGuaranteeOnBase PP.rate.expenseProfit PP.rate.interestProfit PP.rate.interestProfit2 PP.rate.interestProfit2PlusGuarantee PP.rate.interestProfitPlusGuarantee PP.rate.riskProfit PP.rate.sumProfit PP.rate.terminalBonus PP.rate.terminalBonusFund PP.rate.totalInterest PP.rate.totalInterest2 ProfitParticipationFunctions sumProfits
PVfactory (R6Class for present values with arbitrary dimensions)PVfactory
Register a company with a given shortcutregister.company
Register a tariff with the packageregister.tariff
Calculate the rolling mean of length 2rollingmean
Round Numbers Using Mathematical (Half-Up) Roundinground_half_up
Helper object to define rounding rules for the InsuranceContract, InsuranceTarif and ProfitParticipation classes.RoundingHelper
Update one component of an InsuranceTarif's cost structuresetCost
Enum to describe possible sexes in an insurance contract or tariff.SexEnum SexSingleEnum-class
Display insurance contract calculation exampleshowVmGlgExamples
An enum specifying the main characteristics of the tarif.TariffTypeEnum TariffTypeSingleEnum-class
Test profit participation values against reference datatestProfitParticipation
Perform unit tests of given standard values of the insurance contract exampletestVmGlgExample
If 'val' is a function, evaluate it, otherwise return 'val'valueOrFunction
Generate testthat output for unit-testing a tarif implementationvmGlgExample.generateTest