Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[677636]: inst / quotamack.m Maximize Restore History

Download this file

quotamack.m    129 lines (116 with data), 4.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
## Copyright (C) 2009 Esteban Cervetto <estebancster@gmail.com>
##
## Octave is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or (at
## your option) any later version.
##
## Octave is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING. If not, see
## <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} {@var{quotas} =} quotaad (@var{s}, @var{v})
## Calculate the cumulative quotas by the Mack method.
##
## @var{s} is a mxn matrix that contains the run-off triangle, where m is the number of accident-years
## and n is the number of periods to final development. @var{s} may contain u = m-n complete years.
## The value @var{s}(i,k), 1<=i<=m, 0<=k<=n-1 represents the cumulative losses from accident-period i
## settled with a delay of at most k years.
## The values @var{s}(i,k) with i + k > m must be zero because is future time.
## @var{v} is a mx1 vector of known volume measures (like premiums or the number of contracts).
##
## The Mack method asumes that exists a vector @var{v} and a vector P(i) 1<=i<=m of parameters
## such that holds for all i = @{1, @dots{}, m@} the next identity:
##
## @verbatim
## ultimate(i) = V(i)*P(i)
## @end verbatim
##
## where
##
## @verbatim
## l=n-1
## P(i)= O_mack(i) * E IRL_Mack(l)
## l=0
## @end verbatim
##
## ,
##
## @verbatim
## l=n-k-1
## E Z(j,k)
## j=0
## IRL_Mack(i) = ---------------------
## l=n-k-1
## E V(i)*O_Mack(l)
## l=0
## @end verbatim
##
## and
##
## @verbatim
## l=n-i-1
## E Z(i,l)
## l=0
## O_Mack(i) = ------------------
## l=n-1
## E V(i)*IRL(l) (see IRL definition in quotaad function)
## l=0
## @end verbatim
##
## Z represents the incremental losses; then losses satisfy
## Z(k) = (S(k) - S(k-1) ),Z(0) = S(0) for all i = @{1, @dots{}, m@}.
##
## @var{quotas} returns a row vector with the cumulative quotas. The formula is:
##
## @verbatim
## l=k
## E IRL_Mack(l)
## l=0
## quotas(k) = ------------------
## l=n-1
## E IRL_Mack(l)
## l=0
## @end verbatim
##
## @seealso {bferguson, quotald, quotapanning, quotaad}
## @end deftypefn
function [quotas] = quotamack (S, V)
[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)
u = m - n; #rows of the upper square
S = fliplr(triu(fliplr(S),-u)); #ensure S is triangular
if (size(V) ~= [m,1])
error(strcat("volume V must be of size [",num2str(m),",1]" ));
end
# Z triangle
Z = [S(:,1), S(:,2:n)-S(:,1:n-1)];
Z = fliplr(triu(fliplr(Z),-u)); #clean Z
# calculate empirical individual loss ratios
a = repmat (V,1,n);
LRI = Z ./ a;
# weights V(i)/sum(1,n-k,V(i))
num =fliplr(triu(fliplr(a),-u)); #numerator and clean low triangle
den = repmat(sum(num),m,1); #denominator
den = fliplr(triu(fliplr(den),-u)); #clean low triangle
W = num./den; #divide by
W = fliplr(triu(fliplr(W),-u));
# incremental Loss Ratios AD
LRI_AD = diag(LRI' * W)'; #weighted product
if (u==0)
b = (diag(fliplr(S),-u) ./ flipud(cumsum(LRI_AD)') ) ./ V;
else
b = ([S(1:u,n); diag(fliplr(S),-u)] ./ [sum(LRI_AD)*ones(1,u);flipud(cumsum(LRI_AD)')] ) ./ V;
end
sZ = sum (Z); #sum of Z
sb = repmat(b,1,n);
sb = fliplr(triu(fliplr(sb),-u));
sV = repmat(V,1,n);
sV = fliplr(triu(fliplr(sV),-u));
LRI_Mack = sZ ./ (diag(sb'*sV))';
quotas = cumsum(porcentual(LRI_Mack)); #calculate cumulated quota
end