-
Notifications
You must be signed in to change notification settings - Fork 103
Method summary #852
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?
Method summary #852
Changes from all commits
acedad0
12072f3
e90bbd4
4c81050
633a13c
a63d9f5
3c93489
19b6d31
6863d05
3d3ee60
01be8fb
8aa4db4
5333439
ca5f61e
d13b0fa
5d3c97d
1c3db5c
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 |
|---|---|---|
|
|
@@ -65,6 +65,38 @@ def latest_diagonal(self): | |
| else: | ||
| return self.X_.sum('development') | ||
|
|
||
| @property | ||
| def summary_(self): | ||
| return self._get_summary(self.X_,self.ultimate_) | ||
|
|
||
| def _get_summary(self,X,ult): | ||
| #columns for melt | ||
| ids = X.key_labels + ['origin','development','valuation'] | ||
| #create dataframe for amount | ||
| amount = X.incr_to_cum().latest_diagonal.to_frame(implicit_axis=True,keepdims=True).reset_index().melt(id_vars=ids,var_name = 'column',value_name='latest') | ||
| amount_index = X.key_labels + ['origin','column'] | ||
| amount = amount[amount_index + ['development','latest']] | ||
| amount.set_index(amount_index,inplace=True) | ||
| #create dataframe for ultimate | ||
| ultimate = ult.to_frame(implicit_axis=True,keepdims=True).reset_index().melt(id_vars=ids,var_name = 'column',value_name='ultimate') | ||
| #columns for melt for dev factors | ||
| dev_ids = X.ldf_.key_labels + ['origin','development','valuation'] | ||
| #create dataframe for ldf | ||
| ldf = X.ldf_.to_frame(implicit_axis=True,keepdims=True).reset_index().melt(id_vars=dev_ids,var_name = 'column',value_name='ldf') | ||
| dev_factor_index = X.ldf_.key_labels + ['development','column'] | ||
| ldf = ldf[dev_factor_index + ['ldf']] | ||
| ldf.set_index(dev_factor_index,inplace=True) | ||
| #create dataframe for cdf | ||
| cdf = X.cdf_.to_frame(implicit_axis=True,keepdims=True).reset_index().melt(id_vars=dev_ids,var_name = 'column',value_name='cdf') | ||
| cdf = cdf[dev_factor_index + ['cdf']] | ||
| cdf.set_index(dev_factor_index,inplace=True) | ||
| #assemble full summary. start from ultimate, as some methods (e.g. BF) return an ultimate without any actual amount | ||
| output = ultimate.drop(columns=['development','valuation']) | ||
|
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. I would also add the
Collaborator
Author
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. this actually came up a couple of weeks earlier. bugbot saw my friedland code and made the comment that ult - paid isn't IBNR. i think that's a valid point. ibnr_ isn't guaranteed to be IBNR.
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. Oh ya that's another thing that bugs me, a better name would be unmerged or something like that. But this will be deprecate and move to a new name.
Collaborator
Author
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. also, unlike ldf, "ibnr" can just be df["ultimate"] - df["latest"], whenever the user wants. |
||
| output = output.join(amount,on=amount_index,how='left') | ||
| output = output.join(ldf,on=dev_factor_index,how='left') | ||
| output = output.join(cdf,on=dev_factor_index,how='left') | ||
| return output[X.key_labels + ['column','origin','development','latest','ldf','cdf','ultimate']] | ||
|
|
||
| def fit(self, X, y=None, sample_weight=None): | ||
| """Applies the chainladder technique to triangle **X** | ||
|
|
||
|
|
||
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.
Is the LDFs useful? I think the CDFs are fine.
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.
doesn't have to be useful. we are trying to save the user extra work. manipulating ldf separately is not trivial.
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.
When would the user ever need LDFs in the summary?
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.
easy example, if they want to calculate the expected emergence over the next calendar period