-
Notifications
You must be signed in to change notification settings - Fork 103
docs: add tail estimator doctest examples #801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,29 @@ class TailBondy(TailBase): | |
| -------- | ||
| TailCurve | ||
|
|
||
| Examples | ||
| -------- | ||
| Start the Bondy fit later when earlier link ratios are too volatile for the | ||
| selected tail. The fitted exponent changes because fewer ages enter the | ||
| tail regression. | ||
|
|
||
| .. testsetup:: | ||
|
|
||
| import chainladder as cl | ||
|
|
||
| .. testcode:: | ||
|
|
||
| dev = cl.Development().fit_transform(cl.load_sample("raa")) | ||
| b_def = cl.TailBondy().fit(dev) | ||
| b_12 = cl.TailBondy(earliest_age=12).fit(dev) | ||
| print(round(float(b_def.b_.iloc[0, 0]), 6)) | ||
| print(round(float(b_12.b_.iloc[0, 0]), 6)) | ||
|
|
||
| .. testoutput:: | ||
|
|
||
| 0.5 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are these two results too close to demonstrate the theoretical knowledge offer by the setup of the example? |
||
| 0.48451 | ||
|
|
||
| """ | ||
|
|
||
| def __init__(self, earliest_age=None, attachment_age=None, projection_period=12): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,29 @@ class TailClark(TailBase): | |
| norm_resid_: Triangle | ||
| The "Normalized" Residuals of the model according to Clark. | ||
|
|
||
| Examples | ||
| -------- | ||
| Compare Clark growth curves when the selected tail shape is part of the | ||
| modeling judgment. The tail LDF changes because each curve extrapolates the | ||
| remaining development differently. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these sentences are tautologies (i.e. output changes because input is different), which are not instructive. can we explain why one is much higher than the other, rather than just observing that they are in fact different? |
||
|
|
||
| .. testsetup:: | ||
|
|
||
| import chainladder as cl | ||
|
|
||
| .. testcode:: | ||
|
|
||
| dev = cl.Development().fit_transform(cl.load_sample("raa")) | ||
| log = cl.TailClark(growth="loglogistic").fit(dev) | ||
| wei = cl.TailClark(growth="weibull").fit(dev) | ||
| print(round(float(log.ldf_.values[0, 0, 0, -1]), 3)) | ||
| print(round(float(wei.ldf_.values[0, 0, 0, -1]), 3)) | ||
|
|
||
| .. testoutput:: | ||
|
|
||
| 1.189 | ||
| 1.014 | ||
|
|
||
| """ | ||
|
|
||
| def __init__(self, growth="loglogistic", truncation_age=None, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,6 +55,31 @@ class TailCurve(TailBase): | |
| Slope parameter of the curve fit. | ||
| intercept : DataFrame | ||
| Intercept parameter of the curve fit. | ||
|
|
||
| Examples | ||
| -------- | ||
| Compare parametric tail curves when the same development pattern can | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when should someone use exponential? when should someone use power? what should they use to evaluate the fit? |
||
| support multiple extrapolation shapes. The last-period LDF reflects the | ||
| selected curve family. | ||
|
|
||
| .. testsetup:: | ||
|
|
||
| import chainladder as cl | ||
|
|
||
| .. testcode:: | ||
|
|
||
| tri = cl.load_sample("tail_sample") | ||
| dev = cl.Development().fit_transform(tri) | ||
| exp = cl.TailCurve(curve="exponential", extrap_periods=5).fit(dev) | ||
| inv = cl.TailCurve(curve="inverse_power", extrap_periods=5).fit(dev) | ||
| print(round(float(exp.ldf_.values[0, 0, 0, -1]), 6)) | ||
| print(round(float(inv.ldf_.values[0, 0, 0, -1]), 6)) | ||
|
|
||
| .. testoutput:: | ||
|
|
||
| 1.0093 | ||
| 1.039271 | ||
|
|
||
| """ | ||
|
|
||
| def __init__( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is an instructive example. please elaborate