diff --git a/DESCRIPTION b/DESCRIPTION
index 53403f352e5316967e8e272695f1135aa212ffd5..db17621dd07e51f4724d5c51f71d3a1837934303 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,9 +1,23 @@
 Package: ValuationTables
 Type: Package
-Title: A framework for cohort life tables and general life insurance contracts
 Version: 1.0
-Date: 2016-04-01
-Author: Reinhold Kainhofer <reinhold@kainhofer.com>
+Date: 2016-05-01
+Title: A framework for cohort life tables and general life insurance contracts
+Authors@R: c(person("Reinhold", "Kainhofer", role=c("aut", "cre"), email="reinhold@kainhofer.com"))
+Author: Reinhold Kainhofer [aut, cre]
 Maintainer: Reinhold Kainhofer <reinhold@kainhofer.com>
-Description: Yet to be written
-License: Not yet finally decided, probably GPL v3+ or LGPL or something similar
+Depends:
+    ggplot2,
+    methods,
+    openxlsx,
+    scales,
+    utils
+Suggests:
+    lifecontingencies
+Description: This package provides classes to implement cohort life tables
+    for actuarial calculations. In particular, birthyear-dependent mortality
+    tables using a yearly trend to extrapolate from a base year are implemented,
+    as well as period life table, cohort life tables using an age shift, and
+    merged life tables.
+License: GPL (>= 2)
+RoxygenNote: 5.0.1
diff --git a/Formulas_Reference/.gitignore b/Formulas_Reference/.gitignore
deleted file mode 100644
index 1663ebea4eb69ff65a73bc92b1b64fd27efb1138..0000000000000000000000000000000000000000
--- a/Formulas_Reference/.gitignore
+++ /dev/null
@@ -1,10 +0,0 @@
-*.aux
-*.dvi
-*.log
-*.synctex.gz
-*.backup
-*.kilepr
-Bernkopf Max
-Formelsammlung_Beispielrechnung.toc
-Formelsammlung_Beispielrechnung.out
-.gitignore
diff --git a/Formulas_Reference/Formelsammlung_Beispielrechnung.pdf b/Formulas_Reference/Formelsammlung_Beispielrechnung.pdf
deleted file mode 100644
index 19a7192e1dd76c8035108a6141d9350d7d7ca254..0000000000000000000000000000000000000000
Binary files a/Formulas_Reference/Formelsammlung_Beispielrechnung.pdf and /dev/null differ
diff --git a/Formulas_Reference/Formelsammlung_Beispielrechnung.tex b/Formulas_Reference/Formelsammlung_Beispielrechnung.tex
deleted file mode 100644
index d62e41beea98b7e097851c717faef41bb73c803f..0000000000000000000000000000000000000000
--- a/Formulas_Reference/Formelsammlung_Beispielrechnung.tex
+++ /dev/null
@@ -1,1060 +0,0 @@
-\documentclass[a4paper,10pt]{article}
-\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
-\usepackage{geometry}
-\usepackage{tabularx, longtable}
-\usepackage{amsmath}
-\usepackage[ngerman]{babel}
-\usepackage[usenames,dvipsnames]{xcolor}
-\usepackage{enumerate}
-\usepackage{enumitem}
-\setlist{nolistsep}
-\usepackage{multirow}
-%\usepackage{itemize}
-% \usepackage{sans}
-\usepackage{array}
-\newcolumntype{C}[1]{>{\centering\arraybackslash$}p{#1}<{$}}
-\usepackage{rotating}
-\usepackage{pdflscape}
-\usepackage{hyperref}
-
-\usepackage{mathpazo}% Palatino mit mathematischen Zeichen
-\hyphenation{Prä-mi-en-frei-stel-lung}
-
-%opening
-\title{\textbf{Formelsammlung Tarif Lebensversicherung}}
-\author{Reinhold Kainhofer (reinhold@kainhofer.com)}
-
-\geometry{bottom=2cm,top=2cm,left=1.5cm,right=1.5cm}
-
-\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp}
-\newcolumntype{v}[1]{>{\PreserveBackslash\centering\hspace{0pt}}p{#1}}
-
-\newcommand{\markiert}[1]{\colorbox{Goldenrod}{\textcolor{red}{#1}}}
-\newcommand{\orZero}[1]{\mathit{\left[#1\right]}}
-\newcommand{\xn}{{\act[x]{n}}}
-
-
-\setlength{\parindent}{0em}
-
-\makeatletter
-\DeclareRobustCommand{\act}[2][]{%
-\def\arraystretch{0}%
-\setlength\arraycolsep{0.5pt}%
-\setlength\arrayrulewidth{0.5pt}%
-\setbox0=\hbox{$\scriptstyle#1\ifx#1\empty{asdf}\else:\fi#2$}%
-\begin{array}[b]{*2{@{}>{\scriptstyle}c}|}
-\cline{2-2}%
-\rule[1.25pt]{0pt}{\ht0}%
-#1\ifx#1\empty\else:\fi & #2%
-\end{array}%
-}
-\makeatother
-
-\renewcommand{\labelitemi}{-)}
-% \renewcommand[\itemsep}{0cm}
-% \renewcommand{\labelitemsep}{0cm}
-\itemsep0em
-
-
-\begin{document}
-
-\maketitle
-
-% \begin{abstract}
-% 
-% \end{abstract}
-
-Bemerkung: Sämtliche Barwerte werden rekursiv bestimmt, daher werden alle Formeln in ihrer rekursiven Form angegeben. Teilweise wird aus informativen Gründen davor die entsprechende Summenformel angegeben, diese wird jedoch nicht zur tatsächlichen Berechnung benutzt. 
-
-\tableofcontents
-
-
-\begin{landscape}
-\section{Definitionen sämtlicher Variablen}
-
-\subsection{Vertragsdetails (vertragsspezifische Werte)}
-
-\newenvironment{deftab}{\begin{longtable}{p{1.7cm}p{13cm}p{9cm}}}{\end{longtable}}
-
-\begin{deftab}
- $VS$ & Versicherungssumme & \texttt{contract\$params\$sumInsured}\\
- $\widetilde{VS}$ & Versicherungssumme nach außerplanmäßiger Prä"-mi"-en"-frei"-stel"-lung\\[0.5em]
- $x$ & Eintrittsalter der versicherten Person & \texttt{contract\$params\$age}\\
- $n$ & Versicherungsdauer & \texttt{contract\$params\$policyPeriod}\\
- $l$ & Aufschubdauer des Versicherungsschutzes & \texttt{contract\$params\$deferral}\\
- $m$ & Prämienzahlungsdauer & \texttt{contract\$params\$premiumPeriod}\\
- $k$ & Prämienzahlungsweise ($k$-tel jährlich) & \texttt{contract\$params\$premiumFrequency}\\
- $g$ & Garantiedauer (für Renten)  & \texttt{contract\$params\$guaranteed}\\
- $f$ & Prämienfreistellungszeitpunkt\\[0.5em]
- 
- $YOB$ & Geburtsjahr der versicherten Person (bei Benutzung von Generationentafeln) & \texttt{contract\$params\$YOB}\\
- $Beg$ & Versicherungsbeginn (Datum, TODO)\\[0.5em]
-
- $q_{x+t}$ & einjährige Sterbewahrscheinlichkeit der versicherten Person (aus $YOB$ und $x$ bestimmt) & \texttt{contract\$params\$transitionProbabilities\$q}\\
- $i_{x+t}$ & einjährige Erkrankungswahrscheinlichkeit (z.B. Dread Disease, Krebs, etc.) & \texttt{contract\$params\$transitionProbabilities\$i} \\
- $p_{x+t}$ & einjährige Überlebenswahrscheinlichkeit als Aktiver, $p_{x+t} = 1-q_{x+t}-i_{x+1}$ & \texttt{contract\$params\$transitionProbabilities\$p} \\
- $\omega$  & Höchstalter gemäß der benutzten Sterbetafel  & \texttt{getOmega(tarif\$mortalityTable)} \\[0.5em]
- 
-
- $k_{Ausz}$ & unterjährige Auszahlung der Erlebensleistungen (nur Renten) & \texttt{contract\$params\$benefitFrequency}\\
- $y$ & Eintrittsalter der 2. versicherten Person (TODO)\\
- 
- 
-\end{deftab}
-
-\subsection{Tarifdetails (identisch für alle Verträge)}
-\begin{deftab}
- $i$ & Rechnungszins & \texttt{tarif\$i}\\[0.5em]
- $v$ & Diskontierungsfaktor $v=\frac1{1+i}$ & \texttt{tarif\$v}\\[0.5em]
- 
- $\rho$ & Sicherheitszuschlag auf die Prämie & \texttt{tarif\$loadings\$security} \\
- $\rho^{RG}$ & Risikosumme (relativ zu DK) im Ablebensfall bei Prämienrückgewähr & \texttt{tarif\$premiumRefundLoading} \\
- $uz(k)$ & Unterjährigkeitszuschlag bei $k$-tel jährlicher Prämienzahlung (in \% der Prämie) & \texttt{tarif\$premiumFrequencyLoading}\\
- $O(k)$ & Ordnung der Unterjährigkeitsrechnung der Erlebenszahlungen (0./""1./""1,5./""2. Ordnung) & \texttt{tarif\$benefitFrequencyOrder}\\[0.5em]
- 
-\end{deftab}
-
-\subsection{Leistungen}
-
-\begin{deftab}
- $\Pi_t$ & (Netto-)Prämie zum Zeitpunkt $t$ (vorschüssig), $\Pi^{nachsch.}_t$ für nachschüssige Prämienzahlungsweise, normiert auf 1 & \texttt{contract\$cashFlows\$premiums\_advance}\\
- $\Pi^{nachsch.}_t$ & (Netto-)Prämie zum Zeitpunkt $t$ (nachschüssig), normiert auf 1 & \texttt{contract\$cashFlows\$premiums\_arrears}\\
- $PS_t$ &Bruttoprämiensumme bis zum Zeitpunkt $t$: $PS_t=\sum_{j=0}^t \Pi^a_t$\\
- $PS$ & Bruttoprämiensumme über die gesamte Vertragslaufzeit  & \texttt{contract\$premiumSum}\\[0.5em]
- 
- $\ddot{e}_t$ & vorschüssige Erlebenszahlung zum Zeitpunkt $t$ (normiert auf 1) & \texttt{contract\$cashFlows\$survival\_advance}\\
- $e_t$ & nachschüssige Erlebenszahlung zum Zeitpunkt $t$ (normiert auf 1) & \texttt{contract\$cashFlows\$survival\_arrears}\\[0.5em]
- 
- $\ddot{e}_t^*$ & vorschüssige garantierte Zahlung zum Zeitpunkt $t$ (normiert auf 1) & \texttt{contract\$cashFlows\$guaranteed\_advance}\\
- $e_t^*$ & nachschüssige garantierte Zahlung zum Zeitpunkt $t$ (normiert auf 1) & \texttt{contract\$cashFlows\$guaranteed\_arrears}\\[0.5em]
- 
- $a_t$ & Ablebensleistung proportional zur Versicherungssumme (nachschüssig) & \texttt{contract\$cashFlows\$death\_sumInsured}\\
- $a_t^{(RG)}$ & Ablebensleistung für Prämienrückgewähr (normiert auf Prämie 1, relativ zu Prämienzumme $PS$) & \texttt{contract\$cashFlows\$death\_GrossPremium}\\[0.5em]
- $\widetilde{a}_t$ & Ablebensleistung nach außerplanmäßiger Prämienfreistellung proportional zur Versicherungssumme (nachschüssig) & \texttt{contract\$cashFlows\$death\_PremiumFree}\\
- 
- $\overrightarrow{CF}^B_t$ & Leistungscashflow (relativ zur jeweiligen Basis, sowie vor"~/""nachschüssig) als Matrix dargestellt
-\end{deftab}
-
-\subsection{Kosten}
-Mögliche Basen für die Kostenfestsetzung sind:
-\begin{align*}
- \text{Basis} &= \begin{cases}\text{VS ... Versicherungssumme (\texttt{"{}SumInsured"})}\\\text{PS ... gesamte Prämiensumme  (\texttt{"{}SumPremiums"})}\\\text{BP ... Bruttojahresprämie  (\texttt{"{}GrossPremium"})}\end{cases} &
- \text{Dauer} &= \begin{cases}\text{1 ... einmalig bei Abschluss (\texttt{"{}once"})}\\\text{PD ... Prämienzahlungsdauer (\texttt{"{}PremiumPeriod"})}\\\text{Prf ... Nach Ablauf der Prämienzahlungsdauer (\texttt{"{}PremiumFree"})}\\\text{LZ ... gesamte Laufzeit (\texttt{"{}PolicyPeriod"})}\end{cases}
-\end{align*}
-
-
-\begin{deftab}
- $\alpha_t^{\text{Basis},\text{Dauer}}$ & Abschlusskostensatz relativ zu Basis über die angegebene Dauer & \texttt{tarif\$costs["{}alpha",,]}\\
- $Z_t^{\text{Basis},\text{Dauer}}$ & Zillmerkostensatz relativ zu Basis über die angegebene Dauer & \texttt{tarif\$costs["{}Zillmer",,]}\\
- $\beta_t^{\text{Basis},\text{Dauer}}$ & Inkassokostensatz relativ zu Basis über die angegebene Dauer & \texttt{tarif\$costs["{}beta",,]}\\
- $\gamma_t^{\text{Basis},\text{Dauer}}$ & Verwaltungskostensatz relativ zu Basis über die angegebene Dauer & \texttt{tarif\$costs["{}gamma",,]}\\
- $\widetilde{\gamma}_t^{\text{Basis},\text{Dauer}}$ & Verwaltungskostensatz nach außerplanmäßiger Prämienfreistellung relativ zu Basis über die angegebene Dauer & \texttt{tarif\$costs["{}gamma\_nopremiums",,]}\\[0.5em]
- 
- $\alpha_t^{\text{Basis}}$ & Abschlusskosten-Cash Flow relativ zu Basis zu $t$ & \texttt{contract\$cashFlowsCosts[,"{}alpha", Basis]}\\
- $Z_t^{\text{Basis}}$ & Zillmerkosten-Cash Flow relativ zu Basis zu $t$  & \texttt{contract\$cashFlowsCosts[,"{}Zillmer", Basis]}\\
- $\beta_t^{\text{Basis}}$ & Inkassokosten-Cash Flow relativ zu Basis zu $t$  & \texttt{contract\$cashFlowsCosts[,"{}beta", Basis]}\\
- $\gamma_t^{\text{Basis}}$ & Verwaltungskosten-Cash Flow relativ zu Basis zu $t$  & \texttt{contract\$cashFlowsCosts[,"{}gamma", Basis]}\\
- $\widetilde{\gamma}_t^{\text{Basis}}$ & Verwaltungskosten-Cash Flow nach außerplanmäßiger Prämienfreistellung relativ zu Basis zu $t$  & \texttt{contract\$cashFlowsCosts[,"{}gamma\_nopremiums", Basis]}\\[0.5em]
-
- $\overrightarrow{CF}^C_t$ & Kostencashflows (relativ zur jeweiligen Basis) als Matrix dargestellt & \texttt{contract\$cashFlowsCosts["{}t",,]}
-\end{deftab}
-
-\subsection{Barwerte}
-
-\begin{deftab}
- $P_\xn(t)$ & BW der zuk. Prämienzahlungen (mit Prämie 1) zum Zeitpunkt $t$ & \texttt{contract\$presentValues\$premiums}\\
- $E^*_\xn(t)$ & BW der zuk.  garantierten Zahlungen (mit VS 1) zum Zeitpunkt $t$ & \texttt{contract\$presentValues\$guaranteed}\\
- $E_\xn(t)$ & BW der zuk.  Erlebenszahlungen (mit VS 1) zum Zeitpunkt $t$ & \texttt{contract\$presentValues\$survival}\\
- $E^{(k)}_\xn(t)$ & BW der zuk.  Erlebenszahlungen (mit VS 1) bei $k$-tel jährlicher Auszahlung zum Zeitpunkt $t$ & \texttt{contract\$presentValues\$survival}\\
- $\alpha(k)$, $\beta(k)$ & Unterjährigkeitskorrektur bei $k$-tel jährlicher Auszahlung\\
- $A_\xn(t)$ & BW der zuk.  Ablebensleistungen (mit VS 1) zum Zeitpunkt $t$ & \texttt{contract\$presentValues\$death\_SumInsured}\\
- $A_\xn^{prf}(t)$  & BW der zuk.  Ablebensleistungen (mit VS 1) zum Zeitpunkt $t$ nach Prämienfreistellung & \texttt{contract\$presentValues\$death\_GrossPremium}\\
- $A^{(RG)}_\xn(t)$ & BW der zuk.  Ablebensleistungen aus Prämienrückgewähr (mit BP 1) zum Zeitpunkt $t$ & \texttt{contract\$presentValues\$death\_PremiumFree}\\[0.5em]
- 
- $PV^{B1}_\xn(t)$ & BW aller zuk.  Leistungen (ohne Prämienrückgewähr) zum Zeitpunkt $t$ & \texttt{contract\$presentValues\$benefits}\\[1em]
- $PV^B_\xn(t)$ & BW aller zuk.  Leistungen (inkl. Prämienrückgewähr) zum Zeitpunkt $t$ & \texttt{contract\$presentValues\$benefitsAndRefund}\\[1em]
- 
-\end{deftab}
- KOSTEN (TODO)
-
-\subsection{Prämien und Prämienzerlegung}
-
-\begin{deftab}
- $\Pi^1_\xn$ & Nettoprämie auf VS 1 & \texttt{contract\$premiums[["{}unit.net"]]}\\
- $\Pi_\xn^{1,Z}$ & Zillmerprämie auf VS 1 & \texttt{contract\$premiums[["{}unit.Zillmer"]]}\\
- $\Pi_\xn^{1,a}$ & Bruttoprämie (``adequate'' bzw. ``expense-load premium'') auf VS 1 & \texttt{contract\$premiums[["{}unit.gross"]]}\\[0.5em]
- $\Pi_\xn$ & Nettoprämie & \texttt{contract\$premiums[["{}net"]]}\\
- $\Pi_\xn^Z$ & Zillmerprämie & \texttt{contract\$premiums[["{}Zillmer"]]}\\
- $\Pi_\xn^a$ & Bruttoprämie (``adequate'' bzw. ``expense-load premium'') & \texttt{contract\$premiums[["{}gross"]]}\\[0.5em]
- 
- $\Pi_\xn^\alpha$ & $\alpha$-Kostenprämie (Abschlusskostenprämie)\\
- $\Pi_\xn^\beta$ & $\beta$-Kostenprämie (Inkassokostenprämie)\\
- $\Pi_\xn^\gamma$ & $\gamma$-Kostenprämie (Verwaltungskostenprämie)\\[0.5em]
-
- 
- $\Pi_\xn^\text{inv.}$ & Inventarprämie (Netto- plus Verwaltungskostenprämie)\\[1em]
- 
- $\Pi_\xn^s$ & Sparprämie (zum Aufbau des Nettodeckungskapitals investierter Teil der Prämie)\\
- $\Pi_\xn^r$ & Risikoprämie (zur Deckung des einjährigen Ablebensrisikos benutzter Teil der Prämie)\\[0.5em]
- 
- $\Pi_\xn^v$ & verrechnete Prämie (Bruttoprämie inkl. Rabatte, Zuschläge, Stück"-kosten und Steuer) & \texttt{contract\$premiums[["{}written"]]}\\
- $\Pi_\xn^\text{tax}$ & Versicherungssteuer & \texttt{contract\$premiums[["{}tax"]]}\\
-\end{deftab}
-
-\subsection{Absolutwerte der Cashflows und Barwerte}
-
-TODO
-
-\subsection{Rückstellungen}
-
-\begin{deftab}
- $_{t}V_\xn$ & Nettodeckungskapital zum Zeitpunkt $t$  & \texttt{contract\$reserves[,"net"]}\\
- $_{t}V^a_\xn$ & Brutto-Deckungskapital (``adequate'' bzw. ``expense-loaded reserve'') & \texttt{contract\$reserves[,"adequate"]}\\
- $_{t}V^Z_\xn$ & Zillmerreserve bei Zillmerung & \texttt{contract\$reserves[,"Zillmer"]}\\
- $_{t}V^\alpha_xn$ & Abschlusskostenreserve & \texttt{contract\$reserves[,"TODO"]}\\
- $_{t}V^\beta_xn$ & Inkassokostenreserve (typischerweise $=0$)& \texttt{contract\$reserves[,"TODO"]}\\
- $_{t}V^\gamma_xn$ & Verwaltungskostenreserve & \texttt{contract\$reserves[,"gamma"]}\\
- $_{t}V^{Umr}_\xn$ & Umrechnungsreserve (Basis für Vertragskonvertierungen und Prämienfreistellung), inkl. anteiliger Abschlusskostenrückerstattung bei Beendigung innerhalb von fünf Jahren& \texttt{contract\$reserves[,"reduction"]}\\
- $AbskErh(t)$ & Anteilsmäßige Rückerstattung der Abschlusskosten bei Kündigung innerhalb von fünf Jahren& \texttt{contract\$reserves[,"alphaRefund"]}\\[1em]
- 
- $BilRes_{t+u}$  & Bilanzreserve (Interpolation aus  $_{t}V^{x}_\xn$ und $_{t+1}V^{x}_\xn$)
-\end{deftab}
-
-\subsection{Werte nach außerplanmäßiger Prämienfreistellung}
-
-Werte nach außerplanmäßiger Prämienfreistellung werden durch ein $\widetilde{\quad}$ über dem jeweiligen Symbol angezeigt.
- 
-
-
-
-
-\end{landscape}
-\pagebreak
-
-\section{Kosten}
-
-\subsection{Abschlusskosten (\texorpdfstring{$\alpha$}{alpha}-Kosten) / Zillmerkosten (Z-Kosten)}
-\begin{itemize}
- \item Einmalig (bei Vertragsabschluss)
- \begin{itemize}
-   \item \markiert{an Versicherungssumme}
-   \item \markiert{an Brutto-Prämiensumme}\footnote{Entspricht Einmalprämie bei Einmalerlag}
-   \item an Barwert der Versicherungsleistungen (z.B. Rentenbarwert) % HP PV5F & PV6F
- \end{itemize}
- \item Laufend (während Prämienzahlungsdauer)\footnote{Bei Einmalerlag sind einmalige $\alpha$-Kosten und laufende $\alpha$-Kosten auf die Prämie während der Prämienzahlungsdauer ident.}
- \begin{itemize}
-   \item \markiert{an Bruttoprämie}
-   \item an Brutto-Prämiensumme
- \end{itemize}
- \item Laufend (über gesamte Laufzeit des Vertrags)
- \begin{itemize}
-   \item an Bruttoprämie
-   \item an Brutto-Prämiensumme
- \end{itemize}
- 
-\end{itemize}
-
-% TODO: Check the following tariffs:
-%   - GW PV5F & PV6F
-
-\subsection{Inkassokosten (\texorpdfstring{$\beta$}{beta}-Kosten)}
-
-\begin{itemize}
- \item Laufend an Bruttoprämie während Prämienzahlungsdauer (einmalig bei Einmalerlag)
-\end{itemize}
-
-
-\subsection{Verwaltungskosten (\texorpdfstring{$\gamma$}{gamma}-Kosten)}
-
-Laufend während der gesamten Laufzeit verrechnet:
-
-\begin{itemize}
- \item \markiert{an Versicherungssumme (prämienpflichtig)}
- \item \markiert{an Versicherungssumme (planmäßig/außerplanmäßig prämienfrei)}
- \item an Leistungsbarwert / Rentenbarwert (=Deckungskapital) (prämienfrei) % GW PS0-9 & PV0-9
- \item an Prämiensumme (prämienpflichtig) (=am Rentenbarwert zu Vertragsbeginn bei sof.beg.LR mit EE)
- \item an Prämiensumme (planmäßig/außerplanmäßig prämienfrei)
- 
- \item am Ablösekapital während Aufschubzeit % ER III B-PZV Single
- \item \markiert{an jeder Erlebenszahlung/Rente (während Liquiditätsphase)} % ER III B-PZV Single
- \item am Deckungskapital % SV I5U
-\end{itemize}
-
-% TODO: Check the following tariffs:
-%   - GW PS0-9 & PV0-9
-%   - ER III B-PZV Single
-
-\subsection{Stückkosten \textit{StkK}}
-
-\begin{itemize}
- \item Stückkosten (Absolutbetrag) $StkK$ pro Jahr während Prämienzahlungsdauer (bzw. einmalig bei Einmalprämie)
-\end{itemize}
-
-
-\subsection{Übersicht}
-
-Die häufigsten Kostentypen sind \markiert{markiert}.
-
-% % \begin{longtable}{||l|v{3cm}|v{3cm}|v{3cm}|v{3cm}||}\hline\hline
-% %  & an VS & an PS & an JBP\footnote{während der gesamten Prämienzahlungsdauer} & \\ \hline
-% %  
-% % Abschluss $\alpha$ & \markiert{$\alpha^{VS}_{j}$ (einmalig)} & $\alpha^{PS}_{j}$ (LZ)\footnote{evt. mit jährlicher faktorieller Aufwertung (evt. mit Obergrenze)} & $\alpha^{BP}_{j}$ (LZ)\linebreak \markiert{$\alpha_{3a,j}$ (PrD)} & \\ \hline
-% % Zillmer $z$ & \markiert{$z^{VS}_{j}$} & \markiert{$z^{PS}_{j}$} & & \\ \hline
-% % Inkasso $\beta$ & & & \markiert{$\beta_{j}$ (PrD)} & \\ \hline
-% % Verwaltung $\gamma$ & \markiert{$\gamma^{VS}_{j}$ (PrD)}\linebreak \markiert{$\gamma^{VS,fr}_{j}$ (nach PrD)}\linebreak \markiert{$\gamma^{frei}_{j}$ (PrFrei)} & $\gamma^{PS}_{j}$ (LZ/PrD) & & $\gamma^{BP,PrD}_{j}$ (an ErlZ, LZ) \\\hline\hline
-% % % \\[-0.9em]\hline
-% % % 
-% % % Stückkosten $K$ & 
-% % % \\\hline\hline
-% % % 
-% % %  
-% % \end{longtable}
-% % 
-
-\begin{longtable}{||lr|v{2cm}|v{2cm}|v{2cm}|v{3cm}||}\hline\hline
-Typ & Dauer & an VS & an PS & an JBP\footnote{während der gesamten Prämienzahlungsdauer} & \\ \hline
- 
-
-Abschluss $\alpha$ & einmalig      & \markiert{$\alpha^{VS,once}$} &                                                                                                    &                            & \\ 
-                   & Prämiendauer  &                              &                                                                                                    & \markiert{$\alpha^{BP,PrD}$} & \\ 
-                   & Prämienfrei   &                              &                                                                                                    &                            & \\ 
-                   & Vertragsdauer &                              & $\alpha^{PS,LZ}$\footnote{evt. mit jährlicher faktorieller Aufwertung, evt. mit Obergrenze)} & $\alpha^{BP,LZ}$          & \\ \hline
-Zillmer $z$ & einmalig      & \markiert{$z^{VS,once}$} & \markiert{$z^{PS,once}$} & & \\ 
-            & Prämiendauer  &                         &                         & & \\ 
-            & Prämienfrei   &                         &                         & & \\ 
-            & Vertragsdauer &                         & $z^{PS,LZ}$ & & \\ \hline
-Inkasso $\beta$ & einmalig      & & &                              & \\ 
-                & Prämiendauer  & & & \markiert{$\beta^{BP,PrD}$} & \\ 
-                & Prämienfrei   & & &                              & \\ 
-                & Vertragsdauer & & &                              & \\ \hline
-Verwaltung $\gamma$ & einmalig      &  & & & \\
-                    & Prämiendauer  & \markiert{$\gamma^{VS,PrD}$}    & $\gamma^{PS,PrD}$ & & \\
-                    & Prämienfrei   & \markiert{$\gamma^{VS,fr}$} &                   & & $\gamma^{BP,Erl}$ (an ErlZ) \\
-                    & Vertragsdauer & $\gamma^{VS,LZ}$           & $\gamma^{PS,LZ}$ & &  \\\hline
-
-\multirow{4}{2.5cm}{{Verwaltung $\tilde{\gamma}$ (außerplanm. prämienfrei)}} & einmalig      & & & & \\
-                    & Prämiendauer  & & & & \\
-                    & Prämienfrei   & & & & \\
-                    & Vertragsdauer & \markiert{$\tilde{\gamma}^{VS,LZ}$} & & & \\
-\hline\hline
-\end{longtable}
-
-\subsection{Kosten-Cashflows}
-Jede Kostenart ($\alpha$/Zillmer/$\beta$/$\gamma$/$\tilde{\gamma}$) und Bemessungsgrundlage (VS/{}PS/{}JBP) erzeugt aus den verschiedenen Kostendauern einen Cash-Flow-Vektor in folgender Art, der diskontiert den gesamten Kostenbarwert der jeweiligen Kostenart und Bmgl. liefert:
-\begin{equation*}
- X_t^{Bmgl} = 
- \begin{cases}
- X^{Bmgl,once} + X^{Bmgl,PrD} + X^{Bmgl,LZ} & \text{für $t=0$} \\
- \hphantom{X^{Bmgl,once} + \;\,} X^{Bmgl,PrD} + X^{Bmgl,LZ} & \text{für $0<t\leq m$} \\
- \hphantom{X^{Bmgl,once} + \;\,} X^{Bmgl,fr} \;\;\; + X^{Bmgl,LZ} & \text{für $m<t\leq n$}
- \end{cases}
-\end{equation*}
-
-
-
-% \subsubsection{Stückkosten:}
-% \begin{longtable}{lp{13cm}}
-% $K_1$\dots & Stückkosten einmalig bei Vertragsabschluss\\
-% $K$\dots & Stückkosten jährlich während Prämienzahlungsdauer\\
-% $K_{LZ}$\dots & Stückkosten jährlich während der gesamten Laufzeit\\
-% \end{longtable}
-
-\pagebreak
-
-\section{Normierte Cashflows (auf Einheitswerte)}
-
-% \begin{sidewaystable}
-\begin{center}
- 
-
-% \rotatebox{90}{
-\begin{tabular}{lp{6.5cm}v{1.6cm}v{1.5cm}v{1.5cm}v{1cm}v{1cm}}
-& Beschreibung & LR & ALV & ELV & T-F & DD\\\hline\\[0.01em]
-$pr_t$  \dots          & Prämienzahlungen (vorschüssig) zu $t$ & $t<m$ & $t<m$ & $t<m$ & $t<m$ & $t<m$ \\
-$PS$                   & Prämiensumme, $PS=\sum_{t=0}^n pr_t$\\[0.5em]\hline\\[0em]
-
-$\ddot{e}_t$  \dots    & Erlebenszahlungen vorschüssig zu $t$ & $(l+g)...n$ & 0 & $t=n$ & 0 & 0 \\
-$e_t$  \dots           & Erlebenszahlungen nachschüssig zu $t+1$& $(l+g)...n$ & 0 & $t=n$ & 0 & 0 \\
-$\ddot{e}_t^{*}$ \dots & garantierte Zahlungen vorschüssig zu $t$ & $(l+g)...n$ & 0 & 0  & $t=n$ & 0 \\
-$e_t^{*}$  \dots       & garant. Zahlungen nachschüssig zu $t+1$ & $(l+g)...n$ & 0 & 0  & 0 & 0 \\[0.5em]\hline\\[0em]
-
-$a_t$  \dots           & Ablebenszahlung zu $t+1$ & 0 & $l...n$ & 0 & 0 & 0 \\
-$d_t$  \dots           & Zahlung zu $t+1$ bei Eintritt der Erkrankung zwischen $t$ und $t+1$ & 0 & 0 & 0 & 0& $l...n$ \\[0.5em]\hline\\[0em]
-$a_t^{(RG)}$           & Ablebenszahlungen für PRG zu $t+1$ (Ableben im Jahr $t$) & $\min(t+1, m, f)$ & 0 & $\min(t+1,m,f)$ & 0 & 0 \\[0.5em]\hline
-
-\end{tabular}
-% }
-\end{center}
-% \end{sidewaystable}
-
-Die Cash-Flows können auch in Matrixform dargestellt werden:
-\begin{align*}
-%
- \overrightarrow{CF}^L_t &= \left(
- \begin{matrix} % TODO: Add an indication that the first row is in advance, the second in arrears
-pr_t & \ddot{e}_t^{*} & \ddot{e}_t & 0 & 0 & 0 \\
-pr^{(nachsch)}_t & e_t^{*} & e_t & a_t & d_t & a_t^{(RG)}\\
-\end{matrix}
- \right)
-% 
-&
- \overrightarrow{CF}^K_t &= \left(
- \begin{matrix}
-\alpha^{(VS)}_t & \alpha^{(PS)}_t  & \alpha^{(BP)}_t \\
-z^{(VS)}_t & z^{(PS)}_t  & -\\
-- & - & \beta_t \\
-\gamma^{(VS)}_t & \gamma^{(PS)}_t & -\\
-\widetilde{\gamma}^{(VS)}_t & - & -\\  
- \end{matrix}
- \right)
-\end{align*}
-
-
-\pagebreak
-
-\section{Barwerte}
-
-\subsection{Prämienbarwert}
-
-\begin{align*} 
-P_\xn(t) &= \sum_{j=t}^n pr_{t+j} \cdot v^{j-t}  \cdot {}_{j-t}p_{x+t}\\
-	  &= pr_{t} + v \cdot p_{x+t} \cdot P_\xn(t+1)
-\end{align*}
-
-\subsection{Barwert garantierter Zahlungen:}
-Garantierte Erlebensleistungen (wenn Aufschubzeit überlebt wurde):
-% TODO!
-\begin{align*} 
- E^{*}_\xn(t) &= \begin{cases}
-		    {}_{l-t}p_{x+t} \cdot v^{l-t} \cdot \sum_{j=l}^{n} \left\{\ddot{e}^{*}_{j-t}+ v\cdot e^*_{j-t}\right\} v^{j-t} & \text{für $t<l$ (Aufschubzeit)}\\
-		    \sum_{j=t}^{n} \left\{\ddot{e}^{*}_{j-t}+ v\cdot e^*_{j-t}\right\} v^{j-t} & \text{für $t\ge l$ (Liquiditätsphase)}
-                 \end{cases}\\
-   &= \ddot{e}_t^{*} + \left\{E^{*}_\xn(t+1) + e_t^*\right\}\cdot v \cdot \begin{cases}
-	    1 & \text{für $t<l$ (Aufschubzeit)}\\
-            p_{x+t} & \text{für $t\ge l$ (Liquiditätsphase)}
-       \end{cases}
-\end{align*}
-
-
-\subsection{Erlebensleistungsbarwert:}
-% 1. Person:
-\begin{align*} 
-E_\xn(t) &= \sum_{j=t}^n \left(\ddot{e}_{t+j} \cdot v^{j-t}  {}_{j-t}p_{x+t} + e_{t+j} \cdot v^{j+1-t} {}_{j+1-t}p_{x+t} \right)\\
-	  &= \ddot{e}_{t} + v \cdot p_{x+t} \cdot \left\{ e_t + E_\xn(t+1)\right\}\\
-% \intertext{2. Person:}
-% E2_{\act[y]{n}}(t) &= \ddot{e}_{t} + v \cdot p_{y+t} \cdot \left\{ e_t + E2_{\act[y]{n}}(t+1)\right\}\\
-% \intertext{gemeinsam:}
-% E12_{\act[x,y]{n}}(t) &= \ddot{e}_{t} + v \cdot p_{x+t} \cdot p_{y+t} \cdot \left\{ e_t + E12_{\act[x,y]{n}}(n,t+1)\right\}\\
-\end{align*}
-
-% \intertext{Garantierte Erlebensleistungen (wenn Aufschubzeit überlebt wurde):}
-% % \begin{align*} 
-%  E^{*}_\xn(t) &= \begin{cases}
-% 		    {}_{l-t}p_{x+t} \cdot v^{l-t} \cdot \sum_{j=l}^{n} \left\{\ddot{e}^{*}_{j-t}+ v\cdot e^*_{j-t}\right\} v^{j-t} & \text{für $t<l$ (Aufschubzeit)}\\
-% 		    \sum_{j=t}^{n} \left\{\ddot{e}^{*}_{j-t}+ v\cdot e^*_{j-t}\right\} v^{j-t} & \text{für $t\ge l$ (Liquiditätsphase)}
-%                  \end{cases}\\
-%    &= \ddot{e}_t^{*} + \left\{E^{*}_\xn(t+1) + e_t^*\right\}\cdot v \cdot \begin{cases}
-% 	    1 & \text{für $t<l$ (Aufschubzeit)}\\
-%             p_{x+t} & \text{für $t\ge l$ (Liquiditätsphase)}
-%        \end{cases}
-% \end{align*}
-\subsection{Unterjährige Auszahlung der Erlebenszahlungen}
-
-Analog zu (bei konstanter Rente)
-\begin{align*}
- \ddot{a}^{(m)}_\xn &= \ddot{a}_x^{(m)} - {}_np_x \cdot v^n \cdot \ddot{a}_{x+n}^{(m)}\\
- \ddot{a}_x^{(m)} &= \alpha(m) \ddot{a}_x - \beta(m)
-\end{align*}
-mit 
-\begin{align*}
- \alpha(m)&= \frac{d \cdot i}{d^{(m)} \cdot i^{(m)}} & \beta(m) &= \frac{i-i^{(m)}}{d^{(m)} \cdot i^{(m)}}
-\end{align*}
-und $d = \frac{i}{1+i}$, $i^{(m)} = m \cdot \left((1+i)^{1/m} -1\right)$ und $d^{(m)} = i^{(m)} / \left(1+i^{(m)}/m\right)$ bzw. approximativ mit
-\begin{center}
-\begin{tabular}{rccccc}
-& 0.Ord. & 1.Ord. & 1,5-te Ord. & 2.Ord. & \\\hline
-$\alpha(m)$ = & 1 &  & & $+\frac{m^2-1}{12 m^2} i^2$ & ...\\
-$\beta(m)$ = & $\frac{m-1}{2m}$ & $+ \frac{m^2-1}{6 m^2}i$ & $\left[+ \frac{1-m^2}{12\cdot m^2}\cdot i^2\right]$ &$+ \frac{1-m^2}{24 m^2}i^2$ & ...\\[0.3em]\hline 
-\end{tabular}
-\end{center}
-
-ergibt sich auch für allgemeine unterjährige Erlebenszahlungen $\ddot{e}_t$ eine Rekursionsgleichung.
-
-\subsubsection{Vorschüssige \textit{m}-tel jährliche Auszahlung der Erlebensleistungen}
-
-
-\begin{align*}
-E^{(m)}_\xn(t) &= \ddot{e}_t \cdot \ddot{a}_{\act[x+t]{1}}^{(m)} + v \cdot p_{x+1} \cdot E^{(m)}_\xn(t+1)\\
-  &= \ddot{e}_t \cdot \left\{\alpha(m)  - \beta(m) \cdot \left(1-p_{x+t} \cdot v\right)\right\} + v\cdot p_{x+t} \cdot E^{(m)}_\xn(t+1)
-\end{align*}
-
-
-\subsubsection{Nachschüssige \textit{m}-tel jährliche Auszahlung der Erlebensleistungen}
-
-\begin{align*}
-E^{(m)}_\xn(t) &= e_t \cdot a_{\act[x+t]{1}}^{(m)} + v \cdot p_{x+t} \cdot E^{(m)}_\xn(t+1)\\
-   &= e_t\cdot\left\{\alpha(m) - \left(\beta(m)+\frac1m\right)\cdot\left(1-p_{x+t} v\right)\right\} + v\cdot p_{x+t} \cdot E^{(m)}_\xn(t+1)
-\end{align*}
-
-\subsubsection{Allgemeine \textit{m}-tel jährliche Auszahlung der Erlebensleistungen}
-
-
-\begin{align*}
-E^{(m)}_\xn(t) = &\ddot{e}_t \cdot \left\{\alpha(m)  - \beta(m) \cdot \left(1-p_{x+t} \cdot v\right)\right\} +  \\
- &e_t\cdot\left\{\alpha(m) - \left(\beta(m)+\frac1m\right)\cdot\left(1-p_{x+t} v\right)\right\} + \\
- &v\cdot p_{x+t} \cdot E^{(m)}_\xn(t+1)
-\end{align*}
-
-
-
-
-\subsection{Ablebensbarwert}
-
-
-\begin{align*} 
-\intertext{\subsubsection*{Prämienpflichtiger Ablebensbarwert}}
-A_\xn(t) &= \sum_{j=t}^n {}_{j-t}p_{x+t} \cdot q_{x+j} \cdot v^{j-t+1} \cdot a_{j} \\
-         &= q_{x+t} \cdot v \cdot a_t + p_{x+t} \cdot v \cdot A_\xn(t+1)\\
-%
-\intertext{\subsubsection*{Prämienfreier Ablebensbarwert}}
-A^{(prf)}_\xn(t) &= q_{x+t} \cdot v \cdot a^{(prf.)}_t + p_{x+t} \cdot v \cdot A^{(prf.)}_\xn(t+1)\\
-%
-\intertext{\subsubsection*{Barwert der gesamten Prämienrückgewähr (an BP)}}
-A^{(RG)}_\xn(t) &= q_{x+t} \cdot v \cdot a^{(RG)}_t + p_{x+t} \cdot v \cdot A^{(RG)}_\xn(t+1)\\
-%
-\intertext{\subsubsection*{Barwert der bisher bereits erworbenen Prämienrückgewähr (an BP)}}
-A^{(RG-)}_\xn(t) &= a^{(RG)}_{t-1} \cdot A^{(RG-,1)}_\xn(t)\\
-A^{(RG-,1)}_\xn(t) &= q_{x+t} \cdot v \cdot 1 + p_{x+t} \cdot v \cdot A^{(RG-,1)}_\xn(t+1)\\
-%
-\intertext{\subsubsection{Barwert der künftig noch zu erwerbenden Prämienrückgewähr (an BP)}}
-A^{(RG+)}_\xn(t) &= A^{(RG)}_\xn(t) - A^{(RG-)}_\xn(t)
-\intertext{Dieser Wert ist rekursiv nicht darstellbar.}
-\end{align*}
-
-\subsection{Disease-Barwert}
-\begin{align*} 
-A^d_\xn(t) &= i_{x+t} \cdot v \cdot d_t + p_{x+t} \cdot v \cdot A^d_\xn(t+1)\\
-\end{align*}
-
-\subsection{Leistungsbarwert}
-
-\begin{align*}
-BW^L_\xn(t) &= E_\xn(t) + A_\xn(t) + A^d_\xn(t) &\text{ohne Prämienrückgewähr}\\
-BW^{L,RG}_\xn(t) &= BW^L_\xn(t) + (1+\rho^{RG}) \cdot A^{(RG)}_\xn(t)\cdot BP_\xn &\text{inkl. Prämienrückgewähr}
-\end{align*}
-
-
-
-\subsection{Kostenbarwerte}
-
-\begin{align*}
-\intertext{Abschlusskostenbarwerte:}
-AK^{(VS)}_\xn(t) &= \alpha^{VS}_{t} + v \cdot p_{x+t} \cdot AK^{(VS)}_\xn(t+1) \\
-AK^{(PS)}_\xn(t) &= \alpha^{PS}_{t} + v \cdot p_{x+t} \cdot AK^{(PS)}_\xn(t+1) \\
-AK^{(BP)}_\xn(t) &= \alpha^{BP}_{t} + + v \cdot p_{x+t} \cdot AK^{(BP)}_\xn(t+1) \\
-\intertext{Zillmerkostenbarwerte:}
-ZK^{(VS)}_\xn(t) &= z^{VS}_{t} + v \cdot p_{x+t} \cdot ZK^{(VS)}_\xn(t+1) \\
-ZK^{(PS)}_\xn(t) &= z^{PS}_{t} + v \cdot p_{x+t} \cdot ZK^{(PS)}_\xn(t+1) \\
-\intertext{Inkassokostenbarwerte:}
-IK^{(BP)}_\xn(t) &= \beta^{BP}_{t} + v \cdot p_{x+t} \cdot IK^{(BP)}_\xn(t+1) \\
-\intertext{Verwaltungskostenbarwerte:}
-VK^{(VS)}_\xn(t) &= \gamma^{VS}_{t} + v \cdot p_{x+t} \cdot VK^{(VS)}_\xn(t+1) \\
-VK^{(PS)}_\xn(t) &= \gamma^{PS}_{t} + v \cdot p_{x+t} \cdot VK^{(PS)}_\xn(t+1) \\
-\widetilde{VK}^{(VS)}_\xn(t) &= \widetilde{\gamma}^{VS}_{t} + v \cdot p_{x+t} \cdot \widetilde{VK}^{(VS)}_\xn(t+1) \\
-\end{align*}
-
-
-\subsection{Darstellung der Barwerte in Vektor-/Matrixform}
-Die Leistungs- und Kostenbarwerte können (wie auch die Cashflows zu einem Zeitpunkt) 
-in Matrixform dargestellt werden (aus Gründen der Übersichtlichkeit wird hier bei 
-allen Termen der Subscript $\xn$ unterlassen):
-\begin{align*}
-  \overrightarrow{BW}^L(t) &= \left(
- \begin{matrix}
-    P(t), & %E^{Gar}(t), & E(t), & A(t), 
-    BW^L(t), & A^{(RG)}(t)
- \end{matrix}
- \right)
-% 
- &
-%  
- \overrightarrow{BW}^K(t) &= \left(
- \begin{matrix}
-AK^{(VS)}(t) & AK^{(PS)}(t)  & AK^{(BP)}(t) \\
-% 
-ZK^{(VS)}(t) & ZK^{(PS)}(t)  & -\\
-% 
-- & - & IK^{(BP)}(t) \\
-% 
-VK^{(VS)}(t) & VK^{(PS)}(t) & -\\
-\widetilde{VK}^{(VS)}(t) & - & -\\  
- \end{matrix}
- \right)
-% 
-\end{align*}
-
-
-
-\pagebreak
-
-\section{Prämien}
-
-\subsection{Nettoprämie:}
-\begin{align*}
-NP_\xn &= \frac{%E_\xn(0) + A_\xn(0) + \left(1+\rho^{RG}\right) \cdot A^{(RG)}_\xn(0) \cdot BP_\xn}
-BW^{L}_\xn(0) + \left(1+\rho^{RG}\right) \cdot A^{(RG)}_\xn(0) \cdot BP_\xn}
-{P_\xn(0)} \cdot \left(1+\rho\right)
-\end{align*}
-
-
-\subsection{Zillmerprämie (gezillmerte Nettoprämie):}
-% TODO: Sind die beta-Kosten proportional zu BP oder zur ZP??? I.e. ist \beta im Nenner mit BP oder im Zähler?
-\begin{align*}
-ZP_\xn &= 
-\frac{%
-%   NP_\xn\cdot P_\xn(0) +
-  \overbrace{\left(BW^{L}_\xn(0) + \left(1+\rho^{RG}\right) \cdot A^{(RG)}_\xn(0) \cdot BP_\xn\right) \cdot (1+\rho)}^{=NP_\xn\cdot P_\xn(0)} +
-  ZK^{(VS)}_\xn(0) + 
-  ZK^{(PS)}_\xn(0) \cdot BP_\xn \cdot PS + 
-  ZK^{(BP)}_\xn(0)\cdot BP_\xn
-%
-}{P_\xn(0)}
-\end{align*}
-
-Varianten:
-\begin{itemize}
- \item % REFERENCE: GE Tarife!
-     $\beta$- und $\gamma$-Kosten auch in die Zillmerprämie eingerechnet. Einziger Unterschied zur Bruttoprämie ist dann, dass nur die Zillmerkosten statt der $\alpha$-Kosten aufgeteilt werden.
-\begin{align*}
-ZP_\xn &= 
-\left[%
-%   NP_\xn\cdot P_\xn(0) + 
-  BW^{L,RG}_\xn(0) \cdot (1+\rho) +
-  \left(ZK^{(VS)}_\xn(0) + IK^{(VS)}_\xn(0) + VK^{(VS)}_\xn(0)\right) +  \right.\\
-  &\qquad\left.\left(ZK^{(PS)}_\xn(0) + IK^{(PS)}_\xn(0) + VK^{(PS)}_\xn(0)\right) \cdot BP_\xn \cdot PS + \right.\\
-  &\qquad\left.\left(ZK^{(BP)}_\xn(0) + IK^{(BP)}_\xn(0) + VK^{(BP)}_\xn(0)\right) \cdot BP_\xn
-%
-\right] / %
-\left(P_\xn(0)\right)
-\end{align*}
- 
- \item % REFERENCE: ME
-    Prämienrückgewähr proportional zu Zillmerprämie (für Berechnung der Zillmerprämie):
-\begin{align*}
-ZP_\xn &= \frac{BW^L_\xn(0) + \left(1+\rho^{RG}\right) \cdot A^{(RG)}_\xn(0) \cdot ZP_\xn}{P_\xn(0)} \cdot \left(1+\rho\right)\\
-ZP_\xn &= \frac{BW^L_\xn(0)}{P_\xn(0) - \left(1+\rho^{RG}\right)\cdot A^{(RG)}_\xn(0)\cdot \left(1+\rho\right)} \cdot \left(1+\rho\right)
-\end{align*}
- 
-\end{itemize}
-
-
-\subsection{Bruttoprämie:}
-\begin{align*}
-BP_\xn &= \frac%
-{ 
-   BW^L_\xn(0)\cdot\left(1+\rho\right) + 
-   \left( AK^{(VS)}_\xn(0) + IK^{(VS)}_\xn(0) + VK^{(VS)}_\xn(0) \right)
-}%
-{
-   P_\xn(0) - 
-   A^{(RG)}_\xn \left(1+\rho^{RG}\right) \left(1+\rho\right) - 
-         AK^{(BP)}_\xn - IK^{(BP)}_\xn - VK^{(BP)}_\xn - 
-   \left(AK^{(PS)}_\xn + IK^{(PS)}_\xn + VK^{(PS)}_\xn\right) PS
-}
-\end{align*}
-Wie man deutlich sehen kann, ist die Kostenursache ($\alpha$, $\beta$ oder $\gamma$) für die Prämienbestimmung irrelevant. Es werden die Barwerte aller drei Kostenarten jeweils bei der entsprechenden Bemessungsgrundlage aufaddiert.
-% 
-\subsection{Ablebensleistung im Jahr \textit{t}:}
-\begin{align*}
-Abl(t) &= \left\{a_t + a^{(RG)}_t \cdot BP_\xn\right\} \cdot VS
-\end{align*}
-
-\subsection{Koeffizienten in Vektorschreibweise}
-Für die Berechnung der Prämien können die Koeffizienten der jeweiligen Barwerte auch mittels der Vektor-/Ma\-trix\-schreib\-wei\-se dargestellt werden (siehe Tabelle \ref{PVCoeff}).
-\begin{sidewaystable}
-\centering
-
-% \newenvironment{benarray}{\big(\begin{array}{*4{C{3.4em}}C{12em}}}{\end{array}\big)}
-\newenvironment{benarray}{\big(\begin{array}{C{4em}C{5em}C{12em}}}{\end{array}\big)}
-\newenvironment{costarray}{\left(\begin{array}{*3{C{4.7em}}}}{\end{array}\right)}
-% TODO: laufende alpha-Kosten
-\begin{tabular}{||ll|c|c||}\hline\hline
- & & Leistungen & Kosten \\ \hline\hline
- Terme & &  
-%   $\begin{benarray}P_\xn(t) & E^{Gar}_\xn(t) & E_\xn(t) & A_\xn(t)  & A_\xn^{(RG)}(t)\end{benarray}$
-  $\begin{benarray}P_\xn(t) & BW^L_\xn(t)  & A_\xn^{(RG)}(t)\end{benarray}$
- &
- $\begin{costarray}
-AK^{(VS)}_\xn(t) & AK^{(PS)}_\xn(t)  & AK^{(BP)}_\xn(t) \\
-ZK^{(VS)}_\xn(t) & ZK^{(PS)}_\xn(t)  & -\\
-- & - & IK_\xn(t) \\
-VK^{(VS)}_\xn(t) & VK^{(PS)}_\xn(t) & -\\
-VK^{frei}_\xn(t) & - & -\\  
- \end{costarray}$
-\\\hline\hline
-
-
-Nettoprämie & Zähler & 
-  $\begin{benarray}0 & 1+\rho & \left(1+\rho^{RG}\right)\cdot BP_\xn \cdot \left(1+\rho\right)\end{benarray}$
- & -
-\\
-
- & Nenner & 
-  $\begin{benarray} 1 & 0 & 0 \end{benarray}$
- & - 
-\\\hline
-
-
-Zillmerprämie & Zähler & 
-  $\begin{benarray}0 & 1+\rho & \left(1+\rho^{RG}\right)\cdot BP_\xn \cdot \left(1+\rho\right)\end{benarray}$
- &
- $\begin{costarray}
-0 & 0 & 0 \\
-1 & BP_\xn\cdot PS & BP_\xn\\
-\orZero{1} & \orZero{BP_\xn\cdot PS} & \orZero{BP_\xn} \\
-\orZero{1} & \orZero{BP_\xn\cdot PS} & \orZero{BP_\xn} \\
-0 & 0 & 0 \\
- \end{costarray}$
-\\
-
- & Nenner & 
-  $\begin{benarray} 1 & 0 & 0\end{benarray}$
- &
--
-\\\hline
-
-Bruttoprämie & Zähler & 
-   $\begin{benarray}0 & 1+\rho & 0\end{benarray}$
- &
- $\begin{costarray}
-1 & 0 & 0 \\
-0 & 0 & 0\\
-1 & 0 & 0 \\
-1 & 0 & 0\\
-0 & 0 & 0\\
- \end{costarray}$
-\\
-
- & Nenner & 
-  $\begin{benarray}1 & 0 & -(1+\rho)\cdot(1+\rho^{RG}) \end{benarray}$
- &
- $\begin{costarray}
-0 & -PS & -1 \\
-0 & 0   & 0\\
-0 & -PS & -1 \\
-0 & -PS & -1\\
-0 & 0   & 0\\
- \end{costarray}$
-\\
-
-\hline\hline
-
-\end{tabular}
-\label{PVCoeff}
-\caption{Koeffizienten der einzelnen Barwerte zur Berechnung der Prämien}
-\end{sidewaystable}
-
-
-
-\section{Zuschläge und Abschläge, Vorgeschriebene Prämie}
-
-\begin{longtable}{p{4cm}p{11cm}}
- $oUZu$ \dots & Zuschlag für Vertrag ohne ärztliche Untersuchung\\
- $SuRa=SuRa(VS)$ \dots & Summenrabatt (von Höhe der VS abhängig)\\
- $VwGew$ \dots & Vorweggewinnbeteiligung in Form eines \%-uellen Rabattes auf die Bruttoprämie\\
- $StkK$ \dots & Stückkosten pro Jahr (während Prämienzahlungsdauer, einmalig bei Einmalprämien)\\
- $PrRa=PrRa(BP)$ \dots & Prämienrabatt (von Höhe der Bruttoprämie abhängig)\\
- $VwGew_{StkK}$ \dots & Vorweggewinnbeteiligung in Form eines Rabattes auf die Prämie nach Zu-/Abschlägen (insbesondere nach Stückkosten)\\
- $PartnerRa$ \dots & Partnerrabatt auf Prämie nach Zu-/Abschlägen (z.B. bei Abschluss mehrerer Verträge), additiv zu $VwGew_{StkK}$\\
- 
- $uz(k)$ \dots & Zuschlag für unterjährige Prämienzahlung ($k$ mal pro Jahr)
- \begin{equation*}
-  uz(k)=\left.\begin{cases}uk_1 & \text {für jährliche}\\uk_2 & \text {für halbjährliche} \\ uk_4 & \text{für quartalsweise}\\uk_{12} & \text{für monatliche}\end{cases}\right\} \text{Prämienzahlung}
- \end{equation*}\\
- 
- 
- $VSt$ \dots & Versicherungssteuer (in Österreich 4\% oder 11\%) \\
-
-\end{longtable}
-
-
-Vorgeschriebene Prämie:
-\begin{multline*}
-PV_\xn = \left\{ (BP_\xn + oUZu - SuRa) \cdot VS \cdot (1-VwGew) + StkK\right\} \cdot \\ \left(1-PrRa-VwGew_{StkK}-PartnerRa\right)\cdot \frac{1+uz(k)}{k} \cdot (1+VSt)
-% 
-\end{multline*}
-
-\section{Absolute Cash-Flows und Barwerte}
-
-TODO
-
-
-\pagebreak
-
-\section{Rückstellungen und Reserven}
-
-\subsection{Deckungskapital / Reserve}
-
-\subsubsection{Nettodeckungskapital prämienpflichtig:}
-\begin{align*}
-V_\xn(t) &= \left\{BW^L_\xn(t)\cdot(1+\rho) - NP_\xn\cdot P_\xn(t)\right\} \cdot VS
-\end{align*}
-
-\subsubsection{Zillmerreserve prämienpflichtig:}
-TODO!
-\begin{align*}
-V_\xn(t) &= \left\{BW^L_\xn(t)\cdot(1+\rho) - ZP_\xn\cdot P_\xn(t)\right\} \cdot VS =\\
- &= \left\{BW^L_\xn(t)\cdot(1+\rho) - NP_\xn\cdot P_\xn(t) - ZK_\xn(0) \cdot BP_\xn(t) \cdot \frac{P_\xn(t)}{P_\xn(0)}\right\} \cdot VS \\
-\end{align*}
-
-\subsubsection{Reserve prämienpflichtig:}
-Entspricht bei Zillmerung der Zillmerreserve
-\begin{align*}
-V_\xn(t) &= \left\{BW^L_\xn(t)\cdot(1+\rho) - ZP_\xn\cdot P_\xn(t)\right\} \cdot VS \\
-\end{align*}
-
-\subsubsection{Bruttoreserve prämienpflichtig:}
-
-\begin{align*}
-V^{(b)}_\xn(t) &= \left\{BW^L_\xn(t)\cdot(1+\rho) +  - ZP_\xn\cdot P_\xn(t)\right\} \cdot VS \\
-\end{align*}
-
-\subsection{Verwaltungskostenreserve:}
-\begin{align*}
-V^{VwK}_\xn(t) &= \left\{ VK^{(VS)}_\xn(t) - \left(\frac{VK^{(VS)}_\xn(0)}{P_\xn(0)}\right) \cdot P_\xn(t)\right\} \cdot VS\\
-\end{align*}
-
-\subsection{Reserve prämienfrei:}
-\begin{align*}
-V^{frei}_\xn(t) &= \left\{(E_\xn(t) + A1_\xn(t))\cdot\widetilde{VW} + TODO \cdot \min(f,m) \cdot BP_\xn(x,n)\cdot VS\right\} \cdot (1+\rho) \\
-\end{align*}
-
-\subsection{Verwaltungskostenreserve prämienfrei:}
-\begin{align*}
-V^{WvK,frei}_\xn(t) &= VK4_\xn(t) \cdot \widetilde{VS}
-\end{align*}
-
-\section{Spar- und Risikoprämie}
-
-
-\begin{equation*}
- P_\xn(t) = SP_\xn(t) + RP_\xn(t)
-\end{equation*}
-
-
-\subsection{Sparprämie}
-
-\begin{align*}
-SP_\xn(t) &= V_\xn(t+1) \cdot v - V_\xn(t) + \left(\ddot{e}_t + v\cdot e_t\right)\cdot VS
-\end{align*}
-
-\subsection{Risikoprämie}
-\begin{align*}
-RP_\xn(t) &= v\cdot q_{x+t} \cdot \left\{Abl(t) - V_\xn(t+1)\right\} 
-\end{align*}
-
-
-\section{Bilanzreserve}
-
-\begin{tabular}{lp{14cm}}
-$BegDatum$ \dots & Beginndatum des Vertrags\\
-$BilDatum$ \dots & Bilanzstichtag  des Unternehmens\\
-$baf$ \dots & Bilanzabgrenzungsfaktor (Jahresanteil zwischen Abschlussdatum und Bilanzstichtag)
-\begin{itemize}
- \item 30/360: $baf=\frac{Monat(BilDatum+1)-Monat(BegDatum)+1}{12} \mod 1$
- \item Taggenau: $baf=\frac{BilDatum-BegDatum+1}{TageImJahr(BilDatum)} \mod 1$
- \item etc.
-\end{itemize}
-\\
-\end{tabular}
-
-
-\subsection{prämienpflichtig}
-% Bilanzabgrenzungsfaktor 
-Bilanzreserve für Versicherungsleistungen:
-\begin{align*}
-BilRes^{(L)}_\xn(t) &= (1-baf)\cdot V_\xn(t) + baf \cdot V_\xn(t+1)\\
-\intertext{Verwaltungskosten-Bilanzreserve:}
-BilRes^{(VwK)}_\xn(t) &= (1-baf)\cdot V^{(VwK)}_\xn(t) + baf \cdot V^{(VwK)}_\xn(t+1)\\
-\intertext{Gesamte Bilanzreserve:}
-BilRes_\xn(t) &= BilRes^{(L)}_\xn(t) + BilRes^{(VwK)}_\xn(t)\\
-\intertext{\subsection{prämienfrei}
-Bilanzreserve für Versicherungsleistungen, prämienfrei:}
-BilRes^{(L),frei}_\xn(t) &= (1-baf)\cdot V^{frei}_\xn(t) + baf \cdot V^{frei}_\xn(t+1)\\
-\intertext{Verwaltungskosten-Bilanzreserve, prämienfrei:}
-BilRes^{(VwK),frei}_\xn(t) &= (1-baf)\cdot V^{VwK,frei}_\xn(t) + baf \cdot V^{VwK,frei}_\xn(t+1)\\
-\intertext{Gesamte Bilanzreserve, prämienfrei:}
-BilRes^{frei}_\xn(t) &= BilRes^{(L),frei}_\xn(t) + BilRes^{(VwK),frei}_\xn(t)\\\
-\end{align*}
-
-
-\pagebreak
-
-\section{Prämienfreistellung und Rückkauf}
-
-Verteilung der $\alpha$-Kosten auf $r$ Jahre für den Rückkauf bzw. die Vertragskonversion 
-ist nicht bei allen Tarifen oder in allen Jurisdiktionen vorgesehen. => FLAG
-
-\subsection{Umrechnungsreserve}
-Sowohl Prämienfreistellung als auch Rückkauf starten von der Umrechnungsreserve, die sich aus der 
-Zillmerreserve, den Kostenrückstellungen sowie der Verteilung der $\alpha$-Kosten auf 5 Jahre ergibt:
-\begin{align*}
- V_\xn^{Umr} &= \left(V_\xn(t) + V^{VwK}_\xn(t) + AbsKErh(t)\right)\cdot (1-VwGew(TODO))
-\end{align*}
-wobei $AbsKErh(t)$ die anteilsmäßige Rückzahlung der Abschlusskosten bei Rückkauf innerhalb der ersten 
-$n(=5)$ Jahre gemäß \S 176 öVersVG bezeichnet:
-\begin{align*}
-AbskErh(t) &= \max\left(\sum_{j=0}^t Zillm(j) - \frac{t}{5} \sum_{j=0}^n Zillm(j), 0\right)&& \text{(Abschlusskostenerhöhungsbetrag)}\\
-Zillm(t) &= z^{(VS)}_t + z^{(BP)} \cdot BP_\xn + z^{(PS)}_t \cdot BP_\xn \cdot \sum_{j=0}^n pr_j &&\text{(Zillmerprämienanteil/-cashflow im Jahr $j$)}
-\end{align*}
-
-Varianten:
-\begin{itemize}
- \item Verteilung auf 5 Jahre nicht linear ($t/5$), sondern als 5-jährige Leibrente bewertet, deren Rest noch ausständig ist.
- \begin{align*}
-   AbskErh(t) &= \max\left(\sum_{j=0}^t Zillm(j) - \left(1-\frac{\ddot{a}_{\act[x+t]{r-t}}}{\ddot{a}_{\act[x]{r}}}\right) \frac{t}{5} \sum_{j=0}^n Zillm(j), 0\right)
- \end{align*}
- \item Bei zahlreichen Tarifen wird die Abschlusskostenerhöhung erst NACH dem Rückkaufsabschlag addidiert, 
-    sodass diese Erhöhung nicht vom Abschlag betroffen ist => FLAG
-\end{itemize}
-
-\subsection{Rückkaufswert (prämienpflichtig)}
-
-Zahlreiche Tarife sind NICHT rückkaufsfähig => FLAG
-
-\begin{align*}
- Rkf(t) &= f(V_\xn^{Umr}, ...) 
-\end{align*}
-
-Die Abschläge von der Umrechnungsreserve auf den Rückkaufswert sind im Allgemeinen nicht 
-standardisiert, sondern variieren je nach Versicherungsunternehmen stark. Mögliche
-Abschläge sind:
-
-\subsubsection*{Prozentualer Rückkaufsabschlag}
-Prozentualer Abschlag auf die Umrechnungsreserve, z.B. $2\%$ oder $5\%$:
-$RkfFakt=0.95$
-\begin{align*}
-f(V_\xn^{Umr}, ...) = RkfFakt \cdot V_\xn^{Umr} \text{\quad mit $RkfFakt=0.98$ oder $0.95$}
-\end{align*}
-
-\subsubsection*{Lineare Erhöhung des prozentualen Rückkaufsabschlags}
-\begin{align*}
-f(V_\xn^{Umr}, ...) &= RkfFakt(t) \cdot V_\xn^{Umr} \\
-RkfFakt(t) &= min(k_1 + t \cdot \delta k; k_2) \text{\quad mit z.B. $k_1=0.9$, $\delta k = 0.005$ und $k_2=0.98$}
-\end{align*}
-Alternativ:
-\begin{equation*}% ME L12PLK3Z
- RkfFakt(t) = \begin{cases}                
-0.95 & 1\leq t \leq 3\\
-0.95 + 0.003\cdot(t-3) & 3<t\leq 13\\
-0.98 & 13<t
-\end{cases}
-\end{equation*}
-
-
-\subsubsection*{Prozentualer Abschlag mit Mindestabschlag}
-% GW GDV1
-\begin{align*}
-f(V_\xn^{Umr}, ...) &= min\left(0.95 \cdot V_\xn^{Umr}, Abl(t), V_\xn^{Umr}-0.15 \cdot BP_\xn \cdot VS\cdot (1-VwGew)\right)
-\end{align*}
-
-% GW ER11
-\begin{align*}
-f(V_\xn^{Umr}, ...) &= min\left(0.95 \cdot V_\xn^{Umr}, Abl(t)\right)
-\end{align*}
-
-
-\subsubsection*{Prozentualer Abschlag mit Mindestabschlag (Mindesttodesfallsumme als Grenze)}
-% HP/GW:
-\begin{align*}
-f(V_\xn^{Umr}, ...) &= min(0.95 \cdot V_\xn^{Umr}, MTS(m,t)) \\
-MTS(m,t) &= ...
-\end{align*}
-
-
-\subsubsection*{Abschlag proportional zum Deckungskapital}
-% GE
-\begin{align*}
-f(V_\xn^{Umr}, ...) &= V_\xn^{Umr}\cdot \left(s_f + \max(0.97-s_f, 0) \cdot \frac{V_\xn^{Umr}}{VS}\right) \\
-s_f &=\begin{cases}0.92 & \text{ für $t<\max(10, n-5)$}\\ 1 & \text{sonst}\end{cases}
-\end{align*}
-
-
-TODO: Weitere mögliche Rückkaufsabschläge rausfinden
-
-\subsection{Stornogebühr bei Rückkauf}
-
-Manche Tarife sehen eine fixe Stornogebühr bei Rückkauf (z.B. nur in den ersten 24 Monaten) vor:
-% GW
-\begin{equation*}
- StoGeb = \min\left(\max\left(0.15 \cdot PV(x,n) \cdot\frac{pz}{1-uz(pz)} \cdot\frac1{1+VSt}, 30 \right), 300\right)
-\end{equation*}
-Ansonsten: $StoGeb=0$.
-
-
-
-\subsection{Prämienfreistellung}
-
-Der Vertrag wird zum Zeitpunkt $f$ prämienfrei gestellt, d.h. ab $f$ wird keine Prämie mehr bezahlt, 
-die Höhe des Versicherungsschutzes bestimmt sich aus dem zu $f$ vorhandenen Deckungskapital und den 
-Kostenreserven (Umrechnungsreserve). Bei Prämienrückgewähr wird nur die tatsächlich bezahlte Prämiensumme rückgewährt.
-
-Aus
-\begin{align*}
- V_\xn^{Umr}(f) - StoGeb %= \\
- = \underbrace{BW^L_\xn(f)\cdot\left(1+\rho\right)\cdot \widetilde{VS} + BW^{RG,frei}_\xn(f)\cdot \left(1+\rho\right) \cdot BP_\xn \cdot VS}_{=V^{frei}_\xn(f)} + \underbrace{VK^{frei}_\xn(f)}_{=V_\xn^{VwK,frei}(f)}
-%  =  V^{frei}_\xn(f) + V_\xn^{VwK,frei}(f)
-\end{align*}
-mit
-\begin{align*}
-BW^{RG,frei}_\xn(f) &= A^{(RG)}_\xn(t) \cdot \underbrace{\sum_{j=0}^{f-1} pr_j}_{\substack{=\min\left(f,m\right)\text{ bei }\\\text{lfd. konst. Prämie}}} && \text{(BW zukünftiger Prämienrückgewähr)}
-\end{align*}
-ergibt sich die neue Versicherungssumme $\widetilde{VS}(f)$ nach Prämienfreistellung zum Zeitpunkt $f$:
-\begin{equation*}
-\widetilde{VS}(f) = \frac
-  { V_\xn^{Umr}(f) - BW^{RG,frei}_\xn(f)\cdot (1+\rho)\cdot BP_\xn \cdot VS - StoGeb}
-  {BW^L_\xn(f)\cdot(1+\rho) + VK^{frei}_\xn(f)}
-\end{equation*}
-
-\subsection{Reserven nach außerplanmäßiger Prämienfreistellung}
-
-\subsubsection*{Nettodeckungskapital außerplanmäßig Prämienfrei zu $f$}
-
-\begin{align*}
-V^{(n),prf,f}_\xn(t) &= \left\{BW^{L,prf}_\xn(t)\cdot(1+\rho)\right\} \cdot \widetilde{VS(f)}
-\end{align*}
-
-\subsubsection{Reserve außerplanmäßig prämienfrei:}
-
-\begin{align*}
-V_\xn^{prf,f}(t) &= \left\{BW^{L,pr}_\xn(t)\cdot(1+\rho) + BW^{RG,frei,f}_{\act[x]{x}}(t)\right\} \cdot \widetilde{VS(f)} \\
-\end{align*}
-
-\subsection{Verwaltungskostenreserve außerplanmäßig prämienfrei:}
-\begin{align*}
-V^{VwK,prf,f}_\xn(t) &= \left\{ VK^{(VS), prf.}_\xn(t) + VK^{(PS),prf.}_\xn(t)\cdot PS(f)\right\} \cdot \widetilde{VS(f)}\\
-\end{align*}
-
-
-TOCHECK:
-\subsection{Reserve prämienfrei:}
-\begin{align*}
-V^{frei}_\xn(t) &= \left\{(E_\xn(t) + A1_\xn(t))\cdot\widetilde{VW} + TODO \cdot \min(f,m) \cdot BP_\xn(x,n)\cdot VS\right\} \cdot (1+\rho) \\
-\end{align*}
-
-\subsection{Verwaltungskostenreserve prämienfrei:}
-\begin{align*}
-V^{WvK,frei}_\xn(t) &= VK4_\xn(t) \cdot \widetilde{VS}
-\end{align*}
-
-\subsection{Umrechnungsreserve außerplanmäßig prämienfrei}
-\begin{align*}
- V_\xn^{Umr, prf, f}(t) &= \left(V^{prf,f}_\xn(t) + V^{VwK,prf,f}_\xn(t)\right)\cdot (1-VwGew(TODO))
-\end{align*}
-
-
-
-
-
-\end{document}
diff --git a/NAMESPACE b/NAMESPACE
index d75f824ec6278db24891505b14ab3d915514dba7..48ea9787871f20267290b6136650ece7440ca1a6 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1 +1,33 @@
-exportPattern("^[[:alpha:]]+")
+# Generated by roxygen2: do not edit by hand
+
+export(getCohortTable)
+export(plotValuationTables)
+export(undampenTrend)
+export(valuationTable)
+export(valuationTable_ageShift)
+export(valuationTable_improvementFactors)
+export(valuationTable_joined)
+export(valuationTable_mixed)
+export(valuationTable_observed)
+export(valuationTable_period)
+exportClasses(valuationTable)
+exportClasses(valuationTable_ageShift)
+exportClasses(valuationTable_improvementFactors)
+exportClasses(valuationTable_joined)
+exportClasses(valuationTable_mixed)
+exportClasses(valuationTable_observed)
+exportClasses(valuationTable_period)
+exportMethods(ageShift)
+exportMethods(ages)
+exportMethods(baseTable)
+exportMethods(baseYear)
+exportMethods(deathProbabilities)
+exportMethods(getCohortTable)
+exportMethods(getOmega)
+exportMethods(getPeriodTable)
+exportMethods(lifeTable)
+exportMethods(periodDeathProbabilities)
+exportMethods(undampenTrend)
+import(ggplot2)
+import(methods)
+import(openxlsx)
diff --git a/R/HelperFunctions.R b/R/HelperFunctions.R
deleted file mode 100644
index e43c2f6c493ea02eb8f3ace80e6d69c52a339f9b..0000000000000000000000000000000000000000
--- a/R/HelperFunctions.R
+++ /dev/null
@@ -1,154 +0,0 @@
-library(abind);
-
-mergeValues = function(starting, ending, t) {
-  rbind(starting[1:t,], ending[-1:-t,])
-}
-mergeValues3D = function(starting, ending, t) {
-  abind(starting[1:t,,], ending[-1:-t,,], along=1)
-}
-# Caution: px is not neccessarily 1-qx, because we might also have dread diseases so that px=1-qx-ix! However, the ix is not used for the survival present value
-calculatePVSurvival = function(px=1-qx, qx=1-px, advance, arrears=c(0), ..., m=1, mCorrection = list(alpha=1, beta=0), v=1) {
-  # assuming advance and arrears have the same dimensions...
-  init = advance[1]*0;
-  l = max(length(qx), length(advance), length(arrears));
-  q = pad0(qx, l, value=1);
-  p = pad0(px, l, value=0);
-  advance = pad0(advance, l, value=init);
-  arrears = pad0(arrears, l, value=init);
-
-  # TODO: Make this work for matrices (i.e. currently advance and arrears are assumed to be one-dimensional vectors)
-  # TODO: Replace loop by better way (using Reduce?)
-  res = rep(0, l+1);
-  for (i in l:1) {
-    # coefficients for the payments (including corrections for payments during the year (using the alpha(m) and beta(m)):
-    advcoeff = mCorrection$alpha - mCorrection$beta*(1-p[i]*v);
-    arrcoeff = mCorrection$alpha - (mCorrection$beta + 1/m)*(1-p[i]*v);
-    # The actual recursion:
-    res[i] = advance[i]*advcoeff + arrears[i]*arrcoeff + v*p[i]*res[i+1];
-  }
-  res[1:l]
-}
-
-
-calculatePVGuaranteed = function(advance, arrears=c(0), ..., m=1, mCorrection = list(alpha=1, beta=0), v=1) {
-  # assuming advance and arrears have the same dimensions...
-  init = advance[1]*0;
-  l = max(length(advance), length(arrears));
-  advance = pad0(advance, l, value=init);
-  arrears = pad0(arrears, l, value=init);
-
-  # TODO: Make this work for matrices (i.e. currently advance and arrears are assumed to be one-dimensional vectors)
-  # TODO: Replace loop by better way (using Reduce?)
-  res = rep(0, l+1);
-  for (i in l:1) {
-    # coefficients for the payments (including corrections for payments during the year (using the alpha(m) and beta(m)):
-    advcoeff = mCorrection$alpha - mCorrection$beta*(1-v);
-    arrcoeff = mCorrection$alpha - (mCorrection$beta + 1/m)*(1-v);
-    # The actual recursion:
-    res[i] = advance[i]*advcoeff + arrears[i]*arrcoeff + v*res[i+1];
-  }
-  res[1:l]
-}
-
-
-# TODO: So far, we are assuming, the costs array has sufficient time steps and does not need to be padded!
-calculatePVCosts = function(px=1-qx, qx=1-px, costs, ..., v=1) {
-  l = max(length(qx), dim(costs)[1]);
-  p = pad0(px, l, value=0);
-  costs = costs[1:l,,];
-
-  # Take the array structure from the cash flow array and initialize it with 0
-  res = costs*0;
-  prev = res[1,,]*0;
-  # Backward recursion starting from the last time:
-  for (i in l:1) {
-    # cat("values at iteration ", i, ": ", v, q[i], costs[i,,], prev);
-    res[i,,] = costs[i,,] + v*p[i]*prev;
-    prev=res[i,,];
-  }
-  res
-}
-
-calculatePVDeath = function(px, qx, benefits, ..., v=1) {
-  init = benefits[1]*0; # Preserve the possible array structure of the benefits -> vectorized calculations possible!
-  l = max(length(qx), length(benefits));
-  q = pad0(qx, l, value=1);
-  p = pad0(px, l, value=0);
-  benefits = pad0(benefits, l, value=init);
-
-  # TODO: Make this work for matrices (i.e. currently benefits are assumed to be one-dimensional vectors)
-  # TODO: Replace loop by better way (using Reduce?)
-  res = rep(init, l+1);
-  for (i in l:1) {
-    # Caution: p_x is not neccessarily 1-q_x, because we might also have dread diseases, so that px=1-qx-ix!
-    res[i] = v*q[i]*benefits[i] + v*p[i]*res[i+1];
-  }
-  res[1:l]
-}
-
-calculatePVDisease = function(px=1-qx-ix, qx=1-ix-px, ix=1-px-qx, benefits, ..., v=1) {
-  init = benefits[1]*0;
-  l = min(length(ix), length(qx), length(benefits));
-  qx = pad0(qx, l, value=1);
-  ix = pad0(ix, l, value=0);
-  px = pad0(px, l, value=0);
-  benefits = pad0(benefits, l, value=init);
-
-  # TODO: Make this work for matrices (i.e. currently benefits are assumed to be one-dimensional vectors)
-  # TODO: Replace loop by better way (using Reduce?)
-  res = rep(init, l+1);
-  for (i in l:1) {
-    res[i] = v*ix[i]*benefits[i] + v*px[i]*res[i+1];
-  }
-  res[1:l]
-}
-
-
-
-getSavingsPremium = function(reserves, v=1) {
-  pad0(reserves[-1], length(reserves))*v - reserves
-}
-
-correctionPaymentFrequency = function(m = 1, i = self$i, order = 0) {
-  # 0th-order approximation
-  alpha=1;
-  beta=0;
-  # negative orders mean that NO correction is done, e.g. because other means of
-  # correction are used like an explicit premium frequency loading on the premium.
-  if (order >=0 ) beta = beta + (m-1)/(2*m);
-  # For higher orders, simply add one term after the other!
-  if (order >= 1)     beta = beta + (m^2-1)/(6*m^2)*i; # S-Versicherung: *(1-i/2)
-  # order 1.5 has a special term that should NOT be used for higher-order approximations!
-  if (order == 1.5)   beta = beta + (1-m^2)/(12*m^2)*i^2;
-
-  if (order >= 2) {
-    beta = beta + (1-m^2)/(24*m^2)*i^2;
-    alpha = alpha + (m^2-1)/(12*m^2)*i^2;
-  }
-  # Exact value
-  if (order == Inf) {
-    d = i/(1+i);
-    im = m * ((1+i)^(1/m) - 1);
-    dm = im / (1+im/m);
-
-    alpha = d*i / (dm*im);
-    beta = (i-im) / (dm*im);
-  }
-  list(alpha=alpha, beta=beta);
-}
-
-pad0 = function(v, l, value=0) {
-  if (l>=length(v)) {
-    c(v, rep(value, l-length(v)))
-  } else {
-    v[0:l]
-  }
-}
-
-valueOrFunction = function(val, ...) {
-  if (is.function(val)) {
-    val(...)
-  } else {
-    val
-  }
-}
diff --git a/R/InsuranceContract.R b/R/InsuranceContract.R
deleted file mode 100644
index f9eab7dcf5875ec8425b90f07204f43c809dbe43..0000000000000000000000000000000000000000
--- a/R/InsuranceContract.R
+++ /dev/null
@@ -1,209 +0,0 @@
-library(R6)
-library(openxlsx);
-
-InsuranceContract = R6Class("InsuranceContract",
-
-  public = list(
-    tarif = NA,
-
-    #### Contract settings
-    params = list(
-      sumInsured = 1,
-      premiumWaiver = 0,
-      YOB = NA,
-      age = NA,
-      policyPeriod = Inf,
-      premiumPeriod = 1,
-      deferral = 0,
-      guaranteed = 0,
-
-      premiumPayments = PaymentTimeEnum("in advance"),
-      benefitPayments = PaymentTimeEnum("in advance"),
-
-      premiumFrequency = 1,
-      benefitFrequency = 1, # Only for annuities!
-
-      loadings = list(),     # Allow overriding the tariff-defined loadings (see the InsuranceTariff class for all possible names)
-      surrenderPenalty = TRUE,  # Set to FALSE after the surrender penalty has been applied once, e.g. on a premium waiver
-      alphaRefunded = FALSE     # Alpha costs not yet refunded (in case of contract changes)
-    ),
-
-    #### Caching values for this contract, initialized/calculated when the object is created
-    values = list(
-      basicData = NA,
-      transitionProbabilities = NA,
-
-      cashFlowsBasic = NA,
-      cashFlows = NA,
-      cashFlowsCosts = NA,
-      premiumSum = 0,
-
-      presentValues = NA,
-      presentValuesCosts = NA,
-
-      premiumCoefficients = NA,
-      premiums = NA,
-      absCashFlows = NA,
-      absPresentValues = NA,
-
-      reserves = NA,
-
-      premiumComposition = NA
-    ),
-
-    #### Keeping the history of all contract changes during its lifetime
-    history = list(),
-
-
-    #### The code:
-
-    initialize = function(tarif, age, sumInsured = 1,
-                          policyPeriod, premiumPeriod = policyPeriod, guaranteed = 0,
-                          ...,
-                          loadings = list(),
-                          premiumPayments = "in advance", benefitPayments = "in advance",
-                          premiumFrequency = 1, benefitFrequency = 1,
-                          deferral = 0, YOB = 1975) {
-      self$tarif = tarif;
-      self$params$age = age;
-      self$params$policyPeriod = policyPeriod;
-      if (missing(premiumPeriod) && !is.null(self$tarif$defaultPremiumPeriod)) {
-        self$params$premiumPeriod = self$tarif$defaultPremiumPeriod;
-      } else {
-        self$params$premiumPeriod = premiumPeriod;
-      }
-      self$params$sumInsured = sumInsured;
-      if (!missing(deferral))         self$params$deferral = deferral;
-      if (!missing(YOB))              self$params$YOB = YOB;
-      if (!missing(premiumPayments))  self$params$premiumPayments = premiumPayments;
-      if (!missing(benefitPayments))  self$params$benefitPayments = benefitPayments;
-      if (!missing(premiumFrequency)) self$params$premiumFrequency = premiumFrequency;
-      if (!missing(benefitFrequency)) self$params$benefitFrequency = benefitFrequency;
-      if (!missing(guaranteed))       self$params$guaranteed = guaranteed;
-      if (!missing(loadings))         self$params$loadings = loadings;
-
-      self$calculateContract();
-    },
-
-    addHistorySnapshot = function(time=0, comment="Initial contract values", type="Contract", params=self$params, values = self$values) {
-      self$history = rbind(self$history,
-                       list(time=list("time"=time, "comment"=comment, "type"=type, "params"=params, "values"=values)));
-    },
-
-    calculateContract = function() {
-      self$values$transitionProbabilities = self$determineTransitionProbabilities();
-
-      self$values$cashFlowsBasic = self$determineCashFlowsBasic();
-      self$values$cashFlows = self$determineCashFlows();
-      self$values$premiumSum = self$determinePremiumSum();
-      self$values$cashFlowsCosts = self$determineCashFlowsCosts();
-
-      self$values$presentValues = self$calculatePresentValues();
-      self$values$presentValuesCosts = self$calculatePresentValuesCosts();
-
-      # the premiumCalculation function returns the premiums AND the cofficients,
-      # so we have to extract the coefficients and store them in a separate variable
-      res = self$calculatePremiums();
-      self$values$premiumCoefficients = res[["coefficients"]];
-      self$values$premiums = res[["premiums"]]
-
-      # Update the cash flows and present values with the values of the premium
-      pvAllBenefits = self$calculatePresentValuesBenefits()
-      self$values$presentValues = cbind(self$values$presentValues, pvAllBenefits)
-
-      self$values$absCashFlows = self$calculateAbsCashFlows();
-      self$values$absPresentValues = self$calculateAbsPresentValues();
-      self$values$reserves = self$calculateReserves();
-      self$values$basicData = self$getBasicDataTimeseries()
-      self$values$premiumComposition = self$premiumAnalysis();
-
-      self$addHistorySnapshot(0, "Initial contract values", type="Contract", params=self$params, values = self$values);
-    },
-
-    determineTransitionProbabilities = function(contractModification=NULL) {
-      do.call(self$tarif$getTransitionProbabilities, c(self$params, self$values, list(contractModification=contractModification)));
-    },
-    determineCashFlowsBasic = function(contractModification=NULL) {
-      do.call(self$tarif$getBasicCashFlows, self$params);
-    },
-    determineCashFlows = function(contractModification=NULL) {
-      do.call(self$tarif$getCashFlows, c(self$params, self$values, list(contractModification=contractModification)));
-    },
-    determinePremiumSum = function(contractModification=NULL) {
-      sum(self$values$cashFlows$premiums_advance + self$values$cashFlows$premiums_arrears);
-    },
-    determineCashFlowsCosts = function(contractModification=NULL) {
-      do.call(self$tarif$getCashFlowsCosts, c(self$params, self$values, list(contractModification=contractModification)));
-    },
-    calculatePresentValues = function(contractModification=NULL) {
-      do.call(self$tarif$presentValueCashFlows, c(self$params, self$values, list(contractModification=contractModification)));
-    },
-    calculatePresentValuesCosts = function(contractModification=NULL) {
-      do.call(self$tarif$presentValueCashFlowsCosts, c(self$params, self$values, list(contractModification=contractModification)));
-    },
-    calculatePremiums = function(contractModification=NULL) {
-      do.call(self$tarif$premiumCalculation, c(self$params, self$values, list(contractModification=contractModification)));
-    },
-    calculatePresentValuesBenefits = function(contractModification=NULL) {
-      do.call(self$tarif$presentValueBenefits, c(self$params, self$values, list(contractModification=contractModification)));
-    },
-    calculateAbsCashFlows = function(contractModification=NULL) {
-      do.call(self$tarif$getAbsCashFlows, c(self$params, self$values, list(contractModification=contractModification)));
-    },
-    calculateAbsPresentValues = function(contractModification=NULL) {
-      do.call(self$tarif$getAbsPresentValues, c(self$params, self$values, list(contractModification=contractModification)));
-    },
-    calculateReserves = function(contractModification=NULL) {
-      do.call(self$tarif$reserveCalculation, c(self$params, self$values, list(contractModification=contractModification)));
-    },
-    premiumAnalysis = function(contractModification=NULL) {
-      do.call(self$tarif$premiumDecomposition, c(self$params, self$values, list(contractModification=contractModification)));
-    },
-    getBasicDataTimeseries = function(contractModification=NULL) {
-      do.call(self$tarif$getBasicDataTimeseries, c(self$params, self$values, list(contractModification=contractModification)));
-    },
-
-    # Premium Waiver: Stop all premium payments at time t
-    # the SumInsured is determined from the available
-    premiumWaiver = function (t) {
-      newSumInsured = self$values$reserves[[toString(t), "PremiumFreeSumInsured"]];
-      self$params$premiumWaiver = TRUE;
-      self$params$surrenderPenalty = FALSE; # Surrencer penalty has already been applied, don't apply a second time
-      self$params$alphaRefunded = TRUE;     # Alpha cost (if applicable) have already been refunded partially, don't refund again
-
-      self$params$sumInsured = newSumInsured;
-
-      self$values$cashFlowsBasic = mergeValues(starting=self$values$cashFlowsBasic, ending=self$determineCashFlowsBasic(t), t=t);
-      self$values$cashFlows = mergeValues(starting=self$values$cashFlows, ending=self$determineCashFlows(t), t=t);
-      # Premium sum is not affected by premium waivers, i.e. everything depending on the premium sum uses the original premium sum!
-      # self$values$premiumSum = self$determinePremiumSum();
-      self$values$cashFlowsCosts = mergeValues3D(starting=self$values$cashFlowsCosts, ending=self$determineCashFlowsCosts(t), t=t);
-
-      pv = self$calculatePresentValues(t);
-      pvc = self$calculatePresentValuesCosts(t);
-      self$values$presentValuesCosts = mergeValues3D(starting=self$values$presentValuesCosts, ending=pvc, t=t);
-
-      # TODO:
-      # the premiumCalculation function returns the premiums AND the cofficients,
-      # so we have to extract the coefficients and store them in a separate variable
-      # res = self$calculatePremiums(t);
-      # self$values$premiumCoefficients = mergeValues(starting=self$values$premiumCoefficients, ending=res[["coefficients"]], t=t);
-      # self$values$premiums = mergeValues(starting= = res[["premiums"]]
-
-      # Update the cash flows and present values with the values of the premium
-      pvAllBenefits = self$calculatePresentValuesBenefits()
-      self$values$presentValues = mergeValues(starting=self$values$presentValues, ending=cbind(pv, pvAllBenefits), t=t);
-
-      self$values$absCashFlows = mergeValues(starting=self$values$absCashFlows, ending=self$calculateAbsCashFlows(t), t=t);
-      self$values$absPresentValues = mergeValues(starting=self$values$absPresentValues, ending=self$calculateAbsPresentValues(t), t=t);
-      self$values$reserves = mergeValues(starting=self$values$reserves, ending=self$calculateReserves(t), t=t);
-      self$values$basicData = mergeValues(starting=self$values$basicData, ending=self$getBasicDataTimeseries(t), t=t);
-      self$values$premiumComposition = mergeValues(starting=self$values$premiumComposition, ending=self$premiumAnalysis(t), t=t);
-
-      self$addHistorySnapshot(time=t, comment=sprintf("Premium waiver at time %d", t), type="PremiumWaiver", params=self$params, values=self$values);
-    },
-
-    dummy=NULL
-  )
-);
-# InsuranceContract$debug("premiumWaiver")
diff --git a/R/InsuranceTarif.R b/R/InsuranceTarif.R
deleted file mode 100644
index 72eb8087d99658f0f8543b4eefb178e5ca260d14..0000000000000000000000000000000000000000
--- a/R/InsuranceTarif.R
+++ /dev/null
@@ -1,572 +0,0 @@
-library(R6)
-# library(lifecontingencies)
-library(objectProperties)
-
-TariffTypeEnum = setSingleEnum("TariffType", levels = c("annuity", "wholelife", "endowment", "pureendowment", "terme-fix", "dread-disease"))
-PaymentTimeEnum = setSingleEnum("PaymentTime", levels = c("in advance", "in arrears"))
-#PaymentCountEnum = setSingleEnum(PaymentCount, levels = c(1,2,3))
-
-
-# Initialize a cost matrix with dimensions: [CostType, Basis, Period], with:
-#     CostType: alpha, Zillmer, beta, gamma, gamma_nopremiums
-#     Basis:    SumInsured, SumPremiums, GrossPremium
-#     Period:   once, PremiumPeriod, PremiumFree, PolicyPeriod
-# TODO: gamma an Erlebensleistungen?
-initializeCosts = function() {
-  dimnm=list(
-    c("alpha", "Zillmer", "beta", "gamma", "gamma_nopremiums"),
-    c("SumInsured", "SumPremiums", "GrossPremium"),
-    c("once", "PremiumPeriod", "PremiumFree", "PolicyPeriod")
-  );
-  array(0,
-        dim=sapply(dimnm, length),
-        dimnames=dimnm
-      )
-}
-
-
-# base class for Insurance Tarifs (holding contrat-independent values and
-# providing methods to calculate cash flows, premiums, etc.). Objects of this
-# class do NOT contain contract-specific values like age, death probabilities,
-# premiums, reserves, etc.
-InsuranceTarif = R6Class(
-  "InsuranceTarif",
-  public  = list(
-    name  = "Insurance Contract Type",
-    tarif = "Generic Tarif",
-    desc  = "Description of the contract",
-
-    states = c("alive", "dead"),
-    mortalityTable = NULL,
-    invalidityTable = NULL,
-    i = 0, # guaranteed interest rate
-    v = 1, # discount factor
-    tariffType = TariffTypeEnum("wholelife"), # possible values: annuity, wholelife, endowment, pureendowment, terme-fix
-    premiumFrequencyOrder = 0,
-    benefitFrequencyOrder = 0,
-    widowFactor = 0,
-
-    defaultPremiumPeriod = NULL,
-    premiumRefund = 0,
-    premiumRefundLoading = 0,  # Mindesttodesfallrisiko soll damit erreicht werden, z.B. 105% der einbezahlten Prämien
-    surrenderValueCalculation = NULL, # By default, not surrender penalties
-
-    costs = list(),
-    benefitFrequencyLoading = list("1" = 0.0, "2" = 0.0, "4" = 0.0, "12" = 0.0), # TODO: Properly implement this
-    premiumFrequencyLoading = list("1" = 0.0, "2" = 0.0, "4" = 0.0, "12" = 0.0), # TODO: Implement this
-    loadings = list(    # Loadings can also be function(sumInsured, premiums)    # TODO: Add other possible arguments
-        "ongoingAlphaGrossPremium" = 0,    # Acquisition cost that increase the gross premium
-        "tax" = 0.04,                      # insurance tax, factor on each premium paid
-        "unitcosts" = 0,                   # annual unit cost for each policy (Stückkosten), absolute value
-        "security" = 0,                    # Additional security loading on all benefit payments, factor on all benefits
-        "noMedicalExam" = 0,               # Loading when no medicial exam is done, % of SumInsured
-        "noMedicalExamRelative" = 0,       # Loading when no medicial exam is done, % of gross premium
-        "sumRebate" = 0,                   # gross premium reduction for large premiums, % of SumInsured
-        "premiumRebate" = 0,               # gross premium reduction for large premiums, % of gross premium # TODO
-        "advanceProfitParticipation" = 0,                # Vorweggewinnbeteiligung (%-Satz der Bruttoprämie)
-        "advanceProfitParticipationInclUnitCost" = 0,    # Vorweggewinnbeteiligung (%-Satz der Prämie mit Zu-/Abschlägen, insbesondere nach Stückkosten)
-        "partnerRebate" = 0                # Partnerrabatt auf Prämie mit Zu-/Abschlägen, wenn mehr als 1 Vertrag gleichzeitig abgeschlossen wird, additiv mit advanceBonusInclUnitCost and premiumRebate
-      ),
-
-    features = list(  #Special cases for the calculations
-        "betaGammaInZillmer" = FALSE,      # Whether beta and gamma-costs should be included in the Zillmer premium calculation
-        "alphaRefundLinear" = TRUE         # Whether the refund of alpha-costs on surrender is linear in t or follows the NPV of an annuity
-      ),
-
-
-    initialize = function(name = NULL, mortalityTable = NULL, i = NULL, type = "wholelife", ..., loadings=list(), invalidityTable=NULL, features = list(), premiumPeriod = NULL, premiumFrequencyOrder = 0, benefitFrequencyOrder = 0, costs, surrenderValueCalculation) {
-      if (!missing(name))           self$name = name;
-      if (!missing(mortalityTable)) self$mortalityTable = mortalityTable;
-      if (!missing(i))              self$i = i;
-      if (!missing(type))           self$tariffType = type;
-      self$costs = if (!missing(costs)) costs else initializeCosts();
-      if (!missing(benefitFrequencyOrder)) self$benefitFrequencyOrder = benefitFrequencyOrder;
-      if (!missing(premiumFrequencyOrder)) self$premiumFrequencyOrder = premiumFrequencyOrder;
-      # Set default premiumPeriod, e.g. single premium, to be used when the contract has no explicit premium period
-      if (!missing(premiumPeriod))  self$defaultPremiumPeriod = premiumPeriod;
-      if (!missing(features))       self$features = c(features, self$features);
-      if (!missing(surrenderValueCalculation)) self$surrenderValueCalculation = surrenderValueCalculation;
-      if (!missing(invalidityTable)) self$invalidityTable = invalidityTable;
-      if (!missing(loadings))       self$loadings = self$getLoadings(loadings=loadings);
-
-      self$v = 1/(1+self$i);
-
-      cat(paste0("Initializing Insurance Tarif ", self$name, "...\n"));
-    },
-
-    # Merge a possibly passed loadings override with this tariff's default loadings:
-    getLoadings = function(loadings=list(), ...) {
-      c(loadings, self$loadings)
-    },
-
-    getAges = function(age, ..., YOB = 2000) {
-      ages = ages(self$mortalityTable, YOB = YOB);
-      if (age > 0) {
-        ages = ages[-age:-1];
-      }
-      ages
-    },
-
-    getTransitionProbabilities = function(age, ..., YOB = 2000) {
-      ages = self$getAges(age, YOB = YOB);
-      q = deathProbabilities(self$mortalityTable, YOB = YOB);
-      if (age > 0) {
-        q    = q[-age:-1];
-      }
-      if (!is.null(self$invalidityTable)) {
-        i = deathProbabilities(self$invalidityTable, YOB=YOB);
-        if (age > 0) {
-          i    = i[-age:-1];
-        }
-      } else {
-        i = rep(0, length(q));
-      }
-      i = pad0(i, length(q));
-      df = data.frame(age=ages, q=q, i=i, p=1-q-i, row.names = ages-age)
-      df
-    },
-    getBasicCashFlows = function(age, ..., guaranteed = 0, policyPeriod = inf, deferral = 0, maxAge = getOmega(self$mortalityTable)) {
-      maxlen = min(maxAge - age, policyPeriod);
-      cf = data.frame(
-        guaranteed = rep(0, maxlen+1),
-        survival = rep(0, maxlen+1),
-        death = rep(0, maxlen+1),
-        disease = rep(0, maxlen+1)
-      );
-      if (self$tariffType == "annuity") {
-        # guaranteed payments exist only with annuities (first n years of the payment)
-        cf$guaranteed = c(rep(0, deferral), rep(1, guaranteed), rep(0, max(0, maxlen+1 - deferral - guaranteed)))
-        cf$survival = c(rep(0, deferral + guaranteed), rep(1, max(0, maxlen - deferral - guaranteed)), 0)
-      } else if (self$tariffType == "terme-fix") {
-        cf$guaranteed = c(rep(0, policyPeriod), 1);
-      } else if (self$tariffType == "dread-disease") {
-        cf$disease = c(rep(0, deferral), rep(1, maxlen - deferral), 0);
-      } else {
-        if (self$tariffType == "endowment" || self$tariffType == "pureendowment") {
-          cf$survival = c(rep(0, policyPeriod), 1);
-        }
-        if (self$tariffType == "endowment" || self$tariffType == "wholelife") {
-          cf$death = c(rep(0, deferral), rep(1, maxlen - deferral), 0);
-        }
-      }
-      cf
-    },
-
-    getCashFlows = function(age, ..., premiumPayments = "in advance", benefitPayments = "in advance", guaranteed = 0, policyPeriod=Inf, premiumPeriod = policyPeriod, deferral=0, maxAge = getOmega(self$mortalityTable), cashFlowsBasic = NULL, premiumWaiver = FALSE) {
-      if (missing(cashFlowsBasic)) {
-        cashFlowsBasic = self$getBasicCashFlows(age = age, ..., guaranteed = guaranteed,
-              policyPeriod = policyPeriod, deferral = deferral, maxAge = maxAge);
-      }
-      cflen = length(cashFlowsBasic$survival);
-      zeroes = pad0(0, cflen);
-      ages = pad0(self$getAges(age, YOB = YOB), cflen);
-      cf = data.frame(
-        premiums_advance = zeroes,
-        premiums_arrears = zeroes,
-        guaranteed_advance = zeroes,
-        guaranteed_arrears = zeroes,
-        survival_advance = zeroes,
-        survival_arrears = zeroes,
-        death_SumInsured = zeroes,
-        disease_SumInsured = zeroes,
-        death_GrossPremium = zeroes,
-        death_Refund_past = zeroes,
-        death_PremiumFree = zeroes,
-        row.names = ages-age
-      );
-
-      # Premiums:
-      if (!premiumWaiver) {
-        premiums = pad0(rep(1, min(premiumPeriod, policyPeriod)), cflen);
-        if (premiumPayments == "in advance") {
-          cf$premiums_advance = premiums;
-        } else {
-          cf$premiums_arrears = premiums;
-        }
-      }
-
-      # Survival Benefits
-      if (benefitPayments == "in advance") {
-        cf$guaranteed_advance = pad0(cashFlowsBasic$guaranteed, cflen);
-        cf$survival_advance = pad0(cashFlowsBasic$survival, cflen);
-      } else {
-        cf$guaranteed_arrears = pad0(cashFlowsBasic$guaranteed, cflen);
-        cf$survival_arrears = pad0(cashFlowsBasic$survival, cflen);
-      }
-
-      # Death Benefits
-      cf$death_SumInsured = pad0(cashFlowsBasic$death, cflen);
-      cf$disease_SumInsured = pad0(cashFlowsBasic$disease, cflen);
-      cf$death_PremiumFree = cf$death_SumInsured;
-      # premium refund
-      if (self$premiumRefund != 0) {
-        totalpremiumcf = cf$premiums_advance + pad0(c(0, cf$premiums_arrears), cflen);
-
-        # death benefit for premium refund is the sum of all premiums so far:
-        cf$death_GrossPremium = pad0(Reduce("+", totalpremiumcf[0:policyPeriod], accumulate=TRUE), cflen)
-        cf$death_Refund_past = cf$death_GrossPremium
-        cf$death_Refund_past[(cf$death_GrossPremium >0)] = 1;
-      }
-
-      cf
-    },
-
-    getCashFlowsCosts = function(age, ..., policyPeriod=Inf, premiumPeriod = policyPeriod, premiumWaiver = FALSE, maxAge = getOmega(self$mortalityTable)) {
-      maxlen = min(maxAge - age, policyPeriod)+1;
-      policyPeriod = min(maxAge - age, policyPeriod);
-      premiumPeriod = min(policyPeriod, premiumPeriod);
-
-      dm = dim(self$costs);
-      dmnames = dimnames(self$costs);
-      cf = array(0, dim=list(maxlen, dm[1], dm[2]), dimnames=list(0:(maxlen-1), dmnames[[1]], dmnames[[2]]));
-      cf[1,,] = cf[1,,] + self$costs[,,"once"]
-      for (i in 1:premiumPeriod) {
-        cf[i,,] = cf[i,,] + self$costs[,,"PremiumPeriod"];
-      }
-      if (premiumPeriod<policyPeriod) {
-        for (i in (premiumPeriod+1):policyPeriod) {
-          cf[i,,] = cf[i,,] + self$costs[,,"PremiumFree"];
-        }
-      }
-      for (i in 1:policyPeriod) {
-        cf[i,,] = cf[i,,] + self$costs[,,"PolicyPeriod"];
-      }
-
-      # After premiums are waived, use the gamma_nopremiums instead of gamma:
-      if (premiumWaiver) {
-        cf[,"gamma",] = cf[,"gamma_nopremiums",];
-      }
-      cf
-    },
-
-    presentValueCashFlows = function(cashFlows, age, ..., premiumFrequency = 1, benefitFrequency = 1, maxAge = getOmega(self$mortalityTable)) {
-      len = length(cashFlows$premiums_advance);
-      qq = self$getTransitionProbabilities (age, ...);
-      qx = pad0(qq$q, len);
-      ix = pad0(qq$i, len);
-      px = pad0(qq$p, len);
-      benefitFrequencyCorrection = correctionPaymentFrequency(m = benefitFrequency, i = self$i, order = self$benefitFrequencyOrder);
-      premiumFrequencyCorrection = correctionPaymentFrequency(m = premiumFrequency, i = self$i, order = self$premiumFrequencyOrder);
-
-      pvRefund = calculatePVDeath (px, qx, cashFlows$death_GrossPremium, v=self$v);
-      pvRefundPast = calculatePVDeath (px, qx, cashFlows$death_Refund_past, v=self$v) * (cashFlows[,"death_GrossPremium"]-cashFlows[,"premiums_advance"]);
-
-      pv = cbind(
-        premiums = calculatePVSurvival (px, qx, cashFlows$premiums_advance, cashFlows$premiums_arrears, m=premiumFrequency, mCorrection=premiumFrequencyCorrection, v=self$v),
-        guaranteed = calculatePVGuaranteed (cashFlows$guaranteed_advance, cashFlows$guaranteed_arrears, m=benefitFrequency, mCorrection=benefitFrequencyCorrection, v=self$v),
-        survival = calculatePVSurvival (px, qx, cashFlows$survival_advance, cashFlows$survival_arrears, m=benefitFrequency, mCorrection=benefitFrequencyCorrection, v=self$v),
-        death_SumInsured = calculatePVDeath (px, qx, cashFlows$death_SumInsured, v=self$v),
-        disease_SumInsured = calculatePVDisease(px, qx, ix, cashFlows$disease_SumInsured, v=self$v),
-        death_GrossPremium = pvRefund,
-        death_Refund_past = pvRefundPast,
-        death_Refund_future = pvRefund - pvRefundPast,
-        death_PremiumFree = calculatePVDeath (px, qx, cashFlows$death_PremiumFree, v=self$v)
-      );
-
-      rownames(pv) <- pad0(rownames(qq), len);
-      pv
-    },
-
-    presentValueCashFlowsCosts = function(cashFlowsCosts, age, ..., maxAge = getOmega(self$mortalityTable)) {
-      len = dim(cashFlowsCosts)[1];
-      q = self$getTransitionProbabilities (age, ...);
-      qx = pad0(q$q, len);
-      px = pad0(q$p, len);
-
-      pvc = calculatePVCosts(px, qx, cashFlowsCosts, v=self$v);
-      pvc
-    },
-
-    # Cost values (CF, present values, etc.) are an Tx5x3 matrix => convert to Tx15 matrix (alpha | Zillmer | beta | gamma)
-    costValuesAsMatrix = function (costValues) {
-      dm = dim(costValues);
-      nm = dimnames(costValues);
-      colnames=t(outer(nm[[2]], nm[[3]], paste, sep="."));
-
-      res = aperm(costValues, c(1,3,2));
-      dim(res) = c(dm[[1]], dm[[2]]*dm[[3]]);
-      dimnames(res) = list(nm[[1]], colnames)
-      res
-    },
-
-    getAbsCashFlows = function(cashFlows, cashFlowsCosts, premiums, sumInsured=1, premiumSum=0, ...) {
-      refundAddon = self$premiumRefundLoading;
-
-      # TODO: Set up a nice list with coefficients for each type of cashflow, rather than multiplying each item manually (this also mitigates the risk of forgetting a dimension, because then the dimensions would not match, while here it's easy to overlook a multiplication)
-      # Multiply each CF column by the corresponding basis
-      cashFlows[,c("premiums_advance", "premiums_arrears")] = cashFlows[,c("premiums_advance", "premiums_arrears")] * premiums[["gross"]];
-      cashFlows[,c("guaranteed_advance", "guaranteed_arrears", "survival_advance", "survival_arrears", "death_SumInsured", "death_PremiumFree", "disease_SumInsured")] =
-        cashFlows[,c("guaranteed_advance", "guaranteed_arrears", "survival_advance", "survival_arrears", "death_SumInsured", "death_PremiumFree", "disease_SumInsured")] * sumInsured;
-      cashFlows[,c("death_GrossPremium", "death_Refund_past")] = cashFlows[,c("death_GrossPremium","death_Refund_past")] * premiums[["gross"]] * (1+refundAddon);
-
-      # Sum all death-related payments to "death"  and remove the death_GrossPremium column
-      cashFlows[,"death_SumInsured"] = cashFlows[,"death_SumInsured"] + cashFlows[,"death_GrossPremium"]
-      colnames(cashFlows)[colnames(cashFlows)=="death_SumInsured"] = "death";
-      # cashFlows[,"death_GrossPremium"] = NULL;
-
-      cashFlowsCosts = cashFlowsCosts[,,"SumInsured"] * sumInsured +
-        cashFlowsCosts[,,"SumPremiums"] * premiumSum * premiums[["gross"]] +
-        cashFlowsCosts[,,"GrossPremium"] * premiums[["gross"]];
-
-      cbind(cashFlows, cashFlowsCosts)
-    },
-
-    getAbsPresentValues = function(presentValues, premiums, sumInsured=1, premiumSum=0, ...) {
-      refundAddon = self$premiumRefundLoading;
-      pv = presentValues;
-
-      #pv[,"age"] = pv[,"premiums"];
-      #colnames(pv)[colnames(pv)=="age"] = "premiums.unit";
-
-      # Multiply each CF column by the corresponding basis
-      pv[,"premiums"] = pv[,"premiums"] * premiums[["gross"]];
-      pv[,c("guaranteed", "survival", "death_SumInsured", "disease_SumInsured", "death_PremiumFree")] =
-        pv[,c("guaranteed", "survival", "death_SumInsured", "disease_SumInsured", "death_PremiumFree")] * sumInsured;
-      pv[,c("death_GrossPremium", "death_Refund_past", "death_Refund_future")] = pv[,c("death_GrossPremium", "death_Refund_past", "death_Refund_future")] * premiums[["gross"]] * (1+refundAddon);
-      pv[,c("benefits", "benefitsAndRefund", "alpha", "Zillmer", "beta", "gamma", "gamma_nopremiums")] =
-        pv[,c("benefits", "benefitsAndRefund", "alpha", "Zillmer", "beta", "gamma", "gamma_nopremiums")] * sumInsured;
-
-      # Sum all death-related payments to "death"  and remove the death_SumInsured column
-      pv[,"death_SumInsured"] = pv[,"death_SumInsured"] + pv[,"death_GrossPremium"]
-      colnames(pv)[colnames(pv)=="death_SumInsured"] = "death";
-
-      cbind("premiums.unit"=presentValues[,"premiums"], pv)
-    },
-
-
-    presentValueBenefits = function(presentValues, presentValuesCosts, premiums, sumInsured=1, premiumSum=0, ...) {
-      refundAddon = self$premiumRefundLoading;
-      # TODO: Here we don't use the securityLoading parameter => Shall it be used or are these values to be understood without additional security loading?
-      benefits    = presentValues[,"survival"] + presentValues[,"death_SumInsured"] + presentValues[,"disease_SumInsured"];
-      allBenefits = presentValues[,"survival"] + presentValues[,"death_SumInsured"] + presentValues[,"disease_SumInsured"] + presentValues[,"death_GrossPremium"] * premiums[["unit.gross"]] * (1+refundAddon);
-
-      benefitsCosts = presentValuesCosts[,,"SumInsured"] +
-        presentValuesCosts[,,"SumPremiums"] * premiumSum * premiums[["unit.gross"]] +
-        presentValuesCosts[,,"GrossPremium"] * premiums[["unit.gross"]];
-
-      cbind(
-        benefits=benefits,
-        benefitsAndRefund=allBenefits,
-        benefitsCosts)
-    },
-
-    getPremiumCoefficients = function(type="gross", coeffBenefits, coeffCosts, ...,
-                                      premiumSum = 0,premiums = c("unit.gross"=0), loadings=list()) {
-      # Merge a possibly passed loadings override with the defaults of this class:
-      loadings = self$getLoadings(loadings=loadings);
-      securityLoading = loadings$security;
-      refundAddon = self$premiumRefundLoading;
-
-      coeff = list(
-        "SumInsured" = list("benefits" = coeffBenefits*0, "costs" = coeffCosts*0),
-        "Premium"    = list("benefits" = coeffBenefits*0, "costs" = coeffCosts*0)
-      );
-
-      coeff[["Premium"]][["benefits"]][["premiums"]]            = 1;
-
-      coeff[["SumInsured"]][["benefits"]][["guaranteed"]]       = 1+securityLoading;
-      coeff[["SumInsured"]][["benefits"]][["survival"]]         = 1+securityLoading;
-      coeff[["SumInsured"]][["benefits"]][["death_SumInsured"]] = 1+securityLoading;
-      coeff[["SumInsured"]][["benefits"]][["disease_SumInsured"]] = 1+securityLoading;
-
-      # Premium refund is handled differently for gross and net premiums, because it is proportional to the gross premium
-      if (type == "gross") {
-        coeff[["Premium"]][["benefits"]][["death_GrossPremium"]] = -(1+refundAddon) * (1+securityLoading);
-      } else if (type=="net" || type=="Zillmer") {
-        coeff[["SumInsured"]][["benefits"]][["death_GrossPremium"]] = premiums[["unit.gross"]] * (1+refundAddon) * (1+securityLoading);
-      }
-
-
-      # coefficients for the costs
-
-      if (type=="gross") {
-        coeff[["SumInsured"]][["costs"]]["alpha", "SumInsured"] = 1;
-        coeff[["SumInsured"]][["costs"]]["beta",  "SumInsured"] = 1;
-        coeff[["SumInsured"]][["costs"]]["gamma", "SumInsured"] = 1;
-        # TODO: How to handle beta costs proportional to Sum Insured
-        coeff[["Premium"]][["costs"]]["alpha", "SumPremiums"] = -premiumSum;
-        coeff[["Premium"]][["costs"]]["beta",  "SumPremiums"] = -premiumSum;
-        coeff[["Premium"]][["costs"]]["gamma", "SumPremiums"] = -premiumSum;
-
-        coeff[["Premium"]][["costs"]]["alpha", "GrossPremium"] = -1;
-        coeff[["Premium"]][["costs"]]["beta",  "GrossPremium"] = -1;
-        coeff[["Premium"]][["costs"]]["gamma", "GrossPremium"] = -1;
-
-      } else if (type=="Zillmer") {
-        coeff[["SumInsured"]][["costs"]]["Zillmer","SumInsured"] = 1;
-        coeff[["SumInsured"]][["costs"]]["Zillmer","SumPremiums"] = premiumSum * premiums[["unit.gross"]];
-        coeff[["SumInsured"]][["costs"]]["Zillmer","GrossPremium"] = premiums[["unit.gross"]];
-        if (self$features$betaGammaInZillmer) {
-          coeff[["SumInsured"]][["costs"]]["beta",  "SumInsured"] = 1;
-          coeff[["SumInsured"]][["costs"]]["gamma", "SumInsured"] = 1;
-          coeff[["SumInsured"]][["costs"]]["beta",  "SumPremiums"] = premiumSum * premiums[["unit.gross"]];
-          coeff[["SumInsured"]][["costs"]]["gamma", "SumPremiums"] = premiumSum * premiums[["unit.gross"]];
-          coeff[["SumInsured"]][["costs"]]["beta",  "GrossPremium"] = premiums[["unit.gross"]];
-          coeff[["SumInsured"]][["costs"]]["gamma", "GrossPremium"] = premiums[["unit.gross"]];
-        }
-      }
-
-      coeff
-    },
-
-    premiumCalculation = function(presentValues, presentValuesCosts, costs=self$costs, premiumSum=0, sumInsured=1, premiumFrequency = 1, loadings=list(), ...) {
-      # Merge a possibly passed loadings override with the defaults of this class:
-      loadings = self$getLoadings(loadings=loadings);
-      premiums = c("unit.net" = 0, "unit.Zillmer" = 0, "unit.gross"= 0, "net" = 0, "Zillmer" = 0, "gross" = 0, "written" = 0);
-      coefficients = list("gross"=c(), "Zillmer"=c(), "net"=c());
-
-      # net, gross and Zillmer premiums are calculated from the present values using the coefficients on each present value as described in the formulas document
-      coeff=self$getPremiumCoefficients("gross", presentValues["0",]*0, presentValuesCosts["0",,]*0, premiums=premiums, premiumSum=premiumSum, loadings=loadings)
-      enumerator  = sum(coeff[["SumInsured"]][["benefits"]] * presentValues["0",]) + sum(coeff[["SumInsured"]][["costs"]] * presentValuesCosts["0",,]);
-      denominator = sum(coeff[["Premium"   ]][["benefits"]] * presentValues["0",]) + sum(coeff[["Premium"   ]][["costs"]] * presentValuesCosts["0",,]);
-      ongoingAlphaGrossPremium = loadings$ongoingAlphaGrossPremium;
-      premiums[["unit.gross"]] = enumerator/denominator * (1 + ongoingAlphaGrossPremium);
-      premiums[["gross"]] = premiums[["unit.gross"]] * sumInsured;
-      coefficients[["gross"]] = coeff;
-
-      coeff=self$getPremiumCoefficients("net", presentValues["0",]*0, presentValuesCosts["0",,]*0, premiums=premiums, premiumSum=premiumSum)
-      enumerator  = sum(coeff[["SumInsured"]][["benefits"]] * presentValues["0",]) + sum(coeff[["SumInsured"]][["costs"]] * presentValuesCosts["0",,]);
-      denominator = sum(coeff[["Premium"   ]][["benefits"]] * presentValues["0",]) + sum(coeff[["Premium"   ]][["costs"]] * presentValuesCosts["0",,]);
-      premiums[["unit.net"]] = enumerator/denominator; premiums
-      premiums[["net"]] = premiums[["unit.net"]] * sumInsured;
-      coefficients[["net"]] = coeff;
-
-      coeff=self$getPremiumCoefficients("Zillmer", presentValues["0",]*0, presentValuesCosts["0",,]*0, premiums=premiums, premiumSum=premiumSum)
-      enumerator  = sum(coeff[["SumInsured"]][["benefits"]] * presentValues["0",]) + sum(coeff[["SumInsured"]][["costs"]] * presentValuesCosts["0",,]);
-      denominator = sum(coeff[["Premium"   ]][["benefits"]] * presentValues["0",]) + sum(coeff[["Premium"   ]][["costs"]] * presentValuesCosts["0",,]);
-      premiums[["unit.Zillmer"]] = enumerator/denominator;
-      premiums[["Zillmer"]] = premiums[["unit.Zillmer"]] * sumInsured;
-      coefficients[["Zillmer"]] = coeff;
-
-
-      # The written premium is the gross premium with additional loadings, rebates, unit costs and taxes
-      tax           = valueOrFunction(loadings$tax,          sumInsured=sumInsured, premiums=premiums);
-      unitCosts     = valueOrFunction(loadings$unitcosts,    sumInsured=sumInsured, premiums=premiums);
-      noMedicalExam = valueOrFunction(loadings$noMedicalExam,sumInsured=sumInsured, premiums=premiums);
-      noMedicalExam.relative = valueOrFunction(loadings$noMedicalExamRelative,sumInsured=sumInsured, premiums=premiums);
-      sumRebate     = valueOrFunction(loadings$sumRebate,    sumInsured=sumInsured, premiums=premiums);
-      premiumRebate = valueOrFunction(loadings$premiumRebate,sumInsured=sumInsured, premiums=premiums);
-      advanceProfitParticipation = valueOrFunction(loadings$advanceProfitParticipation,sumInsured=sumInsured, premiums=premiums);
-      advanceProfitParticipationUnitCosts = valueOrFunction(loadings$advanceProfitParticipationInclUnitCost, sumInsured=sumInsured, premiums=premiums);
-      partnerRebate = valueOrFunction(loadings$partnerRebate,sumInsured=sumInsured, premiums=premiums);
-
-      frequencyLoading = valueOrFunction(self$premiumFrequencyLoading, sumInsured=sumInsured, premiums=premiums);
-
-      premiumBeforeTax = (premiums[["unit.gross"]]*(1+noMedicalExam.relative) + noMedicalExam - sumRebate)*sumInsured * (1-advanceProfitParticipation) + unitCosts;
-      premiumBeforeTax = premiumBeforeTax * (1-premiumRebate-advanceProfitParticipationUnitCosts-partnerRebate);
-      premiumBeforeTax = premiumBeforeTax * (1+frequencyLoading[[toString(premiumFrequency)]]) / premiumFrequency;
-      premiums[["written_beforetax"]] = premiumBeforeTax;
-      premiums[["tax"]] = premiumBeforeTax * tax;
-      premiums[["written"]] = premiumBeforeTax * (1 + tax);
-
-      list("premiums"=premiums, "coefficients"=coefficients)
-    },
-
-    reserveCalculation = function (premiums, absPresentValues, absCashFlows, sumInsured=1, premiumSum=0, policyPeriod = 1, age = 0, ..., reserves = c(), loadings=list(), surrenderPenalty = TRUE) {
-      # Merge a possibly passed loadings override with the defaults of this class:
-      loadings = self$getLoadings(loadings=loadings);
-      # Net, Zillmer and Gross reserves
-      resNet = absPresentValues[,"benefitsAndRefund"] * (1+loadings$security) - premiums[["net"]] * absPresentValues[,"premiums.unit"];
-      BWZcorr = absPresentValues["0", "Zillmer"] / absPresentValues["0", "premiums"] * absPresentValues[,"premiums"];
-      resZ = resNet - BWZcorr;
-
-      resAdeq = absPresentValues[,"benefitsAndRefund"] * (1+loadings$security) +
-        absPresentValues[,"alpha"] + absPresentValues[,"beta"] + absPresentValues["gamma"] -
-        premiums[["gross"]] * absPresentValues[,"premiums.unit"];
-
-      #premiums[["Zillmer"]] * absPresentValues[,"premiums"];
-      resGamma = absPresentValues[,"gamma"] - absPresentValues["0", "gamma"] / absPresentValues["0", "premiums"] * absPresentValues[,"premiums"]
-
-
-      resConversion = (resZ + resGamma) * (1-loadings$advanceProfitParticipation);
-
-      # Alpha refund: Distribute alpha-costs to 5 year (or if shorter, the policy period):
-      r = min(policyPeriod, 5);
-      ZillmerSoFar = Reduce("+", absCashFlows$Zillmer, accumulate = TRUE);
-      ZillmerTotal = sum(absCashFlows$Zillmer);
-      len = length(ZillmerSoFar);
-      if (self$features$alphaRefundLinear) {
-        ZillmerVerteilungCoeff = pad0((0:r)/r, len, 1);
-      } else {
-        q = self$getTransitionProbabilities (age, ...);
-        # vector of all ä_{x+t, r-t}
-        pvAlphaTmp = calculatePVSurvival(q = pad0(q$q, len), advance = pad0(rep(1,r), len), v = self$v);
-        ZillmerVerteilungCoeff = (1-pvAlphaTmp/pvAlphaTmp[[1]]);
-      }
-      alphaRefund = ZillmerSoFar - ZillmerVerteilungCoeff * ZillmerTotal;
-
-      # Reduction Reserve: Reserve used for contract modifications:
-      resReduction = pmax(0, resZ+resGamma+alphaRefund) # V_{x,n}^{Rkf}
-
-      # Collect all reserved to one large matrix
-      res = cbind("net"=resNet, "Zillmer"=resZ, "adequate"= resAdeq, "gamma"=resGamma,
-                  "contractual"=resZ+resGamma, "conversion"=resConversion, "alphaRefund"=alphaRefund, "reduction"=resReduction
-                  #, "Reserve.premiumfree"=res.premiumfree, "Reserve.gamma.premiumfree"=res.gamma.premiumfree);
-      );
-      rownames(res) <- rownames(absPresentValues);
-
-      # The surrender value functions can have arbitrary form, so we store a function
-      # here in the tarif and call that, passing the reduction reserve as
-      # starting point, but also all reserves, cash flows, premiums and present values
-      if (!surrenderPenalty) {
-        # No surrender penalty any more (has already been applied to the first contract change!)
-        surrenderValue = resReduction;
-      } else if (!is.null(self$surrenderValueCalculation)) {
-        surrenderValue = self$surrenderValueCalculation(
-          resReduction, reserves=res, premiums=premiums, absPresentValues=absPresentValues,
-          absCashFlows=absCashFlows, sumInsured=sumInsured, premiumSum=premiumSum,
-          policyPeriod = policyPeriod, age = age, loadings=loadings, ...);
-      } else {
-        # by default, refund the full reduction reserve, except the advance profit participation, which is also included in the reserve, but not charged on the premium!
-        surrenderValue = resReduction * (1-loadings$advanceProfitParticipationInclUnitCost);
-      }
-
-
-      # Calculate new sum insured after premium waiver
-      Storno = 0; # TODO: Implement storno costs
-      newSI = (surrenderValue - absPresentValues[,"death_Refund_past"] * (1+loadings$security) - c(Storno)) /
-        (absPresentValues[, "benefits"] * (1+loadings$security) + absPresentValues[, "gamma_nopremiums"]) * sumInsured;
-
-      cbind(res,
-            "PremiumsPaid"=Reduce("+", absCashFlows$premiums_advance, accumulate = TRUE),
-            "Surrender"=surrenderValue,
-            "PremiumFreeSumInsured" = newSI
-      )
-    },
-
-    getBasicDataTimeseries = function(premiums, reserves, absCashFlows, absPresentValues, sumInsured=1, policyPeriod, premiumPeriod, ...) {
-      res=cbind(
-        "PremiumPayment" = c(rep(1, premiumPeriod), rep(0, policyPeriod-premiumPeriod+1)),
-        "SumInsured" = c(rep(sumInsured, policyPeriod), 0),
-        "Premiums" = absCashFlows$premiums_advance + absCashFlows$premiums_arrears,
-        "InterestRate" = rep(self$i, policyPeriod+1),
-        "PolicyDuration" = rep(policyPeriod, policyPeriod+1),
-        "PremiumPeriod" = rep(premiumPeriod, policyPeriod+1)
-      );
-      rownames(res) = 0:policyPeriod;
-      res
-    },
-
-    premiumDecomposition = function(premiums, reserves, absCashFlows, absPresentValues, transitionProbabilities, sumInsured=1, ...) {
-      l = dim(reserves)[[1]];
-      premium.savings = getSavingsPremium(reserves[,"Zillmer"], self$v) + getSavingsPremium(reserves[,"gamma"], self$v);
-      # TODO: Switch to use the Ziller or net or adequate reserve!
-      premium.risk    = self$v * (absCashFlows[,"death"] - c(reserves[,"Zillmer"][-1], 0)) * pad0(transitionProbabilities$q, l) +
-        self$v * (absCashFlows[,"disease_SumInsured"] - c(reserves[,"Zillmer"][-1], 0)) * pad0(transitionProbabilities$i, l);
-      # premium.risk    = self$v * (absCashFlows[,"death"] - c(reserves[,"Zillmer"][-1], 0)) * transitionProbabilities$q;
-
-
-      res = cbind("savings"=premium.savings, "risk"=premium.risk, "savings+risk"= premium.savings+premium.risk, "gamma"=absCashFlows[,"gamma"]);
-      rownames(res) <- rownames(premiums);
-      res
-    },
-
-
-
-
-
-
-    # Dummy to allow commas
-    dummy = 0
-  )
-);
diff --git a/R/S4classes.R b/R/S4classes.R
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/R/ValuationTables.R b/R/ValuationTables.R
index c1fae8c81fe2d380d785668ee8c23642614feb98..d3b2afd82dabc517c87391938b1ceef3f400c9f5 100644
--- a/R/ValuationTables.R
+++ b/R/ValuationTables.R
@@ -1,7 +1,30 @@
-library("lifecontingencies");
-library(ggplot2);
-
-# (virtual) base class for valuation tables, contains only the name / ID
+#' Provide life table classes for life insurance purposes
+#'
+#' @import openxlsx
+#' @import methods
+#' @import ggplot2
+#'
+"_PACKAGE"
+
+
+#' Class valuationTable
+#'
+#' Class \code{valuationTable} is the (virtual) base class for all valuation
+#' tables. It contains the name and some general values applying to all
+#' types of tables, but does not contain any data itself. Use a child class
+#' to create actual valuation tables.
+#'
+#' @slot name     The human-readable name of the valuation table
+#' @slot baseYear The base year of the valuation table (e.g. for tables with trend projection)
+#' @slot modification A function that will be called with the final death probabilities
+#'        to give the user a way to modify the final probabilities
+#' @slot loading  Additional security loading on the resulting table (single numeric
+#'        value, e.g. 0.05 adds 5% security margin to the probabilities)
+#'
+#' @name valuationTable-class
+#' @rdname valuationTable-class
+#' @export valuationTable
+#' @exportClass valuationTable
 valuationTable=setClass(
   "valuationTable",
   slots=list(name="character", baseYear="numeric", loading="numeric", modification="function"),
@@ -10,67 +33,117 @@ valuationTable=setClass(
 );
 
 
-# A period life table, giving death probabilities for each age, up to
-# maximum age omega. Optionally apply selection factors to the probabilities
-valuationTable.period=setClass(
-  "valuationTable.period",
+#' A period life table, giving death probabilities for each age, up to
+#' maximum age omega. Optionally apply selection factors to the probabilities
+#'
+#' @slot ages       The ages corresponding to the entries of the deathProbs
+#' @slot deathProbs The one-year death probabilities for the ages
+#'
+#' @export valuationTable_period
+#' @exportClass valuationTable_period
+valuationTable_period=setClass(
+  "valuationTable_period",
   slots=list(ages="numeric", deathProbs="numeric"),
   prototype=list(ages=eval(0:120), deathProbs=rep(1,120)),
   contains="valuationTable"
 );
 
-# A cohort life table, obtained by age-shifting from a given base table (PODs
-# for a base YOB)
-valuationTable.ageShift=setClass(
-  "valuationTable.ageShift",
+
+#' A cohort life table, obtained by age-shifting from a given base table (death probabilities
+# for a base birth year)
+#'
+#' @slot ageShifts  A \code{data.frame} with columns \code{YOB} and \code{shifts} giving the age shifts for each birth year
+#'
+#' @export valuationTable_ageShift
+#' @exportClass valuationTable_ageShift
+valuationTable_ageShift=setClass(
+  "valuationTable_ageShift",
   slots=list(ageShifts="data.frame"),
   prototype=list(ageShifts=data.frame(YOB=c(), shifts=c())),
-  contains="valuationTable.period"
+  contains="valuationTable_period"
 );
 
-# A cohort life table, obtained by a trend projection from a given base table
-# (PODs for a given observation year). Typically, the trend is obtained by
-# the Lee-Carter method or some other trend estimation.
-# The dampingFunction can be used to modify the cumulative years (e.g. G(tau+x) instead of tau+x)
-# If trend2 is given, the G(tau+x) gives the weight of the first trend, 1-G(tau+x) the weight of the second trend
-valuationTable.trendProjection=setClass(
-  "valuationTable.trendProjection",
+#' A cohort life table, obtained by a trend projection from a given base table
+#' (PODs for a given observation year). Typically, the trend is obtained by
+#' the Lee-Carter method or some other trend estimation.
+#' The dampingFunction can be used to modify the cumulative years (e.g. G(tau+x) instead of tau+x)
+#' If trend2 is given, the G(tau+x) gives the weight of the first trend, 1-G(tau+x) the weight of the second trend
+#'
+#' @slot baseYear The base year of the trend projection (\code{baseTable} describes the death probabilities in this year)
+#' @slot trend    The yearly improvements of the log-death probabilities (per age)
+#' @slot dampingFunction A possible damping of the trend. This is a function \code{damping(delta_years)} that gets a vector of years from the baseYear and should return the dampened values.
+#' @slot trend2   The alternate trend. If given, the damping function interpolates between \code{trend} and \code{trend2}, otherwise the dumping function simply modifies the coefficients of \code{trend}.
+#'
+#' @export valuationTable_ageShift
+#' @exportClass valuationTable_ageShift
+valuationTable_trendProjection=setClass(
+  "valuationTable_trendProjection",
   slots=list(baseYear="numeric", trend="numeric", dampingFunction="function", trend2="numeric"),
   prototype=list(baseYear=1980, trend=rep(0,120), dampingFunction=identity, trend2=0),
-  contains="valuationTable.period"
+  contains="valuationTable_period"
 );
 
-# A cohort life table, obtained by an improvment factor projection
-# from a given base table (PODs for a given observation year).
-valuationTable.improvementFactors=setClass(
-  "valuationTable.improvementFactors",
+#' A cohort life table, obtained by an improvment factor projection
+#' from a given base table (PODs for a given observation year).
+#'
+#' @slot baseYear    The base year for the improvements (\code{baseTable} describes the death probabilities in this year)
+#' @slot improvement Yearly improvement factors per age
+#'
+#' @export valuationTable_improvementFactors
+#' @exportClass valuationTable_improvementFactors
+valuationTable_improvementFactors=setClass(
+  "valuationTable_improvementFactors",
   slots=list(baseYear="numeric", improvement="numeric"),
   prototype=list(baseYear=2012, improvement=rep(0,120)),
-  contains="valuationTable.period"
+  contains="valuationTable_period"
 );
 
-# A cohort life table described by actual observations (data frame of PODs
-# per year and age)
-valuationTable.observed=setClass(
-  "valuationTable.observed",
+#' A cohort life table described by actual observations (data frame of PODs
+#' per year and age)
+#'
+#' @slot data    The observations
+#'
+#' @export valuationTable_observed
+#' @exportClass valuationTable_observed
+valuationTable_observed=setClass(
+  "valuationTable_observed",
   slots=list(data="data.frame"),
   prototype=list(data=data.frame()),
   contains="valuationTable"
 );
 
-# A cohort life table obtained by joining two cohort life tables, each of which
-# applies only to certain observation years (e.g. for the past use the observed
-# PODs, and project them to the future with the trend projection)
-valuationTable.joined=setClass(
-  "valuationTable.joined",
+
+#' A cohort life table obtained by joining two cohort life tables, each of which
+#' applies only to certain observation years (e.g. for the past use the observed
+#' PODs, and project them to the future with the trend projection)
+#'
+#' @slot table1 The first \code{valuationTable}, valid for years given in \code{yearRange1}
+#' @slot yearRange1 The years, for which \code{table1} describes the death probabilities
+#' @slot table2 The second \code{valuationTable}, valid for years given in \code{yearRange2}
+#' @slot yearRange2 The years, for which \code{table2} describes the death probabilities
+#'
+#' @export valuationTable_joined
+#' @exportClass valuationTable_joined
+valuationTable_joined=setClass(
+  "valuationTable_joined",
   slots=list(
     table1="valuationTable", yearRange1="numeric",
     table2="valuationTable", yearRange2="numeric"),
   contains="valuationTable"
 );
-# A cohort life table obtained by mixing two life tables with the given weights
-valuationTable.mixed=setClass(
-  "valuationTable.mixed",
+
+#' A cohort life table obtained by mixing two life tables with the given weights
+#'
+#' @slot table1 The first \code{valuationTable}
+#' @slot table2 The second \code{valuationTable}
+#' @slot weight1 The weight of the first valuation table
+#' @slot weight2 The weight of the second valuation table
+#' @slot loading Additional security loading
+#'
+#' @export valuationTable_mixed
+#' @exportClass valuationTable_mixed
+valuationTable_mixed=setClass(
+  "valuationTable_mixed",
   slots=c(table1="valuationTable", table2="valuationTable", weight1="numeric", weight2="numeric", loading="numeric"),
   prototype=list(weight1=1/2, weight2=1/2, loading=0),
   contains="valuationTable"
@@ -78,43 +151,100 @@ valuationTable.mixed=setClass(
 
 
 
+#' Return the maximum age of the life table
+#'
+#' @name valuationTable
+#' @rdname valuationTable-class
+#' @exportMethod getOmega
 setGeneric("getOmega", function(object) standardGeneric("getOmega"));
-setMethod("getOmega", "valuationTable.period",
+#' Return the maximum age of the period life table
+#'
+#' @name valuationTable_period-class
+#' @rdname valuationTable_period-class
+#' @aliases getOmega,valuationTable_period-method
+setMethod("getOmega", "valuationTable_period",
           function (object) {
             max(object@ages,na.rm=TRUE);
           })
-setMethod("getOmega", "valuationTable.mixed",
+#' Return the maximum age of the mixed life table
+#'
+#' @name valuationTable_mixed-class
+#' @rdname valuationTable_mixed-class
+#' @aliases getOmega,valuationTable_mixed-method
+setMethod("getOmega", "valuationTable_mixed",
           function (object) {
             getOmega(object@table1);
           })
-setMethod("getOmega", "valuationTable.joined",
+#' Return the maximum age of the joined life table
+#'
+#' @name valuationTable_joined-class
+#' @rdname valuationTable_joined-class
+#' @aliases getOmega,valuationTable_joined-method
+setMethod("getOmega", "valuationTable_joined",
           function (object) {
             getOmega(object@table1);
           })
 
+
+#' Return the defined ages of the life table
+#'
+#' @name valuationTable
+#' @rdname valuationTable-class
+#' @exportMethod ages
 setGeneric("ages", function(object, ...) standardGeneric("ages"));
-setMethod("ages", "valuationTable.period",
+#' Return the defined ages of the life table
+#'
+#' @name valuationTable_period-class
+#' @rdname valuationTable_period-class
+#' @aliases ages,valuationTable_period-method
+setMethod("ages", "valuationTable_period",
           function (object, ...) {
             object@ages;
           })
-setMethod("ages", "valuationTable.mixed",
+#' Return the defined ages of the life table
+#'
+#' @name valuationTable_mixed-class
+#' @rdname valuationTable_mixed-class
+#' @aliases ages,valuationTable_mixed-method
+setMethod("ages", "valuationTable_mixed",
           function (object, ...) {
             ages(object@table1);
           })
-setMethod("ages", "valuationTable.joined",
+#' Return the defined ages of the life table
+#'
+#' @name valuationTable_joined-class
+#' @rdname valuationTable_joined-class
+#' @aliases ages,valuationTable_joined-method
+setMethod("ages", "valuationTable_joined",
           function (object, ...) {
             ages(object@table1);
           })
 
+
+
+#' Return the age shift of the age-shifted life table given the birth year
+#'
+#' @param YOB The birth year for which the age shift should be determined.
+#'
+#' @name valuationTable_ageShift
+#' @rdname valuationTable_ageShift-class
+#' @exportMethod ageShift
 setGeneric("ageShift", function(object, YOB=1975, ...) standardGeneric("ageShift"));
-setMethod("ageShift","valuationTable.ageShift",
+#' Return the age shift of the age-shifted life table given the birth year
+#'
+#' @param YOB The birth year for which the age shift should be determined.
+#'
+#' @name valuationTable_ageShift-class
+#' @rdname valuationTable_ageShift-class
+#' @aliases ageShift,valuationTable_ageShift-method
+setMethod("ageShift","valuationTable_ageShift",
           function(object, YOB, ...) {
             shift = object@ageShifts[toString(YOB),];
             if (is.na(shift)) {
               # The row names (YOB) are unfortunately strings, so we cannot easily query them.
               # TODO: Change the data.frame to use a real column for the YOB
-              firstYOB = head(rownames(object@ageShifts), n=1);
-              lastYOB = tail(rownames(object@ageShifts), n=1);
+              firstYOB = utils::head(rownames(object@ageShifts), n=1);
+              lastYOB = utils::tail(rownames(object@ageShifts), n=1);
               if (YOB < as.integer(firstYOB)) {
                 shift = object@ageShifts[firstYOB,];
               } else if (YOB > as.integer(lastYOB)) {
@@ -124,12 +254,35 @@ setMethod("ageShift","valuationTable.ageShift",
             shift
           })
 
+
+
+#' Return the (cohort) death probabilities of the life table given the birth year (if needed)
+#'
+#' @param YOB The birth year for which the death probabilities should be calculated
+#'
+#' @name valuationTable
+#' @rdname valuationTable-class
+#' @exportMethod deathProbabilities
 setGeneric("deathProbabilities", function(object, ..., YOB=1975) standardGeneric("deathProbabilities"));
-setMethod("deathProbabilities", "valuationTable.period",
+#' Return the (cohort) death probabilities of the life table given the birth year (if needed)
+#'
+#' @param YOB The birth year for which the death probabilities should be calculated
+#'
+#' @name valuationTable_period-class
+#' @rdname valuationTable_period-class
+#' @aliases deathProbabilities,valuationTable_period-method
+setMethod("deathProbabilities", "valuationTable_period",
           function(object, ..., YOB=1975) {
             object@modification(object@deathProbs * (1+object@loading));
           })
-setMethod("deathProbabilities","valuationTable.ageShift",
+#' Return the (cohort) death probabilities of the life table given the birth year (if needed)
+#'
+#' @param YOB The birth year for which the death probabilities should be calculated
+#'
+#' @name valuationTable_ageShift-class
+#' @rdname valuationTable_ageShift-class
+#' @aliases deathProbabilities,valuationTable_ageShift-method
+setMethod("deathProbabilities","valuationTable_ageShift",
           function (object,  ..., YOB=1975) {
             qx=object@deathProbs * (1+object@loading);
             shift = ageShift(object, YOB);
@@ -141,8 +294,14 @@ setMethod("deathProbabilities","valuationTable.ageShift",
             object@modification(qx)
           })
 
-
-setMethod("deathProbabilities","valuationTable.trendProjection",
+#' Return the (cohort) death probabilities of the life table given the birth year (if needed)
+#'
+#' @param YOB The birth year for which the death probabilities should be calculated
+#'
+#' @name valuationTable_trendProjection-class
+#' @rdname valuationTable_trendProjection-class
+#' @aliases deathProbabilities,valuationTable_trendProjection-method
+setMethod("deathProbabilities","valuationTable_trendProjection",
           function (object,  ..., YOB=1975) {
             qx=object@deathProbs * (1+object@loading);
             if (is.null(object@trend2) || length(object@trend2)<=1) {
@@ -158,13 +317,27 @@ setMethod("deathProbabilities","valuationTable.trendProjection",
             object@modification(finalqx)
           })
 
-setMethod("deathProbabilities","valuationTable.improvementFactors",
+#' Return the (cohort) death probabilities of the life table given the birth year (if needed)
+#'
+#' @param YOB The birth year for which the death probabilities should be calculated
+#'
+#' @name valuationTable_improvementFactors-class
+#' @rdname valuationTable_improvementFactors-class
+#' @aliases deathProbabilities,valuationTable_improvementFactors-method
+setMethod("deathProbabilities","valuationTable_improvementFactors",
           function (object,  ..., YOB=1975) {
             qx=object@deathProbs * (1+object@loading);
             finalqx=(1-object@improvement)^(YOB+0:(length(qx)-1)-object@baseYear)*qx;
             object@modification(finalqx)
           })
-setMethod("deathProbabilities","valuationTable.mixed",
+#' Return the (cohort) death probabilities of the life table given the birth year (if needed)
+#'
+#' @param YOB The birth year for which the death probabilities should be calculated
+#'
+#' @name valuationTable_mixed-class
+#' @rdname valuationTable_mixed-class
+#' @aliases deathProbabilities,valuationTable_mixed-method
+setMethod("deathProbabilities","valuationTable_mixed",
           function (object,  ..., YOB=1975) {
             qx1=deathProbabilities(object@table1, ..., YOB) * (1+object@loading);
             qx2=deathProbabilities(object@table2, ..., YOB) * (1+object@loading);
@@ -173,21 +346,51 @@ setMethod("deathProbabilities","valuationTable.mixed",
           })
 
 
+
+
+#' Return the (period) death probabilities of the life table for a given observation year
+#'
+#' @param Period  The observation year for which the period death probabilities should be determined
+#'
+#' @name valuationTable
+#' @rdname valuationTable-class
+#' @exportMethod periodDeathProbabilities
 setGeneric("periodDeathProbabilities", function(object, ...) standardGeneric("periodDeathProbabilities"));
-setMethod("periodDeathProbabilities", "valuationTable.period",
+#' Return the (period) death probabilities of the life table for a given observation year
+#'
+#' @param Period  The observation year for which the period death probabilities should be determined
+#'
+#' @name valuationTable_period-class
+#' @rdname valuationTable_period-class
+#' @aliases periodDeathProbabilities,valuationTable_period-method
+setMethod("periodDeathProbabilities", "valuationTable_period",
           function(object, ...) {
             object@modification(object@deathProbs * (1+object@loading));
           })
-setMethod("periodDeathProbabilities","valuationTable.ageShift",
+#' Return the (period) death probabilities of the life table for a given observation year
+#'
+#' @param Period  The observation year for which the period death probabilities should be determined
+#'
+#' @name valuationTable_ageShift-class
+#' @rdname valuationTable_ageShift-class
+#' @aliases periodDeathProbabilities,valuationTable_ageShift-method
+setMethod("periodDeathProbabilities","valuationTable_ageShift",
           function (object,  ..., Period=1975) {
             # TODO
             qx=object@deathProbs * (1+object@loading);
-            shift.index=match(YOB, object@shifts, 0);
-            if (shift.index) {}
-            #             TODO
+            # TODO!!!
+            # shift.index=match(YOB, object@shifts, 0);
+            # if (shift.index) {}
             object@modification(qx)
           })
-setMethod("periodDeathProbabilities","valuationTable.trendProjection",
+#' Return the (period) death probabilities of the life table for a given observation year
+#'
+#' @param Period  The observation year for which the period death probabilities should be determined
+#'
+#' @name valuationTable_trendProjection-class
+#' @rdname valuationTable_trendProjection-class
+#' @aliases periodDeathProbabilities,valuationTable_trendProjection-method
+setMethod("periodDeathProbabilities","valuationTable_trendProjection",
           function (object,  ..., Period=1975) {
             qx=object@deathProbs * (1+object@loading);
             if (is.null(object@trend2) || length(object@trend2)<=1) {
@@ -196,21 +399,34 @@ setMethod("periodDeathProbabilities","valuationTable.trendProjection",
               # print(data.frame(age=0:(length(qx)-1), trend=object@trend, exponent=-object@trend*damping, damping=damping, baseqx=qx, qx=exp(-object@trend*damping)*qx)[66:90,]);
               finalqx=exp(-object@trend*damping)*qx;
             } else {
-              # TODO
+              # TODO!!!
               # dampingFunction interpolates between the two trends:
-              weights=sapply(YOB+0:(length(qx)-1), object@dampingFunction);
-              finalqx=qx*exp(-(object@trend*(1-weights) + object@trend2*(weights))*(YOB+0:(length(qx)-1)-object@baseYear));
+              # weights=sapply(YOB+0:(length(qx)-1), object@dampingFunction);
+              # finalqx=qx*exp(-(object@trend*(1-weights) + object@trend2*(weights))*(YOB+0:(length(qx)-1)-object@baseYear));
             }
             object@modification(finalqx)
           })
-# data.frame(x=0:121, qx=deathProbabilities(AVOe2005R.unisex, YOB=1948));
-setMethod("periodDeathProbabilities","valuationTable.improvementFactors",
+#' Return the (period) death probabilities of the life table for a given observation year
+#'
+#' @param Period  The observation year for which the period death probabilities should be determined
+#'
+#' @name valuationTable_improvementFactors-class
+#' @rdname valuationTable_improvementFactors-class
+#' @aliases periodDeathProbabilities,valuationTable_improvementFactors-method
+setMethod("periodDeathProbabilities","valuationTable_improvementFactors",
           function (object, ..., Period=1975) {
             qx=object@deathProbs * (1+object@loading);
             finalqx=(1-object@improvement)^(Period-object@baseYear)*qx;
             object@modification(finalqx)
           })
-setMethod("periodDeathProbabilities","valuationTable.mixed",
+#' Return the (period) death probabilities of the life table for a given observation year
+#'
+#' @param Period  The observation year for which the period death probabilities should be determined
+#'
+#' @name valuationTable_mixed-class
+#' @rdname valuationTable_mixed-class
+#' @aliases periodDeathProbabilities,valuationTable_mixed-method
+setMethod("periodDeathProbabilities","valuationTable_mixed",
           function (object,  ..., Period=1975) {
             qx1=periodDeathProbabilities(object@table1, ..., Period=Period) * (1+object@loading);
             qx2=periodDeathProbabilities(object@table2, ..., Period=Period) * (1+object@loading);
@@ -221,40 +437,104 @@ setMethod("periodDeathProbabilities","valuationTable.mixed",
 
 
 
+#' Return the lifetable object (package lifecontingencies) for the cohort life table
+#'
+#' @param ... Parameters to be handed to the \code{deathProbabilities} method of the life table
+#'
+#' @name valuationTable
+#' @rdname valuationTable-class
+#' @exportMethod lifeTable
 setGeneric("lifeTable", function(object, ...) standardGeneric("lifeTable"));
+#' Return the lifetable object (package lifecontingencies) for the cohort life table
+#'
+#' @param ... Parameters to be handed to the \code{deathProbabilities} method of the life table
+#'
+#' @name valuationTable-class
+#' @rdname valuationTable-class
+#' @aliases lifeTable,valuationTable-method
 setMethod("lifeTable","valuationTable",
           function (object,  ...) {
             qx=deathProbabilities(object, ...);
             if (qx[[length(qx)]]!=1) { qx=c(qx, 1, 1); }
-            probs2lifetable(qx, type="qx")
+            lifecontingencies::probs2lifetable(qx, type="qx")
           })
 
 
+
+
+#' Return the base year of the life table
+#'
+#' @name valuationTable
+#' @rdname valuationTable-class
+#' @exportMethod baseYear
 setGeneric("baseYear", function(object, ...) standardGeneric("baseYear"));
+#' Return the base year of the life table
+#'
+#' @name valuationTable-class
+#' @rdname valuationTable-class
+#' @aliases baseYear,valuationTable-method
 setMethod("baseYear","valuationTable",
           function (object,  ...) {
             object@baseYear
           })
-setMethod("baseYear","valuationTable.mixed",
+#' Return the base year of the life table
+#'
+#' @name valuationTable_mixed-class
+#' @rdname valuationTable_mixed-class
+#' @aliases baseYear,valuationTable_mixed-method
+setMethod("baseYear","valuationTable_mixed",
           function (object,  ...) {
             baseYear(object@table1)
           })
 
+
+
+#' Return the base table of the life table
+#'
+#' @name valuationTable
+#' @rdname valuationTable-class
+#' @exportMethod baseTable
 setGeneric("baseTable", function(object, ...) standardGeneric("baseTable"));
+#' Return the base table of the life table
+#'
+#' @name valuationTable-class
+#' @rdname valuationTable-class
+#' @aliases baseTable,valuationTable-method
 setMethod("baseTable","valuationTable",
           function (object,  ...) {
             c()
           })
-setMethod("baseTable","valuationTable.period",
+#' Return the base table of the life table
+#'
+#' @name valuationTable_period-class
+#' @rdname valuationTable_period-class
+#' @aliases baseTable,valuationTable_period-method
+setMethod("baseTable","valuationTable_period",
           function (object,  ...) {
             object@deathProbs
           })
 
 
+
+
+#' Return the period life table as a \code{valuationTable_period} object
+#'
+#' @param Period The observation year, for which the death probabilities should be determined
+#'
+#' @name valuationTable
+#' @rdname valuationTable-class
+#' @exportMethod getPeriodTable
 setGeneric("getPeriodTable", function(object, Period, ...) standardGeneric("getPeriodTable"));
+#' Return the period life table as a \code{valuationTable_period} object
+#'
+#' @param Period The observation year, for which the death probabilities should be determined
+#'
+#' @name valuationTable-class
+#' @rdname valuationTable-class
+#' @aliases getPeriodTable,valuationTable-method
 setMethod("getPeriodTable","valuationTable",
           function (object, Period, ...) {
-            valuationTable.period(
+            valuationTable_period(
                 name = paste(object@name, ", Period ", Period),
                 baseYear = Period,
                 ages = ages(object),
@@ -262,10 +542,27 @@ setMethod("getPeriodTable","valuationTable",
             )
           })
 
-setGeneric("getCohortTable", function(object, Period, ...) standardGeneric("getCohortTable"));
+
+
+#' Return the cohort life table as a \code{valuationTable_period} object
+#'
+#' @param YOB The birth year for which the life table should be calculated
+#'
+#' @name valuationTable
+#' @rdname valuationTable-class
+#' @exportMethod getCohortTable
+setGeneric("getCohortTable", function(object, YOB, ...) standardGeneric("getCohortTable"));
+#' Return the cohort life table as a \code{valuationTable_period} object
+#'
+#' @param YOB The birth year for which the life table should be calculated
+#'
+#' @name valuationTable-class
+#' @rdname valuationTable-class
+#' @aliases getCohortTable,valuationTable-method
+#' @export getCohortTable
 setMethod("getCohortTable","valuationTable",
           function (object, YOB, ...) {
-            valuationTable.period(
+            valuationTable_period(
                 name = paste(object@name, ", YOB ", YOB),
                 baseYear = YOB,
                 ages=ages(object),
@@ -274,73 +571,22 @@ setMethod("getCohortTable","valuationTable",
           })
 
 
+
+
+#' Return a \code{valuationTable_trensProjection} object with the trend damping removed.
+#'
+#' @name valuationTable_trendProjection
+#' @rdname valuationTable_trendProjection-class
+#' @exportMethod undampenTrend
 setGeneric("undampenTrend", function (object) standardGeneric("undampenTrend"));
-setMethod("undampenTrend", "valuationTable.trendProjection",
+#' Return a \code{valuationTable_trensProjection} object with the trend damping removed.
+#'
+#' @name valuationTable_trendProjection-class
+#' @rdname valuationTable_trendProjection-class
+#' @aliases undampenTrend,valuationTable_trendProjection-method
+#' @export undampenTrend
+setMethod("undampenTrend", "valuationTable_trendProjection",
           function (object) {
             object@dampingFunction=identity;
             object
             });
-
-
-makeQxDataFrame = function(..., YOB=1972, Period=NA) {
-  data=list(...);
-  names(data) = lapply(data, function(t) t@name);
-  if (missing(Period)) {
-    cat("Year of birth: ", YOB, "\n");
-    data = lapply(data, function(t) cbind(x=ages(t), y=deathProbabilities(t, YOB=YOB)))
-  } else {
-    cat("Period: ", Period,"\n");
-    data = lapply(data, function(t) cbind(x=ages(t), y=periodDeathProbabilities(t, Period=Period)))
-  }
-
-  list.names = names(data)
-  lns <- sapply(data, nrow)
-  data <- as.data.frame(do.call("rbind", data))
-  data$group <- rep(list.names, lns)
-  data
-}
-
-plotValuationTables = function(data, ..., title = "", legend.position=c(0.9,0.1), legend.key.width = unit(25, "mm")) {
-  if (!is.data.frame(data)) {
-    data = makeQxDataFrame(data, ...);
-  }
-
-  pl = ggplot(data, aes(x = x, y = y, colour = data$group)) +
-    theme_bw() +
-    theme(
-      plot.title = element_text(size=18, face="bold"),
-      legend.title = element_text(size=14, face="bold.italic"),
-      # legend in bottom right corner of the plot
-      legend.justification=c(1,0), legend.position=legend.position,
-      # No box around legend entries
-      legend.key = element_blank(),
-      legend.key.width = legend.key.width,
-      legend.background = element_rect(colour="gray50", linetype="solid")
-    ) +
-    geom_line() +
-    scale_y_log10(
-      name=expression(paste("Sterbewahrscheinlichkeit  ", q[x])),
-      breaks = scales::trans_breaks('log10', function(x) 10^x),
-      labels = scales::trans_format('log10', scales::math_format(10^.x))
-      #minor_breaks = log(c(sapply(x, function(x) seq(0, x, x/10))), 10)
-    ) +
-    scale_x_continuous(
-      name="Alter",
-      #breaks = function (limits) scales::trans_breaks('', function(x) 10^x),
-      breaks = function (limits) seq(max(min(limits),0),max(limits),5),
-      minor_breaks = function (limits) seq(max(round(min(limits)),0),round(max(limits)),1),
-      #labels = scales::trans_format('log10', scales::math_format(10^.x))
-
-    ) +
-    annotation_logticks(sides="lr") +
-    xlab("Alter") + labs(colour="Sterbetafel");
-  if (title != "") {
-    pl = pl + ggtitle(title);
-  }
-  pl# + coord_flip()
-}
-#
-# plotValuationTables(mort.AT.census.1869.male, mort.AT.census.1869.female, mort.AT.census.2011.male, mort.AT.census.2011.female, AVOe2005R.male, AVOe2005R.female, YOB=1972,title="Vergleich österreichische Sterbetafeln, YOB=1972 (bei Generationentafeln)")
-#
-# plotValuationTables(mort.AT.census.2001.male, AVOe2005R.male, YOB=1972, title="Vergleich österreichische Sterbetafeln")
-#  plotValuationTables(getCohortTable(AVOe2005R.male, YOB=1972), getCohortTable(AVOe2005R.male, YOB=2016), title="Vergleich österreichische Sterbetafeln")
diff --git a/R/exportInsuranceContract_xlsx.R b/R/exportInsuranceContract_xlsx.R
deleted file mode 100644
index bcf8b67aa3b0e4df903af87a2c252b0601a330a1..0000000000000000000000000000000000000000
--- a/R/exportInsuranceContract_xlsx.R
+++ /dev/null
@@ -1,409 +0,0 @@
-
-################################################
-# Helper Functions
-################################################
-
-
-writeAgeQTable = function (wb, sheet, probs, crow=1, ccol=1, styles=list()) {
-  writeData(wb, sheet, "Sterblichkeiten", startCol = ccol+2, startRow = crow);
-  addStyle(wb, sheet, style=styles$header, rows=crow, cols = ccol+2, stack=TRUE);
-  mergeCells(wb, sheet, rows=crow, cols=(ccol+2):(ccol+3))
-  writeDataTable(wb, sheet, probs,
-                 startRow=crow+1, startCol = ccol, colNames = TRUE, rowNames = TRUE,
-                 tableStyle = "TableStyleMedium3", withFilter = FALSE, headerStyle = styles$tableHeader);
-  freezePane(wb, sheet, firstActiveRow=crow+2, firstActiveCol = ccol+2)
-  addStyle(wb, sheet, style=styles$center, rows=(crow+2):(crow+1+dim(probs)[[1]]), cols=ccol:(ccol+1), gridExpand = TRUE, stack=TRUE);
-  addStyle(wb, sheet, style=styles$qx, rows=(crow+2):(crow+1+dim(probs)[[1]]), cols=(ccol+2):(ccol+3), gridExpand = TRUE, stack=TRUE);
-  dim(probs)[[2]] + 2;
-};
-
-writeValuesTable = function (wb, sheet, values, caption=NULL, crow=1, ccol=1, rowNames=FALSE, tableStyle="TableStyleMedium3", tableName=NULL, withFilter=FALSE, styles=list(), valueStyle=NULL) {
-  nrrow = dim(values)[[1]];
-  nrcol = dim(values)[[2]];
-  addcol = if (rowNames) 1 else 0;
-  ecol = ccol + addcol + nrcol - 1;
-  if (!missing(caption)) {
-    writeData(wb, sheet, caption, startCol = ccol+addcol, startRow = crow);
-    addStyle(wb, sheet, style=styles$header, rows=crow, cols = ccol+addcol, stack=TRUE);
-    mergeCells(wb, sheet, rows=crow, cols=(ccol+addcol):ecol);
-  }
-
-  writeDataTable(wb, sheet, values, startRow=crow+1, startCol=ccol, colNames=TRUE,
-                 rowNames=rowNames, tableStyle=tableStyle,
-                 tableName=tableName, withFilter = withFilter, headerStyle = styles$tableHeader)
-  if (!missing(valueStyle)) {
-    addStyle(wb, sheet, style=valueStyle, rows=(crow+2):(crow+nrrow+1), cols=(ccol+addcol):ecol, gridExpand = TRUE, stack = TRUE);
-  }
-  # width of table is the return value
-  nrcol + addcol
-};
-
-writePremiumCoefficients = function(wb, sheet, values, tarif=NULL, type="benefits", crow=crow, ccol=ccol) {
-  writeData(wb, sheet, matrix(c(
-    "Nettoprämie", "", "Zillmerprämie", "", "Bruttoprämie", "",
-    "rel. zu VS", "rel. zu Prämie", "rel. zu VS", "rel. zu Prämie", "rel. zu VS", "rel. zu Prämie"), 6, 2
-  ), startCol = ccol, startRow = crow, colNames = FALSE, borders = "rows", borderColour = "gray5", borderStyle = "thin");
-  mergeCells(wb, sheet, cols = ccol, rows = crow:(crow+1));
-  mergeCells(wb, sheet, cols = ccol, rows = (crow+2):(crow+3));
-  mergeCells(wb, sheet, cols = ccol, rows = (crow+4):(crow+5));
-  addStyle(wb, sheet, style=createStyle(halign = "left", valign = "center",
-                                        borderColour = "gray5", border = "LeftBottomTop",
-                                        borderStyle = "thin"),
-           rows = crow:(crow+5), cols = ccol);
-  addStyle(wb, sheet, style=createStyle(halign = "right", valign = "center",
-                                        borderColour = "gray5", border = "RightBottomTop",
-                                        borderStyle = "thin"),
-           rows = crow:(crow+5), cols = ccol+1);
-
-  # The first column of the benefits coefficients is for "age", which we want to remove
-  mod = function(a) { as.data.frame(t(a)) };
-  if (type=="costs") {
-    mod = function(vals) {
-      vals = setInsuranceValuesLabels(vals);
-      newvals=vals;
-      dimn = dimnames(newvals);
-      dim(newvals) = c(1, dim(vals));
-      dimnames(newvals) = c(list("Coeff"), dimn);
-      as.data.frame(tarif$costValuesAsMatrix(newvals))
-    };
-  }
-  coeff = rbind(mod(values[["net"]][["SumInsured"]][[type]]),
-                mod(values[["net"]][["Premium"]][[type]]),
-                mod(values[["Zillmer"]][["SumInsured"]][[type]]),
-                mod(values[["Zillmer"]][["Premium"]][[type]]),
-                mod(values[["gross"]][["SumInsured"]][[type]]),
-                mod(values[["gross"]][["Premium"]][[type]]));
-
-  writeData(wb, sheet, coeff, startCol = ccol+2, startRow = crow, colNames=FALSE, borders="rows", borderColour="gray5", borderStyle="thin");
-  dim(coeff)[[2]]
-}
-
-labelsReplace = function(labels) {
-  labels[labels=="alpha"] = "α";
-  labels[labels=="Zillmer"] = "Zill.";
-  labels[labels=="beta"] = "β";
-  labels[labels=="gamma"] = "γ";
-  labels[labels=="gamma_nopremiums"] = "γ_prf";
-  labels[labels=="SumInsured"] = "VS";
-  labels[labels=="SumPremiums"] = "PS";
-  labels[labels=="GrossPremium"] = "BP";
-
-  labels[labels=="premiums"] = "Präm.";
-  labels[labels=="guaranteed"] = "Gar.";
-  labels[labels=="survival"] = "Erl.";
-  labels[labels=="death_SumInsured"] = "Abl. VS";
-  labels[labels=="death_GrossPremium"] = "Abl. BP";
-  labels[labels=="death"] = "Abl.";
-  labels[labels=="death_PremiumFree"] = "Abl. prf";
-  labels[labels=="benefits"] = "Abl.Lst.";
-  labels[labels=="benefitsAndRefund"] = "Abl. + RG";
-
-  labels[labels=="once"] = "einm."
-  labels[labels=="PremiumPeriod"] = "PD"
-  labels[labels=="PremiumFree"] = "Pr.Fr."
-  labels[labels=="PolicyPeriod"] = "LZ"
-
-
-  labels
-}
-
-setInsuranceValuesLabels = function(vals) {
-  dimnames(vals) = lapply(dimnames(vals), labelsReplace);
-  vals
-}
-
-
-################################################################################
-#
-# The actual export function
-#
-#    exportInsuranceContract.xlsx(contract, filename)
-#
-################################################################################
-
-
-exportInsuranceContract.xlsx = function(contract, filename) {
-  # TODO: argument checking for contract and filename
-
-  ###
-  nrrows = dim(contract$values$cashFlows)[[1]]; # Some vectors are longer (e.g. qx), so determine the max nr or rows
-  qp = contract$values$transitionProbabilities[1:nrrows,]; # extract the probabilities once, will be needed in every sheet
-
-  ################################################
-  # Style information
-  ################################################
-  styles = list(
-    header = createStyle(border="TopBottomLeftRight", borderColour="#DA9694", borderStyle="medium",
-                         fgFill="#C0504D", fontColour="#FFFFFF",
-                         halign="center", valign="center", textDecoration="bold"),
-    tableHeader = createStyle(#border="TopLeftRight", borderColour="#DA9694", borderStyle="medium",
-                              #bgFill="#C0504D", fontColour="#FFFFFF",
-                              halign="center", valign="center", textDecoration="bold"),
-    hide0 = createStyle(numFmt="General; General; \"\""),
-    currency0 = createStyle(numFmt="[$€-C07] #,##0.00;[red]-[$€-C07] #,##0.00;\"\""),
-    cost0 = createStyle(numFmt="0.000%; 0.000%; \"\""),
-    pv0 = createStyle(numFmt="0.00000;-0.00000;\"\""),
-    qx = createStyle(numFmt="0.000000"),
-    wrap = createStyle(wrapText=TRUE),
-    center = createStyle(halign="center", valign="center")
-  );
-
-  ################################################
-  # General Workbook setup
-  ################################################
-  wb = openxlsx::createWorkbook();
-  addWorksheet(wb, "Tarifinformationen");
-  addWorksheet(wb, "Basisdaten");
-  addWorksheet(wb, "Reserven");
-  addWorksheet(wb, "abs.Barwerte");
-  addWorksheet(wb, "abs.Cash-Flows");
-  addWorksheet(wb, "Barwerte");
-  addWorksheet(wb, "Cash-Flows");
-
-  # Print out general Contract and Tariff information, including results
-  sheet = "Tarifinformationen"
-  crow = 1;
-  writeData(wb, sheet, matrix(c(
-    "Tarif:", contract$tarif$tarif,
-    "Tarifname:", contract$tarif$name,
-    "Description:", contract$tarif$desc
-  ), 3, 2, byrow = TRUE), startCol=1, startRow=1, colNames=FALSE, rowNames=FALSE);
-  mergeCells(wb, sheet, cols=2:10, rows=1);
-  mergeCells(wb, sheet, cols=2:10, rows=2);
-  mergeCells(wb, sheet, cols=2:10, rows=3);
-  addStyle(wb, sheet, style=styles$wrap, rows=3, cols=2:10, stack=TRUE);
-  addStyle(wb, sheet, style=createStyle(valign="top"), rows=1:3, cols=1:10, gridExpand=TRUE, stack=TRUE);
-  setColWidths(wb, sheet, cols = 1:50, widths = "auto", ignoreMergedCells = TRUE);
-
-  crow = crow+4;
-
-  ################################################
-  # Basic parameters
-  ################################################
-  values=c(
-    "Sum insured"=contract$params$sumInsured,
-    "Mortality table"=contract$tarif$mortalityTable@name,
-    "YOB"=contract$params$YOB,
-    "Age"=contract$params$age,
-    "Policy duration"=contract$params$policyPeriod,
-    "Premium period"=contract$params$premiumPeriod,
-    "Deferral"=contract$params$deferral,
-    "Guaranteed payments"=contract$params$guaranteed,
-    i=contract$tarif$i);
-
-  writeData(wb, sheet, "Basisdaten des Vertrags und Tarifs", startCol=1, startRow=crow);
-  mergeCells(wb, sheet, cols=1:length(values), rows=crow:crow);
-  writeDataTable(wb, sheet, as.data.frame(t(values)),
-                 startCol=1, startRow=crow+1, colNames=TRUE, rowNames=FALSE,
-                 tableStyle="TableStyleMedium3", withFilter = FALSE, headerStyle = styles$tableHeader);
-
-  crow = crow + 4;
-
-  # Premiums
-  writeData(wb, sheet, "Prämien", startCol=1, startRow=crow);
-  mergeCells(wb, sheet, cols=1:length(contract$values$premiums), rows=crow:crow);
-  writeDataTable(wb, sheet, setInsuranceValuesLabels(as.data.frame(t(contract$values$premiums))),
-                 startCol=1, startRow=crow+1, colNames=TRUE, rowNames=FALSE,
-                 tableStyle="TableStyleMedium3", withFilter = FALSE, headerStyle = styles$tableHeader);
-  crow = crow + 4;
-
-  # Cost structure:
-  costtable = as.data.frame.table(setInsuranceValuesLabels(contract$tarif$costs) )
-  colnames(costtable) = c("Kostenart", "Basis", "Periode", "Kostensatz");
-  costtable = costtable[costtable[,"Kostensatz"]!=0.0000,]
-  writeValuesTable(wb, sheet, costtable, crow=crow, ccol=1, tableName="Kosten", styles=styles, caption="Kosten");
-  # writeDataTable(wb, sheet, costtable, startCol=1, startRow=crow+1, colNames=TRUE, rowNames=FALSE,
-                 # tableStyle = "TableStyleMedium3", headerStyle = styles$tableHeader);
-  addStyle(wb, sheet, style=styles$cost0, rows=(crow+2):(crow+dim(costtable)[[1]]+1), cols=4, stack=TRUE);
-  setColWidths(wb, sheet, cols = 1:50, widths = "auto", ignoreMergedCells = TRUE)
-  crow = crow + dim(costtable)[[1]] + 3;
-
-  # Contract history
-  # time=t, comment=sprintf("Premium waiver at time %d", t), type="PremiumWaiver"
-  histtime = unlist(lapply(contract$history, function(xl) xl$time));
-  histcomment = unlist(lapply(contract$history, function(xl) xl$comment));
-  histtype = unlist(lapply(contract$history, function(xl) xl$type));
-  writeValuesTable(wb, sheet, data.frame(time=histtime, Comment=histcomment, Type=histtype),
-                   crow=crow, ccol=1, tableName="Vertragshistorie", styles=styles,
-                   caption="Vertragshistorie");
-  crow = crow + dim(histtime)[[1]] + 3;
-
-
-
-  ################################################
-  # Print out Basic contract data as time series
-  ################################################
-
-  # Age, death and survival probabilities
-  ccol = 1;
-  crow = 4;
-  sheet = "Basisdaten";
-  tbl = qp[,"age", drop=FALSE];
-  writeDataTable(wb, sheet, tbl,
-                 startRow=crow+1, startCol = ccol, colNames = TRUE, rowNames = TRUE,
-                 tableStyle = "TableStyleMedium3", withFilter = FALSE, headerStyle = styles$tableHeader);
-  freezePane(wb, sheet, firstActiveRow=crow+2, firstActiveCol = ccol+2)
-  addStyle(wb, sheet, style=styles$center, rows=(crow+2):(crow+1+dim(tbl)[[1]]), cols=ccol:(ccol+1), gridExpand = TRUE, stack=TRUE);
-  ccol = ccol + dim(tbl)[[2]] + 2;
-
-  ccol = ccol + writeValuesTable(wb, sheet, as.data.frame(setInsuranceValuesLabels(contract$values$basicData)),
-                                 crow=crow, ccol=ccol, tableName="Grunddaten", styles=styles,
-                                 caption="Vertragsgrunddaten im Zeitverlauf", valueStyle=styles$currency0) + 1;
-  setColWidths(wb, sheet, cols = 1:50, widths = "auto", ignoreMergedCells = TRUE)
-
-  # TODO: Change PremiumPayment column to 0=prf. / 1=prpfl. / -1=außerplanm.prf.
-  # TODO: Change InterestRate column to percent format
-
-
-
-  ################################################
-  # Print out Reserves and premium decomposition
-  ################################################
-
-  # Age, death and survival probabilities
-  ccol = 1;
-  crow = 4;
-  sheet = "Reserven";
-
-  ccol = ccol + writeAgeQTable(wb, sheet, probs=qp, crow=crow, ccol=1, styles=styles);
-  ccol = ccol + writeValuesTable(wb, sheet, as.data.frame(setInsuranceValuesLabels(contract$values$reserves)),
-                                 crow=crow, ccol=ccol, tableName="Reserves", styles=styles,
-                                 caption="Reserven", valueStyle=styles$currency0) + 1;
-  ccol = ccol + writeValuesTable(wb, sheet, as.data.frame(setInsuranceValuesLabels(contract$values$premiumComposition)),
-                                 crow=crow, ccol=ccol, tableName="Premium_Decomposition", styles=styles,
-                                 caption = "Prämienzerlegung", valueStyle=styles$currency0) + 1;
-  setColWidths(wb, sheet, cols = 1:50, widths = "auto", ignoreMergedCells = TRUE)
-
-
-  ################################################
-  # Print out absolute values of present values
-  ################################################
-
-  # Age, death and survival probabilities
-  ccol = 1;
-  crow = 4;
-  sheet = "abs.Barwerte";
-  ccol = ccol + writeAgeQTable(wb, sheet, probs=qp, crow=crow, ccol=1, styles=styles);
-
-  ccol = ccol + writeValuesTable(wb, sheet, as.data.frame(setInsuranceValuesLabels(contract$values$absPresentValues)),
-                                 crow=crow, ccol=ccol, tableName="PresentValues_absolute", styles=styles,
-                                 caption = "abs. Leistungs- und Kostenbarwerte", valueStyle=styles$currency0) + 1;
-  setColWidths(wb, sheet, cols = 1:50, widths = "auto", ignoreMergedCells = TRUE)
-
-
-  ################################################
-  # Print out absolute values for cash flows
-  ################################################
-
-  # Age, death and survival probabilities
-  ccol = 1;
-  crow = 4;
-  sheet = "abs.Cash-Flows";
-  ccol = ccol + writeAgeQTable(wb, sheet, probs=qp, crow=crow, ccol=1, styles=styles);
-  ccol = ccol + writeValuesTable(wb, sheet, as.data.frame(setInsuranceValuesLabels(contract$values$absCashFlows)),
-                                 crow=crow, ccol=ccol, tableName="CashFlows_absolute", styles=styles,
-                                 caption="abs. Leistungs- und Kostencashflows", withFilter=TRUE, valueStyle=styles$currency0) + 1;
-  setColWidths(wb, sheet, cols = 1:50, widths = "auto", ignoreMergedCells = TRUE)
-
-
-  ################################################
-  # Print out present values
-  ################################################
-
-  # Age, death and survival probabilities
-  costPV = as.data.frame(contract$tarif$costValuesAsMatrix(setInsuranceValuesLabels(contract$values$presentValuesCosts)));
-  ccol = 1;
-  crow = 4;
-  sheet = "Barwerte";
-  # We add six lines before the present values to show the coefficients for the premium calculation
-  ccol = ccol + writeAgeQTable(wb, sheet, probs=qp, crow=crow+6, ccol=1, styles=styles);
-
-  # Store the start/end columns of the coefficients, since we need them later in the formula for the premiums!
-  w1 = writePremiumCoefficients(wb, sheet, contract$values$premiumCoefficients, type="benefits", crow=crow, ccol=ccol-2, tarif=contract$tarif);
-  area.premiumcoeff = paste0(int2col(ccol), "%d:", int2col(ccol+w1-1), "%d");
-  area.premiumvals  = paste0("$", int2col(ccol), "$", crow+6+2, ":$", int2col(ccol+w1-1), "$", crow+6+2);
-  ccol = ccol + writeValuesTable(wb, sheet, as.data.frame(setInsuranceValuesLabels(contract$values$presentValues)),
-                                 crow=crow+6, ccol=ccol, tableName="PresentValues_Benefits", styles=styles,
-                                 caption = "Leistungsbarwerte", valueStyle=styles$pv0) + 1;
-
-  w2 = writePremiumCoefficients(wb, sheet, contract$values$premiumCoefficients, type="costs", crow=crow, ccol=ccol-2, tarif=contract$tarif);
-  area.costcoeff = paste0(int2col(ccol), "%d:", int2col(ccol+w2-1), "%d");
-  area.costvals  = paste0("$", int2col(ccol), "$", crow+6+2, ":$", int2col(ccol+w2-1), "$", crow+6+2);
-  ccol = ccol + writeValuesTable(wb, sheet, as.data.frame(costPV),
-                                 crow=crow+6, ccol=ccol, tableName="PresentValues_Costs", styles=styles,
-                                 caption = "Kostenbarwerte", valueStyle=styles$cost0) + 1;
-
-  # Now print out the formulas for premium calculation into the columns 2 and 3:
-  writeData(wb, sheet, as.data.frame(c("Nettoprämie", contract$values$premiums[["net"]],"Zillmerprämie", contract$values$premiums[["Zillmer"]], "Bruttoprämie", contract$values$premiums[["gross"]])), startCol = 1, startRow=crow, colNames = FALSE, borders = "rows");
-  for (i in 0:5) {
-    writeFormula(wb, sheet, paste0("SUMPRODUCT(", sprintf(area.premiumcoeff, crow+i, crow+i), ", ", area.premiumvals, ") + SUMPRODUCT(", sprintf(area.costcoeff, crow+i, crow+i), ", ", area.costvals, ")"), startCol = 3, startRow = crow+i);
-    addStyle(wb, sheet, style=styles$pv0, rows = crow+i, cols = 3, stack = TRUE);
-  }
-  for (i in c(0,2,4)) {
-    writeFormula(wb, sheet, paste0(int2col(3), crow+i, "/", int2col(3), crow+i+1), startCol=2, startRow = crow+i);
-    addStyle(wb, sheet, style=styles$pv0, rows = crow+i, cols = 2, stack = TRUE);
-  }
-  for (i in c(1,3,5)) {
-    writeFormula(wb, sheet, paste0(int2col(2), crow+i-1, "*", contract$params$sumInsured), startCol=2, startRow = crow+i);
-    addStyle(wb, sheet, style=styles$currency0, rows = crow+i, cols = 1:2, stack = TRUE, gridExpand = TRUE);
-  }
-  setColWidths(wb, sheet, cols = 1:50, widths = "auto", ignoreMergedCells = TRUE)
-
-
-  ################################################
-  # Print out cash flows
-  ################################################
-
-  # Age, death and survival probabilities
-  costCF = as.data.frame(contract$tarif$costValuesAsMatrix(setInsuranceValuesLabels(contract$values$cashFlowsCosts)));
-  ccol = 1;
-  crow = 4;
-  sheet = "Cash-Flows";
-  ccol = ccol + writeAgeQTable(wb, sheet, probs=qp, crow=crow, ccol=1, styles=styles);
-  ccol = ccol + writeValuesTable(wb, sheet, setInsuranceValuesLabels(contract$values$cashFlows),
-                                 crow=crow, ccol=ccol, tableName="CashFlows_Benefits", styles=styles,
-                                 caption="Leistungscashflows", withFilter=TRUE, valueStyle=styles$hide0) + 1;
-  ccol = ccol + writeValuesTable(wb, sheet, costCF,
-                                 crow=crow, ccol=ccol, tableName="CashFlows_Costs", styles=styles,
-                                 caption="Kostencashflows", withFilter=TRUE, valueStyle=styles$cost0) + 1;
-  setColWidths(wb, sheet, cols = 1:50, widths = "auto", ignoreMergedCells = TRUE)
-
-
-
-  openxlsx::saveWorkbook(wb, filename, overwrite = TRUE)
-
-
-  # #### Contract
-  # premiumPayments = PaymentTimeEnum("in advance"),
-  # benefitPayments = PaymentTimeEnum("in advance"),
-  # premiumFrequency = 1,
-  # benefitFrequency = 1, # Only for annuities!
-  # loadings = list(),    # Allow overriding the tariff-defined loadings (see the InsuranceTariff class for all possible names)
-  # premiumSum = 0,
-  #
-  #
-  # #### TARIF:
-  # tariffType = TariffTypeEnum("wholelife"), # possible values: annuity, wholelife, endowment, pureendowment, terme-fix
-  # premiumFrequencyOrder = 0,
-  # benefitFrequencyOrder = 0,
-  # widowFactor = 0,
-  # premiumRefund = 0,
-  # premiumRefundLoading = 0,  # Mindesttodesfallrisiko soll damit erreicht werden, z.B. 105% der einbezahlten Prämien
-  # costs = list(),
-  # benefitFrequencyLoading = list("1" = 0.0, "2" = 0.0, "4" = 0.0, "12" = 0.0), # TODO: Properly implement this
-  # premiumFrequencyLoading = list("1" = 0.0, "2" = 0.0, "4" = 0.0, "12" = 0.0), # TODO: Implement this
-  # loadings = list(    # Loadings can also be function(sumInsured, premiums)    # TODO: Add other possible arguments
-  #   "ongoingAlphaGrossPremium" = 0,    # Acquisition cost that increase the gross premium
-  #   "tax" = 0.04,                      # insurance tax, factor on each premium paid
-  #   "unitcosts" = 0,                   # annual unit cost for each policy (Stückkosten), absolute value
-  #   "security" = 0,                    # Additional security loading on all benefit payments, factor on all benefits
-  #   "noMedicalExam" = 0,               # Loading when no medicial exam is done, % of SumInsured
-  #   "noMedicalExamRelative" = 0,       # Loading when no medicial exam is done, % of gross premium
-  #   "sumRebate" = 0,                   # gross premium reduction for large premiums, % of SumInsured
-  #   "premiumRebate" = 0,               # gross premium reduction for large premiums, % of gross premium # TODO
-  #   "advanceProfitParticipation" = 0,                # Vorweggewinnbeteiligung (%-Satz der Bruttoprämie)
-  #   "advanceProfitParticipationInclUnitCost" = 0,    # Vorweggewinnbeteiligung (%-Satz der Prämie mit Zu-/Abschlägen, insbesondere nach Stückkosten)
-  #   "partnerRebate" = 0                # Partnerrabatt auf Prämie mit Zu-/Abschlägen, wenn mehr als 1 Vertrag gleichzeitig abgeschlossen wird, additiv mit advanceBonusInclUnitCost and premiumRebate
-  # ),
-
-}
diff --git a/R/plotValuationTables.R b/R/plotValuationTables.R
new file mode 100644
index 0000000000000000000000000000000000000000..e31917423d9f87f353afb1d2952d3bf18c88dca2
--- /dev/null
+++ b/R/plotValuationTables.R
@@ -0,0 +1,73 @@
+makeQxDataFrame = function(..., YOB=1972, Period=NA) {
+  data=list(...);
+  names(data) = lapply(data, function(t) t@name);
+  if (missing(Period)) {
+    cat("Year of birth: ", YOB, "\n");
+    data = lapply(data, function(t) cbind(x=ages(t), y=deathProbabilities(t, YOB=YOB)))
+  } else {
+    cat("Period: ", Period,"\n");
+    data = lapply(data, function(t) cbind(x=ages(t), y=periodDeathProbabilities(t, Period=Period)))
+  }
+
+  list.names = names(data)
+  lns <- sapply(data, nrow)
+  data <- as.data.frame(do.call("rbind", data))
+  data$group <- rep(list.names, lns)
+  data
+}
+
+#' Plot multiple valuation tables (life tables) in one plot
+#'
+#' \code{plotValuationTables} prints multiple life tables (objects of child classes of \code{valuationTable}) in one log-linear plot, with a legend showing the names of the tables.
+#'
+#' @param data First life table to be plotted. Either a \code{data.frame} generated by \code{makeQxDataFrame} or a \code{valuationTable} object
+#' @param ... Additional life tables to be plotted (if \code{data} is a \code{valuationTable} object)
+#' @param title The plot title
+#' @param legend.position The position of the legend (default is \code{c(0.9,0.1)})
+#' @param legend.key.width The keywith of the lines in the  legend (default is \code{unit(25,"mm")})
+#'
+#' @export
+plotValuationTables = function(data, ..., title = "", legend.position=c(0.9,0.1), legend.key.width = unit(25, "mm")) {
+  if (!is.data.frame(data)) {
+    data = makeQxDataFrame(data, ...);
+  }
+
+  pl = ggplot(data, aes(x = x, y = y, colour = data$group)) +
+    theme_bw() +
+    theme(
+      plot.title = element_text(size=18, face="bold"),
+      legend.title = element_text(size=14, face="bold.italic"),
+      # legend in bottom right corner of the plot
+      legend.justification=c(1,0), legend.position=legend.position,
+      # No box around legend entries
+      legend.key = element_blank(),
+      legend.key.width = legend.key.width,
+      legend.background = element_rect(colour="gray50", linetype="solid")
+    ) +
+    geom_line() +
+    scale_y_log10(
+      name=expression(paste("Sterbewahrscheinlichkeit  ", q[x])),
+      breaks = scales::trans_breaks('log10', function(x) 10^x),
+      labels = scales::trans_format('log10', scales::math_format(10^.x))
+      #minor_breaks = log(c(sapply(x, function(x) seq(0, x, x/10))), 10)
+    ) +
+    scale_x_continuous(
+      name="Alter",
+      #breaks = function (limits) scales::trans_breaks('', function(x) 10^x),
+      breaks = function (limits) seq(max(min(limits),0),max(limits),5),
+      minor_breaks = function (limits) seq(max(round(min(limits)),0),round(max(limits)),1),
+      #labels = scales::trans_format('log10', scales::math_format(10^.x))
+
+    ) +
+    annotation_logticks(sides="lr") +
+    xlab("Alter") + labs(colour="Sterbetafel");
+  if (title != "") {
+    pl = pl + ggtitle(title);
+  }
+  pl
+}
+#
+# plotValuationTables(mort.AT.census.1869.male, mort.AT.census.1869.female, mort.AT.census.2011.male, mort.AT.census.2011.female, AVOe2005R.male, AVOe2005R.female, YOB=1972,title="Vergleich österreichische Sterbetafeln, YOB=1972 (bei Generationentafeln)")
+#
+# plotValuationTables(mort.AT.census.2001.male, AVOe2005R.male, YOB=1972, title="Vergleich österreichische Sterbetafeln")
+#  plotValuationTables(getCohortTable(AVOe2005R.male, YOB=1972), getCohortTable(AVOe2005R.male, YOB=2016), title="Vergleich österreichische Sterbetafeln")
diff --git a/ValuationTables.Rproj b/ValuationTables.Rproj
index d603dfcc0ff2ec2ee017a886dc6d12974bb4fe17..d4713ef066eab16356af13db53b2339161985f8f 100644
--- a/ValuationTables.Rproj
+++ b/ValuationTables.Rproj
@@ -16,4 +16,6 @@ AutoAppendNewline: Yes
 StripTrailingWhitespace: Yes
 
 BuildType: Package
+PackageUseDevtools: Yes
 PackageInstallArgs: --no-multiarch
+PackageRoxygenize: rd,collate,namespace
diff --git a/man/ValuationTables-package.Rd b/man/ValuationTables-package.Rd
index d41e96bc2b2266b0f990218e5443cca423de709c..be62d48672aec5c1134353672fa49ab0395a85e0 100644
--- a/man/ValuationTables-package.Rd
+++ b/man/ValuationTables-package.Rd
@@ -1,40 +1,11 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/ValuationTables.R
+\docType{package}
 \name{ValuationTables-package}
-\alias{ValuationTables-package}
 \alias{ValuationTables}
-\docType{package}
-\title{
-What the package does (short line)
-~~ package title ~~
-}
+\alias{ValuationTables-package}
+\title{Provide life table classes for life insurance purposes}
 \description{
-More about what it does (maybe more than one line)
-~~ A concise (1-5 lines) description of the package ~~
-}
-\details{
-\tabular{ll}{
-Package: \tab ValuationTables\cr
-Type: \tab Package\cr
-Version: \tab 1.0\cr
-Date: \tab 2013-05-03\cr
-License: \tab What license is it under?\cr
+Provide life table classes for life insurance purposes
 }
-~~ An overview of how to use the package, including the most important functions ~~
-}
-\author{
-Who wrote it
 
-Maintainer: Who to complain to <yourfault@somewhere.net>
-~~ The author and/or maintainer of the package ~~
-}
-\references{
-~~ Literature or other references for background information ~~
-}
-~~ Optionally other standard keywords, one per line, from file KEYWORDS in the R documentation directory ~~
-\keyword{ package }
-\seealso{
-~~ Optional links to other man pages, e.g. ~~
-~~ \code{\link[<pkg>:<pkg>-package]{<pkg>}} ~~
-}
-\examples{
-~~ simple examples of the most important functions ~~
-}
diff --git a/man/plotValuationTables.Rd b/man/plotValuationTables.Rd
new file mode 100644
index 0000000000000000000000000000000000000000..2d855be3f3966bbab023de11be90918a830b0601
--- /dev/null
+++ b/man/plotValuationTables.Rd
@@ -0,0 +1,24 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/plotValuationTables.R
+\name{plotValuationTables}
+\alias{plotValuationTables}
+\title{Plot multiple valuation tables (life tables) in one plot}
+\usage{
+plotValuationTables(data, ..., title = "", legend.position = c(0.9, 0.1),
+  legend.key.width = unit(25, "mm"))
+}
+\arguments{
+\item{data}{First life table to be plotted. Either a \code{data.frame} generated by \code{makeQxDataFrame} or a \code{valuationTable} object}
+
+\item{...}{Additional life tables to be plotted (if \code{data} is a \code{valuationTable} object)}
+
+\item{title}{The plot title}
+
+\item{legend.position}{The position of the legend (default is \code{c(0.9,0.1)})}
+
+\item{legend.key.width}{The keywith of the lines in the  legend (default is \code{unit(25,"mm")})}
+}
+\description{
+\code{plotValuationTables} prints multiple life tables (objects of child classes of \code{valuationTable}) in one log-linear plot, with a legend showing the names of the tables.
+}
+
diff --git a/man/valuationTable-class.Rd b/man/valuationTable-class.Rd
new file mode 100644
index 0000000000000000000000000000000000000000..49e5016913d25d3c1d65393b0cb8823aa0911436
--- /dev/null
+++ b/man/valuationTable-class.Rd
@@ -0,0 +1,106 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/ValuationTables.R
+\docType{class}
+\name{valuationTable-class}
+\alias{baseTable,valuationTable-method}
+\alias{baseYear,valuationTable-method}
+\alias{getCohortTable,valuationTable-method}
+\alias{getPeriodTable,valuationTable-method}
+\alias{lifeTable,valuationTable-method}
+\alias{valuationTable}
+\alias{valuationTable-class}
+\title{Class valuationTable}
+\usage{
+getOmega(object)
+
+ages(object, ...)
+
+deathProbabilities(object, ..., YOB = 1975)
+
+periodDeathProbabilities(object, ...)
+
+lifeTable(object, ...)
+
+\S4method{lifeTable}{valuationTable}(object, ...)
+
+baseYear(object, ...)
+
+\S4method{baseYear}{valuationTable}(object, ...)
+
+baseTable(object, ...)
+
+\S4method{baseTable}{valuationTable}(object, ...)
+
+getPeriodTable(object, Period, ...)
+
+\S4method{getPeriodTable}{valuationTable}(object, Period, ...)
+
+getCohortTable(object, YOB, ...)
+
+\S4method{getCohortTable}{valuationTable}(object, YOB, ...)
+}
+\arguments{
+\item{...}{Parameters to be handed to the \code{deathProbabilities} method of the life table}
+
+\item{YOB}{The birth year for which the death probabilities should be calculated}
+
+\item{Period}{The observation year for which the period death probabilities should be determined}
+
+\item{...}{Parameters to be handed to the \code{deathProbabilities} method of the life table}
+
+\item{Period}{The observation year, for which the death probabilities should be determined}
+
+\item{Period}{The observation year, for which the death probabilities should be determined}
+
+\item{YOB}{The birth year for which the life table should be calculated}
+
+\item{YOB}{The birth year for which the life table should be calculated}
+}
+\description{
+Class \code{valuationTable} is the (virtual) base class for all valuation
+tables. It contains the name and some general values applying to all
+types of tables, but does not contain any data itself. Use a child class
+to create actual valuation tables.
+
+Return the maximum age of the life table
+
+Return the defined ages of the life table
+
+Return the (cohort) death probabilities of the life table given the birth year (if needed)
+
+Return the (period) death probabilities of the life table for a given observation year
+
+Return the lifetable object (package lifecontingencies) for the cohort life table
+
+Return the lifetable object (package lifecontingencies) for the cohort life table
+
+Return the base year of the life table
+
+Return the base year of the life table
+
+Return the base table of the life table
+
+Return the base table of the life table
+
+Return the period life table as a \code{valuationTable_period} object
+
+Return the period life table as a \code{valuationTable_period} object
+
+Return the cohort life table as a \code{valuationTable_period} object
+
+Return the cohort life table as a \code{valuationTable_period} object
+}
+\section{Slots}{
+
+\describe{
+\item{\code{name}}{The human-readable name of the valuation table}
+
+\item{\code{baseYear}}{The base year of the valuation table (e.g. for tables with trend projection)}
+
+\item{\code{modification}}{A function that will be called with the final death probabilities
+to give the user a way to modify the final probabilities}
+
+\item{\code{loading}}{Additional security loading on the resulting table (single numeric
+value, e.g. 0.05 adds 5% security margin to the probabilities)}
+}}
+
diff --git a/man/valuationTable_ageShift-class.Rd b/man/valuationTable_ageShift-class.Rd
new file mode 100644
index 0000000000000000000000000000000000000000..6e7857a67d231f1636939a11fb7144700f306365
--- /dev/null
+++ b/man/valuationTable_ageShift-class.Rd
@@ -0,0 +1,47 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/ValuationTables.R
+\docType{class}
+\name{valuationTable_ageShift-class}
+\alias{ageShift,valuationTable_ageShift-method}
+\alias{deathProbabilities,valuationTable_ageShift-method}
+\alias{periodDeathProbabilities,valuationTable_ageShift-method}
+\alias{valuationTable_ageShift}
+\alias{valuationTable_ageShift-class}
+\title{A cohort life table, obtained by age-shifting from a given base table (death probabilities}
+\usage{
+ageShift(object, YOB = 1975, ...)
+
+\S4method{ageShift}{valuationTable_ageShift}(object, YOB = 1975, ...)
+
+\S4method{deathProbabilities}{valuationTable_ageShift}(object, ...,
+  YOB = 1975)
+
+\S4method{periodDeathProbabilities}{valuationTable_ageShift}(object, ...,
+  Period = 1975)
+}
+\arguments{
+\item{YOB}{The birth year for which the age shift should be determined.}
+
+\item{Period}{The observation year for which the period death probabilities should be determined}
+
+\item{YOB}{The birth year for which the age shift should be determined.}
+
+\item{YOB}{The birth year for which the death probabilities should be calculated}
+}
+\description{
+A cohort life table, obtained by age-shifting from a given base table (death probabilities
+
+Return the age shift of the age-shifted life table given the birth year
+
+Return the age shift of the age-shifted life table given the birth year
+
+Return the (cohort) death probabilities of the life table given the birth year (if needed)
+
+Return the (period) death probabilities of the life table for a given observation year
+}
+\section{Slots}{
+
+\describe{
+\item{\code{ageShifts}}{A \code{data.frame} with columns \code{YOB} and \code{shifts} giving the age shifts for each birth year}
+}}
+
diff --git a/man/valuationTable_improvementFactors-class.Rd b/man/valuationTable_improvementFactors-class.Rd
new file mode 100644
index 0000000000000000000000000000000000000000..6dd7d591d66c5d6973264fe2d3d211ed37ede511
--- /dev/null
+++ b/man/valuationTable_improvementFactors-class.Rd
@@ -0,0 +1,38 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/ValuationTables.R
+\docType{class}
+\name{valuationTable_improvementFactors-class}
+\alias{deathProbabilities,valuationTable_improvementFactors-method}
+\alias{periodDeathProbabilities,valuationTable_improvementFactors-method}
+\alias{valuationTable_improvementFactors}
+\alias{valuationTable_improvementFactors-class}
+\title{A cohort life table, obtained by an improvment factor projection
+from a given base table (PODs for a given observation year).}
+\usage{
+\S4method{deathProbabilities}{valuationTable_improvementFactors}(object, ...,
+  YOB = 1975)
+
+\S4method{periodDeathProbabilities}{valuationTable_improvementFactors}(object,
+  ..., Period = 1975)
+}
+\arguments{
+\item{YOB}{The birth year for which the death probabilities should be calculated}
+
+\item{Period}{The observation year for which the period death probabilities should be determined}
+}
+\description{
+A cohort life table, obtained by an improvment factor projection
+from a given base table (PODs for a given observation year).
+
+Return the (cohort) death probabilities of the life table given the birth year (if needed)
+
+Return the (period) death probabilities of the life table for a given observation year
+}
+\section{Slots}{
+
+\describe{
+\item{\code{baseYear}}{The base year for the improvements (\code{baseTable} describes the death probabilities in this year)}
+
+\item{\code{improvement}}{Yearly improvement factors per age}
+}}
+
diff --git a/man/valuationTable_joined-class.Rd b/man/valuationTable_joined-class.Rd
new file mode 100644
index 0000000000000000000000000000000000000000..ccfc977b0a306eba9f21d2d63114c8db266ced1c
--- /dev/null
+++ b/man/valuationTable_joined-class.Rd
@@ -0,0 +1,37 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/ValuationTables.R
+\docType{class}
+\name{valuationTable_joined-class}
+\alias{ages,valuationTable_joined-method}
+\alias{getOmega,valuationTable_joined-method}
+\alias{valuationTable_joined}
+\alias{valuationTable_joined-class}
+\title{A cohort life table obtained by joining two cohort life tables, each of which
+applies only to certain observation years (e.g. for the past use the observed
+PODs, and project them to the future with the trend projection)}
+\usage{
+\S4method{getOmega}{valuationTable_joined}(object)
+
+\S4method{ages}{valuationTable_joined}(object, ...)
+}
+\description{
+A cohort life table obtained by joining two cohort life tables, each of which
+applies only to certain observation years (e.g. for the past use the observed
+PODs, and project them to the future with the trend projection)
+
+Return the maximum age of the joined life table
+
+Return the defined ages of the life table
+}
+\section{Slots}{
+
+\describe{
+\item{\code{table1}}{The first \code{valuationTable}, valid for years given in \code{yearRange1}}
+
+\item{\code{yearRange1}}{The years, for which \code{table1} describes the death probabilities}
+
+\item{\code{table2}}{The second \code{valuationTable}, valid for years given in \code{yearRange2}}
+
+\item{\code{yearRange2}}{The years, for which \code{table2} describes the death probabilities}
+}}
+
diff --git a/man/valuationTable_mixed-class.Rd b/man/valuationTable_mixed-class.Rd
new file mode 100644
index 0000000000000000000000000000000000000000..208f3bb7e453a2a0d3541fe1d6318b7448502246
--- /dev/null
+++ b/man/valuationTable_mixed-class.Rd
@@ -0,0 +1,56 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/ValuationTables.R
+\docType{class}
+\name{valuationTable_mixed-class}
+\alias{ages,valuationTable_mixed-method}
+\alias{baseYear,valuationTable_mixed-method}
+\alias{deathProbabilities,valuationTable_mixed-method}
+\alias{getOmega,valuationTable_mixed-method}
+\alias{periodDeathProbabilities,valuationTable_mixed-method}
+\alias{valuationTable_mixed}
+\alias{valuationTable_mixed-class}
+\title{A cohort life table obtained by mixing two life tables with the given weights}
+\usage{
+\S4method{getOmega}{valuationTable_mixed}(object)
+
+\S4method{ages}{valuationTable_mixed}(object, ...)
+
+\S4method{deathProbabilities}{valuationTable_mixed}(object, ..., YOB = 1975)
+
+\S4method{periodDeathProbabilities}{valuationTable_mixed}(object, ...,
+  Period = 1975)
+
+\S4method{baseYear}{valuationTable_mixed}(object, ...)
+}
+\arguments{
+\item{YOB}{The birth year for which the death probabilities should be calculated}
+
+\item{Period}{The observation year for which the period death probabilities should be determined}
+}
+\description{
+A cohort life table obtained by mixing two life tables with the given weights
+
+Return the maximum age of the mixed life table
+
+Return the defined ages of the life table
+
+Return the (cohort) death probabilities of the life table given the birth year (if needed)
+
+Return the (period) death probabilities of the life table for a given observation year
+
+Return the base year of the life table
+}
+\section{Slots}{
+
+\describe{
+\item{\code{table1}}{The first \code{valuationTable}}
+
+\item{\code{table2}}{The second \code{valuationTable}}
+
+\item{\code{weight1}}{The weight of the first valuation table}
+
+\item{\code{weight2}}{The weight of the second valuation table}
+
+\item{\code{loading}}{Additional security loading}
+}}
+
diff --git a/man/valuationTable_observed-class.Rd b/man/valuationTable_observed-class.Rd
new file mode 100644
index 0000000000000000000000000000000000000000..14b5261a67327b760f02670146a0f01bd3443fff
--- /dev/null
+++ b/man/valuationTable_observed-class.Rd
@@ -0,0 +1,18 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/ValuationTables.R
+\docType{class}
+\name{valuationTable_observed-class}
+\alias{valuationTable_observed}
+\alias{valuationTable_observed-class}
+\title{A cohort life table described by actual observations (data frame of PODs
+per year and age)}
+\description{
+A cohort life table described by actual observations (data frame of PODs
+per year and age)
+}
+\section{Slots}{
+
+\describe{
+\item{\code{data}}{The observations}
+}}
+
diff --git a/man/valuationTable_period-class.Rd b/man/valuationTable_period-class.Rd
new file mode 100644
index 0000000000000000000000000000000000000000..401788b4ef0f1b1298c6b8e112f08d0d45d923b4
--- /dev/null
+++ b/man/valuationTable_period-class.Rd
@@ -0,0 +1,51 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/ValuationTables.R
+\docType{class}
+\name{valuationTable_period-class}
+\alias{ages,valuationTable_period-method}
+\alias{baseTable,valuationTable_period-method}
+\alias{deathProbabilities,valuationTable_period-method}
+\alias{getOmega,valuationTable_period-method}
+\alias{periodDeathProbabilities,valuationTable_period-method}
+\alias{valuationTable_period}
+\alias{valuationTable_period-class}
+\title{A period life table, giving death probabilities for each age, up to
+maximum age omega. Optionally apply selection factors to the probabilities}
+\usage{
+\S4method{getOmega}{valuationTable_period}(object)
+
+\S4method{ages}{valuationTable_period}(object, ...)
+
+\S4method{deathProbabilities}{valuationTable_period}(object, ..., YOB = 1975)
+
+\S4method{periodDeathProbabilities}{valuationTable_period}(object, ...)
+
+\S4method{baseTable}{valuationTable_period}(object, ...)
+}
+\arguments{
+\item{YOB}{The birth year for which the death probabilities should be calculated}
+
+\item{Period}{The observation year for which the period death probabilities should be determined}
+}
+\description{
+A period life table, giving death probabilities for each age, up to
+maximum age omega. Optionally apply selection factors to the probabilities
+
+Return the maximum age of the period life table
+
+Return the defined ages of the life table
+
+Return the (cohort) death probabilities of the life table given the birth year (if needed)
+
+Return the (period) death probabilities of the life table for a given observation year
+
+Return the base table of the life table
+}
+\section{Slots}{
+
+\describe{
+\item{\code{ages}}{The ages corresponding to the entries of the deathProbs}
+
+\item{\code{deathProbs}}{The one-year death probabilities for the ages}
+}}
+
diff --git a/man/valuationTable_trendProjection-class.Rd b/man/valuationTable_trendProjection-class.Rd
new file mode 100644
index 0000000000000000000000000000000000000000..48bf30db88285d4e37a5cc9ed18ba68c30990c89
--- /dev/null
+++ b/man/valuationTable_trendProjection-class.Rd
@@ -0,0 +1,57 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/ValuationTables.R
+\docType{class}
+\name{valuationTable_trendProjection-class}
+\alias{deathProbabilities,valuationTable_trendProjection-method}
+\alias{periodDeathProbabilities,valuationTable_trendProjection-method}
+\alias{undampenTrend,valuationTable_trendProjection-method}
+\alias{valuationTable_trendProjection}
+\alias{valuationTable_trendProjection-class}
+\title{A cohort life table, obtained by a trend projection from a given base table
+(PODs for a given observation year). Typically, the trend is obtained by
+the Lee-Carter method or some other trend estimation.
+The dampingFunction can be used to modify the cumulative years (e.g. G(tau+x) instead of tau+x)
+If trend2 is given, the G(tau+x) gives the weight of the first trend, 1-G(tau+x) the weight of the second trend}
+\usage{
+\S4method{deathProbabilities}{valuationTable_trendProjection}(object, ...,
+  YOB = 1975)
+
+\S4method{periodDeathProbabilities}{valuationTable_trendProjection}(object, ...,
+  Period = 1975)
+
+undampenTrend(object)
+
+\S4method{undampenTrend}{valuationTable_trendProjection}(object)
+}
+\arguments{
+\item{YOB}{The birth year for which the death probabilities should be calculated}
+
+\item{Period}{The observation year for which the period death probabilities should be determined}
+}
+\description{
+A cohort life table, obtained by a trend projection from a given base table
+(PODs for a given observation year). Typically, the trend is obtained by
+the Lee-Carter method or some other trend estimation.
+The dampingFunction can be used to modify the cumulative years (e.g. G(tau+x) instead of tau+x)
+If trend2 is given, the G(tau+x) gives the weight of the first trend, 1-G(tau+x) the weight of the second trend
+
+Return the (cohort) death probabilities of the life table given the birth year (if needed)
+
+Return the (period) death probabilities of the life table for a given observation year
+
+Return a \code{valuationTable_trensProjection} object with the trend damping removed.
+
+Return a \code{valuationTable_trensProjection} object with the trend damping removed.
+}
+\section{Slots}{
+
+\describe{
+\item{\code{baseYear}}{The base year of the trend projection (\code{baseTable} describes the death probabilities in this year)}
+
+\item{\code{trend}}{The yearly improvements of the log-death probabilities (per age)}
+
+\item{\code{dampingFunction}}{A possible damping of the trend. This is a function \code{damping(delta_years)} that gets a vector of years from the baseYear and should return the dampened values.}
+
+\item{\code{trend2}}{The alternate trend. If given, the damping function interpolates between \code{trend} and \code{trend2}, otherwise the dumping function simply modifies the coefficients of \code{trend}.}
+}}
+