1## Copyright (C) 2009 Esteban Cervetto <estebancster@gmail.com>
2##
3## Octave is free software; you can redistribute it and/or modify it
4## under the terms of the GNU General Public License as published by
5## the Free Software Foundation; either version 3 of the License, or (at
6## your option) any later version.
7##
8## Octave is distributed in the hope that it will be useful, but
9## WITHOUT ANY WARRANTY; without even the implied warranty of
10## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11## General Public License for more details.
12##
13## You should have received a copy of the GNU General Public License
14## along with Octave; see the file COPYING.  If not, see
15## <http://www.gnu.org/licenses/>.
16
17## -*- texinfo -*-
18## @deftypefn {Function File} {@var{quotas} =} quotald (@var{s})
19## Calculate the cumulative quotas by the Loss Development (Chainladder) method.
20##
21## @var{s} is a mxn matrix that contains the run-off triangle, where m is the number of accident-years
22## and n is the number of periods to final development. @var{s} may contain u = m-n complete years.
23## The value @var{s}(i,k), 1<=i<=m, 0<=k<=n-1 represents the cumulative losses from accident-period i
24## settled with a delay of at most k years.
25## The values @var{s}(i,k) with i + k > m must be zero because is future time.
26##
27## The LD method asumes that exists a development pattern on the individual factors.
28## This means that the identity
29## @group
30## @example
31##             E[S(i,k) ]
32## LDI(k) =   -------------
33##            E[S(i,k-1) ]
34## @end example
35## @end group
36## holds for all k = {0,...,n-1} and for all i = {1,...,m}.
37##
38## @var{quotas} returns a row vector with the cumulative quotas. The transformation
39## from individual factors to cumulative quotas is:
40## @group
41## @example
42##                    l=n-1    1
43## @var{quotas}(k) =  II    -------
44##                    l=k+1    LDI(l)
45## @end example
46## @end group
47##
48## @seealso {bferguson, ultimateld, quotapanning, quotaad, quotamack}
49## @end deftypefn
50
51## Author: Act. Esteban Cervetto ARG <estebancster@gmail.com>
52##
53## Maintainer: Act. Esteban Cervetto ARG <estebancster@gmail.com>
54##
55## Created: jul-2009
56##
57## Version: 1.1.0
58##
59## Keywords: actuarial reserves insurance bornhuetter ferguson chainladder
60
61function quotas = quotald(S)
62
63[m,n] = size (S);           #triangle with m years (i=1,2,u,...u+1,u+2,....m) and n periods (k=0,1,2,...n-1)
64u = m - n;                                     #rows of the upper square
65S = fliplr(triu(fliplr(S),-u));                   #ensure S is triangular
66
67# calculate the triangle of individual development factors (LDI).
68LDI = [ones(m,1), S(:,2:n)./S(:,1:n-1)];
69LDI = fliplr(triu(fliplr(LDI),-u));
70LDI (m,1) = 0;                     #last row element without partner
71
72# weights
73W =  fliplr(triu(fliplr(S),1-u));  #get T values to use
74W =  shift (W,1,2);                #redim k = k-1,
75W = porcentual(W,1);
76
77#individual development factors (LDI) or Chainladder factors
78LDI_CL  = diag(LDI' * W)';                 #weighted product
79quotas = 1./cumprod(fliplr(LDI_CL));       #calcs cumulated quota
80quotas (n) = 1;                            #last value is 1
81quotas = fliplr(shift(quotas,1));
82
83end
84