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
Having some trouble with origin periods #367
Comments
I thought I got all the dates that are off-cycle from traditional calendar periods. Admittedly these types of triangles haven't been tested nearly enough. Thanks for reporting this. It will be a good unit test. |
I tried to locate the issue, but got lost in the odims and the split stuff. any direction would be great It also isn't the only roadblock for independently constructing weight triangles. Since sample weights are required to be triangles, and have the same grain, I've had to create dummy diagonals to accommodate.
|
@henrydingliu, did you have trouble fixing the source code or were you trying to get around it? The problem is that the declaration/instantiation of the Do you intent to have |
having trouble fixing the source code. got lost around line 186. in my example, i intend for development grain to be quarterly. the issue is, if i pass in a single diagonal, I'm unable to set the development grain to quarterly. i had to add a dummy second diagonal in order to get to quarterly, so it's compatible to use with the BF estimator. |
@jbogaardt do you want to take this one? There's a #373 that addressed #294 and #313, and I think this one is similar, which I can take a look. Let me know! |
Its all you @kennethshsu . I may still refactor after your PR to just make the code more legible |
I fixed the 'Q-JUN' issue on this one in f821992. For However, the master branch currently fails here, putting the burden on the end-user to manage the grain: import chainladder as cl
prism = cl.load_sample('prism')['Paid'].sum().incr_to_cum().grain('OQDM')
exposure = prism.latest_diagonal
prism = prism.grain('OQDQ')
# This doesn't work because prism.development_grain = 'Q' and exposure.development_grain = 'M'
prism / exposure I'll issue an additional fix to allow this arithmetic to occur. |
i dont mind setting the exposure grain manually. the issue is that right now it's not possible when the exposure triangle has a single valuation. |
Ok, either way, the exception handling has been relaxed on that one. I believe master should now work as you intend. If I missed something in the intent of this issue, let me know. |
Wow you guys are killing it! @henrydingliu why don't you combine the premium data and the loss data into a single |
@kennethshsu yeah that's been my workaround too. then i got stuck trying to make count_cl.ultimate_ * detrended_selected_sev work as sample_weight |
Can you post the whole code? Also, does it work with @jbogaardt's latest code? |
when i pip install, i seem to be installing an older master |
You would have to run a development environment with the latest commit, can't use pip or conda since those changes aren't released. |
f71f390 didn't fix the issue. However, I have plenty of efficient workarounds at this point. happy to close the issue.
Actually, I found a way to tap into the existing development grain inference, via calling to_period(freq="Q") on the origin series. df = pd.DataFrame()
df["DOL"] = pd.date_range(start="1/1/2008", periods=120, freq="M")
df["Dev"] = "2019-04-30"
df["Premium"] = 1000000
tri = cl.Triangle(
data=df,
origin="DOL",
development="Dev",
columns="Premium",
cumulative=True,
)
print(tri.origin_grain)
print(tri.development_grain)
df["DOL_Q"] = df["DOL"].dt.to_period(freq="Q")
tri = cl.Triangle(
data=df,
origin="DOL_Q",
development="Dev",
columns="Premium",
cumulative=True,
)
print(tri.origin_grain)
print(tri.development_grain) |
Thanks for the additional example. I think it should work with the BF method now on master. |
Trying to bring in premium data for BF. For some reason the origin type gets set to Q-JUN (loss had was Q-DEC no problem).
The text was updated successfully, but these errors were encountered: