Skip to content
Snippets Groups Projects
Commit 53690c44 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Implement Costs relative to net premium and fixed costs (no basis); Args to...

Implement Costs relative to net premium and fixed costs (no basis); Args to initializeCosts to quickly define the most common cost types

-) Costs with basis "NetPremium"
-) Costs with basis "Constant"
-) TODO: include them into the calculation of the Zillmer premium
-) Arguments to initializeCosts to quickly set the most common cost types.

Fixes #46, #40
parent e0cabab1
No related branches found
No related tags found
No related merge requests found
No preview for this file type
This diff is collapsed.
...@@ -3,22 +3,53 @@ NULL ...@@ -3,22 +3,53 @@ NULL
#' Initialize a cost matrix with dimensions: [CostType, Basis, Period], with: #' Initialize a cost matrix with dimensions: [CostType, Basis, Period], with:
#' CostType: alpha, Zillmer, beta, gamma, gamma_nopremiums #' CostType: alpha, Zillmer, beta, gamma, gamma_nopremiums, unitcosts
#' Basis: SumInsured, SumPremiums, GrossPremium #' Basis: SumInsured, SumPremiums, GrossPremium, NetPremium, Constant
#' Period: once, PremiumPeriod, PremiumFree, PolicyPeriod #' Period: once, PremiumPeriod, PremiumFree, PolicyPeriod
#' TODO: gamma an Erlebensleistungen? #' TODO: gamma an Erlebensleistungen?
#' @export #' @export
initializeCosts = function() { initializeCosts = function(costs, alpha, Zillmer, beta, gamma, gamma.paidUp, gamma.premiumfree, unitcosts, unitcosts.PolicyPeriod) {
dimnm = list( if (missing(costs)) {
c("alpha", "Zillmer", "beta", "gamma", "gamma_nopremiums"), dimnm = list(
c("SumInsured", "SumPremiums", "GrossPremium"), type = c("alpha", "Zillmer", "beta", "gamma", "gamma_nopremiums", "unitcosts"),
c("once", "PremiumPeriod", "PremiumFree", "PolicyPeriod") basis = c("SumInsured", "SumPremiums", "GrossPremium", "NetPremium", "Constant"),
); frequency = c("once", "PremiumPeriod", "PremiumFree", "PolicyPeriod")
array(0, );
dim = sapply(dimnm, length), costs = array(
dimnames = dimnm 0,
) dim = sapply(dimnm, length),
dimnames = dimnm
);
}
if (!missing(alpha)) {
costs[["alpha", "SumPremiums", "once"]] = alpha;
}
if (!missing(Zillmer)) {
costs[["Zillmer","SumPremiums", "once"]] = Zillmer;
}
if (!missing(beta)) {
costs[["beta", "GrossPremium", "PremiumPeriod"]] = beta;
}
if (!missing(gamma)) {
costs[["gamma", "SumInsured", "PremiumPeriod"]] = gamma;
}
if (!missing(gamma.premiumfree)) {
costs[["gamma", "SumInsured", "PremiumFree"]] = gamma.premiumfree;
}
if (!missing(gamma.paidUp)) {
costs[["gamma_nopremiums", "SumInsured", "PolicyPeriod"]] = gamma.paidUp;
}
if (!missing(unitcosts)) {
costs[["unitcosts", "Constant", "PremiumPeriod"]] = unitcosts;
}
if (!missing(unitcosts.PolicyPeriod)) {
costs[["unitcosts", "Constant", "PolicyPeriod"]] = unitcosts.PolicyPeriod;
}
costs
} }
# costs[["beta", "GrossPremium", "once"]] = 0.12; // Bei EINMALERLAG!
# costs[["gamma", "SumInsured", "PolicyPeriod"]] = 0.0005;
# costs[["alpha", "NetPremium", "once"]]
#' Data structure (filled only with NULL) for insurance contract class member values. #' Data structure (filled only with NULL) for insurance contract class member values.
......
...@@ -475,7 +475,9 @@ InsuranceTarif = R6Class( ...@@ -475,7 +475,9 @@ InsuranceTarif = R6Class(
benefitsCosts = values$presentValuesCosts[,,"SumInsured"] + benefitsCosts = values$presentValuesCosts[,,"SumInsured"] +
values$presentValuesCosts[,,"SumPremiums"] * values$unitPremiumSum * values$premiums[["unit.gross"]] + values$presentValuesCosts[,,"SumPremiums"] * values$unitPremiumSum * values$premiums[["unit.gross"]] +
values$presentValuesCosts[,,"GrossPremium"] * values$premiums[["unit.gross"]]; values$presentValuesCosts[,,"GrossPremium"] * values$premiums[["unit.gross"]] +
values$presentValuesCosts[,,"NetPremium"] * values$premiums[["unit.net"]] +
values$presentValuesCosts[,,"Constant"] / params$ContractData$sumInsured;
cbind( cbind(
benefits = benefits, benefits = benefits,
...@@ -497,7 +499,14 @@ InsuranceTarif = R6Class( ...@@ -497,7 +499,14 @@ InsuranceTarif = R6Class(
coeff[["Premium"]][["benefits"]][["premiums"]] = 1; coeff[["Premium"]][["benefits"]][["premiums"]] = 1;
# Costs proportional to NetPremium introduce a non-linearity, as the NP is not available when the gross premium is calculated
# => the corresponding costs PV is included in the coefficient!
browser();
coeff.benefits = (1 + securityLoading); coeff.benefits = (1 + securityLoading);
if (type == "gross") {
# TODO: How to include this into the Zillmer premium calculation?
coeff.benefits = coeff.benefits * (1 + sum(values$presentValuesCosts["0", c("alpha", "beta", "gamma"), "NetPremium"]) / values$presentValues[["0","premiums"]])
}
coeff[["SumInsured"]][["benefits"]][["guaranteed"]] = coeff.benefits; coeff[["SumInsured"]][["benefits"]][["guaranteed"]] = coeff.benefits;
coeff[["SumInsured"]][["benefits"]][["survival"]] = coeff.benefits; coeff[["SumInsured"]][["benefits"]][["survival"]] = coeff.benefits;
coeff[["SumInsured"]][["benefits"]][["death_SumInsured"]] = coeff.benefits; coeff[["SumInsured"]][["benefits"]][["death_SumInsured"]] = coeff.benefits;
...@@ -531,6 +540,7 @@ InsuranceTarif = R6Class( ...@@ -531,6 +540,7 @@ InsuranceTarif = R6Class(
coeff[["SumInsured"]][["costs"]]["gamma", "Constant"] = 1 / params$ContractData$sumInsured; coeff[["SumInsured"]][["costs"]]["gamma", "Constant"] = 1 / params$ContractData$sumInsured;
} else if (type == "Zillmer") { } else if (type == "Zillmer") {
# TODO: Include costs with basis NetPremium and fixed costs!
coeff[["SumInsured"]][["costs"]]["Zillmer","SumInsured"] = 1; coeff[["SumInsured"]][["costs"]]["Zillmer","SumInsured"] = 1;
coeff[["SumInsured"]][["costs"]]["Zillmer","SumPremiums"] = values$unitPremiumSum * premiums[["unit.gross"]]; coeff[["SumInsured"]][["costs"]]["Zillmer","SumPremiums"] = values$unitPremiumSum * premiums[["unit.gross"]];
coeff[["SumInsured"]][["costs"]]["Zillmer","GrossPremium"] = premiums[["unit.gross"]]; coeff[["SumInsured"]][["costs"]]["Zillmer","GrossPremium"] = premiums[["unit.gross"]];
......
...@@ -100,9 +100,12 @@ labelsReplace = function(labels) { ...@@ -100,9 +100,12 @@ labelsReplace = function(labels) {
labels[labels == "beta"] = "β"; labels[labels == "beta"] = "β";
labels[labels == "gamma"] = "γ"; labels[labels == "gamma"] = "γ";
labels[labels == "gamma_nopremiums"] = "γ prf."; labels[labels == "gamma_nopremiums"] = "γ prf.";
labels[labels == "unitcosts"] = "StkK";
labels[labels == "SumInsured"] = "VS"; labels[labels == "SumInsured"] = "VS";
labels[labels == "SumPremiums"] = "PS"; labels[labels == "SumPremiums"] = "PS";
labels[labels == "GrossPremium"] = "BP"; labels[labels == "GrossPremium"] = "BP";
labels[labels == "NetPremium"] = "NP";
labels[labels == "Constant"] = "";
# Cash Flows # Cash Flows
labels[labels == "premiums_advance"] = "Präm. vorsch."; labels[labels == "premiums_advance"] = "Präm. vorsch.";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment