Diff of /inst/quotald.m [88c2a4] .. [677636]  Maximize  Restore

Switch to unified view

a/inst/quotald.m b/inst/quotald.m
...
...
47
## @seealso {bferguson, ultimateld, quotapanning, quotaad, quotamack}
47
## @seealso {bferguson, ultimateld, quotapanning, quotaad, quotamack}
48
## @end deftypefn
48
## @end deftypefn
49
49
50
function quotas = quotald(S)
50
function quotas = quotald(S)
51
51
52
[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)
52
  [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)
53
u = m - n;                                     #rows of the upper square
53
  u = m - n;                                     #rows of the upper square
54
S = fliplr(triu(fliplr(S),-u));                   #ensure S is triangular  
54
  S = fliplr(triu(fliplr(S),-u));                   #ensure S is triangular
55
55
56
# calculate the triangle of individual development factors (LDI).
56
  # calculate the triangle of individual development factors (LDI)
57
LDI = [ones(m,1), S(:,2:n)./S(:,1:n-1)];
57
  LDI = [ones(m,1), S(:,2:n)./S(:,1:n-1)];
58
LDI = fliplr(triu(fliplr(LDI),-u));
58
  LDI = fliplr(triu(fliplr(LDI),-u));
59
LDI (m,1) = 0;                     #last row element without partner
59
  LDI (m,1) = 0;                     #last row element without partner
60
60
61
# weights
61
  # weights
62
W =  fliplr(triu(fliplr(S),1-u));  #get T values to use
62
  W =  fliplr(triu(fliplr(S),1-u));  #get T values to use
63
W =  shift (W,1,2);                #redim k = k-1, 
63
  W =  shift (W,1,2);                #redim k = k-1,
64
W = porcentual(W,1);
64
  W = porcentual(W,1);
65
65
66
#individual development factors (LDI) or Chainladder factors
66
  #individual development factors (LDI) or Chainladder factors
67
LDI_CL  = diag(LDI' * W)';                 #weighted product
67
  LDI_CL = diag(LDI' * W)';                 #weighted product
68
quotas = 1./cumprod(fliplr(LDI_CL));       #calcs cumulated quota
68
  quotas = 1./cumprod(fliplr(LDI_CL));       #calcs cumulated quota
69
quotas (n) = 1;                            #last value is 1
69
  quotas (n) = 1;                            #last value is 1
70
quotas = fliplr(shift(quotas,1));
70
  quotas = fliplr(shift(quotas,1));
71
71
72
end
72
end