Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Diff of /inst/ultimatecc.m [000000] .. [d39d4b] Maximize Restore

  Switch to unified view

a b/inst/ultimatecc.m
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{ultimate} =} ultimatecc (@var{s},@var{v},@var{quotas})
19
## Calculate the ultimate values by the Cape Cod 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
## @var{v} is an mx1 vector of known volume measures (like premiums or the number of contracts).
27
## @var{quotas} is an 1xn vector of cumulatives quotas. 
28
## 
29
## The Cape Cod method asumes that exists a development pattern on the cumulative quotas (Q).
30
## This means that the identity 
31
## @group
32
## @example
33
##          E[S(i,k) ]
34
## Q(k) = -------------
35
##          E[S(i,n) ]
36
## @end example
37
## @end group
38
## holds for all k = {0,...,n-1} and for all i = {1,...,m}.
39
## 
40
## Also, the Cape Cod Method asumes the existence of a value "H" in a way that satisfy
41
## @group
42
## @example
43
##        S(i,n)
44
## H = E [------]
45
##         V(i)
46
## @end example
47
## @end group
48
## holds for all i = {1,...,m}.
49
## H is called the Cape Cod loss ratio and it can be prove this value is
50
## @group
51
## @example
52
##                    j=n-1        
53
##                     E   S(j,n-j)
54
##                    j=0            
55
## @var{quotas}(k) =  ----------------
56
##                   j=n-1            
57
##                     E   Q(n-j)V(j)
58
##                    j=0             
59
## @end example
60
## @end group
61
##
62
## @var{ultimate} returns a row column with the ultimate values. Their values are:
63
## @group
64
## @example
65
## @var{ultimate}(i) = H * @var{v}(i)
66
## @end example
67
## @end group
68
##
69
## @seealso {bferguson}
70
## @end deftypefn
71
72
## Author: Act. Esteban Cervetto ARG <estebancster@gmail.com>
73
##
74
## Maintainer: Act. Esteban Cervetto ARG <estebancster@gmail.com>
75
##
76
## Created: jul-2009
77
##
78
## Version: 1.1.0 
79
##
80
## Keywords: actuarial reserves insurance bornhuetter ferguson chainladder
81
82
function ultimate = ultimatecc (S,V,quotas)
83
84
[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)
85
u = m - n;                                     #rows of the upper square
86
S = fliplr(triu(fliplr(S),-u));                   #ensure S is triangular  
87
88
if (size(V) ~= [m,1])
89
 usage(strcat("volume V must be of size [",num2str(m),",1]" ));
90
end  
91
if (size(quotas) ~= [1,n])
92
 usage("quotas must be of dimension [1,n]");
93
end  
94
95
# CapeCods K   K = S(i+k = n)/quotas*V
96
97
if (u==0)
98
K = sum(diag(fliplr(S))')/ (fliplr(quotas)*V);
99
else
100
K = sum([diag(fliplr(S),-u)' S(1:u,n)])/ (fliplr([quotas ones(u)])*V);
101
end
102
103
#ultimate value
104
ultimate = K * V;
105
106
end