Repository navigation
Description
Description
MackChainladder gives a prediction error for each index row, but nothing in chainladder gives one for the sum of several rows. Adding the rows in quadrature treats the lines as independent. Adding the standard errors treats them as perfectly correlated. Running Mack on the summed triangle changes the reserve itself. Braun 2004 extends Mack's recursions to several triangles whose development factors correlate within each development period. His worked example uses the data in cl.load_sample("liab"), and he prints every intermediate value.
Is your feature request aligned with the scope of the package?
- Yes, absolutely!
- No, but it's still worth discussing.
- N/A (this request is not a codebase enhancement).
Describe the solution you'd like, or your current workaround.
A fitted MackChainladder on a triangle with several index rows could expose a portfolio prediction error next to total_mack_std_err_. A standalone function that takes the fitted model would also work. Braun needs one extra estimate per development period and pair of rows. His equation 26 gives it, and the rest reuses the sigma, factor and projection arrays that Mack already builds. I can follow whatever shape you prefer.
Do you have any additional supporting notes?
Braun, C. 2004. The Prediction Error of the Chain Ladder Method Applied to Correlated Run-off Triangles. ASTIN Bulletin 34(2), 399-423. https://doi.org/10.2143/AST.34.2.505150
His Tables 1 and 2 match liab cell for cell. liab labels the origins 2000 to 2013 where Braun uses 1987 to 2000. A short numpy prototype of his recursions reproduces his portfolio figure on liab. The same prototype also runs on clrd paid losses summed by line of business.
| Braun 2004 | chainladder or prototype | |
|---|---|---|
| liab IBNR, General and Auto | 6,155,261 and 2,063,612 | 6,155,261 and 2,063,612 |
| liab Mack prediction error, General and Auto | 427,289 and 162,872 | 427,289 and 162,872 |
| liab portfolio with no correlation | 457,278 | 457,278 |
| liab portfolio, Braun | 509,075 | 509,075 |
| clrd six lines, no correlation | 752,644 | |
| clrd six lines, Braun | 886,262 | |
| clrd six lines, perfect correlation | 1,290,952 |
These figures need Development(sigma_interpolation="mack"). The default log-linear fill gives 428,317 and 163,151 for the two liab lines. Braun prints no correlation for the last development period, and setting it to zero reproduces his tables. The prototype handles more than two triangles by summing Braun's pairwise terms.
chainladder values
import numpy as np
import chainladder as cl
liab = cl.load_sample("liab")
mk = cl.MackChainladder().fit(cl.Development(sigma_interpolation="mack").fit_transform(liab))
print("liab IBNR", mk.ibnr_.sum("origin").values.ravel().round(0))
se = mk.total_mack_std_err_.values.ravel()
print("liab Mack se", se.round(0))
print("liab independent", np.sqrt((se ** 2).sum()).round(0))
mk = cl.MackChainladder().fit(liab)
print("liab Mack se, default fill", mk.total_mack_std_err_.values.ravel().round(0))
clrd = cl.load_sample("clrd").groupby("LOB").sum()["CumPaidLoss"]
mk = cl.MackChainladder().fit(cl.Development(sigma_interpolation="mack").fit_transform(clrd))
se = mk.total_mack_std_err_.values.ravel()
print("clrd LOB", list(clrd.index.iloc[:, 0]))
print("clrd Mack se", se.round(0))
print("clrd independent", np.sqrt((se ** 2).sum()).round(0))
print("clrd comonotonic", se.sum().round(0))Braun prototype
import numpy as np
import chainladder as cl
def params(X):
n = X.shape[0]
f = np.zeros(n - 1)
s2 = np.zeros(n - 1)
for t in range(n - 1):
r = np.arange(n - 1 - t)
f[t] = X[r, t + 1].sum() / X[r, t].sum()
if len(r) > 1:
s2[t] = (X[r, t] * (X[r, t + 1] / X[r, t] - f[t]) ** 2).sum() / (len(r) - 1)
s2[-1] = min(s2[-2] ** 2 / s2[-3], s2[-3])
return f, s2
def rho_pair(C, D, f, g):
n = C.shape[0]
rho = np.zeros(n - 1)
for t in range(n - 2):
r = np.arange(n - 1 - t)
sq = np.sqrt(C[r, t] * D[r, t])
w2 = sq.sum() ** 2 / (C[r, t].sum() * D[r, t].sum())
e = (C[r, t + 1] / C[r, t] - f[t]) * (D[r, t + 1] / D[r, t] - g[t])
rho[t] = (sq * e).sum() / (len(r) - 2 + w2)
return rho
def project(X, f):
n = X.shape[0]
H = X.copy()
for i in range(n):
for t in range(n - 1 - i, n - 1):
H[i, t + 1] = H[i, t] * f[t]
return H
def pair_msep(C, D, f, g, rh):
n = C.shape[0]
Ch = project(C, f)
Dh = project(D, g)
cs = np.array([C[: n - 1 - t, t].sum() for t in range(n - 1)])
ds = np.array([D[: n - 1 - t, t].sum() for t in range(n - 1)])
sq = np.array([np.sqrt(C[: n - 1 - t, t] * D[: n - 1 - t, t]).sum() for t in range(n - 1)])
cx = rh * sq / (cs * ds)
rnd = np.zeros(n)
est = np.zeros((n, n))
for i in range(n):
for t in range(n - 1 - i, n - 1):
rnd[i] = rnd[i] * f[t] * g[t] + np.sqrt(Ch[i, t] * Dh[i, t]) * rh[t]
for j in range(n):
for t in range(n - 1 - min(i, j), n - 1):
est[i, j] = est[i, j] * f[t] * g[t] + Ch[i, t] * Dh[j, t] * cx[t]
return rnd.sum() + est.sum()
def braun(tris):
P = [params(X) for X in tris]
N = len(tris)
M = np.zeros((N, N))
for a in range(N):
for b in range(a, N):
rh = P[a][1] if a == b else rho_pair(tris[a], tris[b], P[a][0], P[b][0])
M[a, b] = M[b, a] = pair_msep(tris[a], tris[b], P[a][0], P[b][0], rh)
return M
liab = cl.load_sample("liab")
M = braun([liab.loc[k].values[0, 0].astype(float) for k in ("GeneralLiab", "AutoLiab")])
print("liab Braun portfolio", np.sqrt(M.sum()).round(0))
clrd = cl.load_sample("clrd").groupby("LOB").sum()["CumPaidLoss"]
M = braun([clrd.values[i, 0].astype(float) for i in range(clrd.shape[0])])
print("clrd Braun portfolio", np.sqrt(M.sum()).round(0))#412 asked for portfolio Mack support in 2023 and closed with no comments.
Would you be willing to contribute this ticket?
- Yes, absolutely!
- Yes, but I would like some help.
- No.
(This issue was written with Árbol, an AI assistant, under my direction.)
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Scope
Effort
Projects
- StatusShow more project fieldsNot Ready
Activity