From ad177af03614a2ca8ecd4a27ee204d12692f06f0 Mon Sep 17 00:00:00 2001
From: Reinhold Kainhofer <reinhold@kainhofer.com>
Date: Mon, 2 May 2016 22:10:41 +0200
Subject: [PATCH] Add function to merge two matrices/data.frames, where one
 goes from time 0 to t-1, and the other from time t to the end in the
 resulting matrix/data.frame.

This is used later on when contract changes are done, because everything up to t-1 is from the old values, everything start at t is using the new contract data.
---
 R/HelperFunctions.R | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/R/HelperFunctions.R b/R/HelperFunctions.R
index c0c80f5..e43c2f6 100644
--- a/R/HelperFunctions.R
+++ b/R/HelperFunctions.R
@@ -1,3 +1,11 @@
+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...
-- 
GitLab