Actuarial Outpost
 
Go Back   Actuarial Outpost > Actuarial Discussion Forum > Software & Technology
FlashChat Actuarial Discussion Preliminary Exams CAS/SOA Exams Cyberchat Around the World Suggestions


Fill in a brief DW Simpson Registration Form
to be contacted when new jobs meet your criteria.


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-05-2019, 10:10 AM
Mitsu96 Mitsu96 is offline
Member
Non-Actuary
 
Join Date: Jan 2017
Studying for FM
Posts: 73
Default How to calculate the development period (Age) for a loss development triangle in R?

Hello everyone,
I am trying to create a loss development triangle in R using the 'ChainLadder' package. What I am getting stuck is how to create a formula for the 'Age' variable. My dataframe consist of accident date (mm/dd/yyyy), accident year(yyyy), valuation date (mm/dd/yyyy) and valuation year (yyyy), in individual columns. So, for example, looking at this loss triangle, I want the 'Age' variable to generate a sequence or interval of some sort, which incorporate two things:

i. For the months <= 6 (before July): the sequence should start from 6 and then with each decreasing accident year, it increases by 12. So, for accident year = 2013, and evaluation date = 6/31/2013, I want Age = 6. But, when accident year = 2012 and evaluation date = 6/31/2013, I want Age = 18. And, when accident year = 2011 and evaluation date = 6/31/2013, I want Age = 30 and so on.....

ii. For the months > 6 (after July): the sequence should start from 12 and then with each decreasing accident year, it increases by 12. So, for accident year = 2013, and evaluation date = 11/25/2013, I want Age = 12. But, when accident year = 2012 and evaluation date = 11/25/2013, I want Age = 24. And, when accident year = 2011 and evaluation date = 11/25/2013, I want Age = 36 and so on.....

Not entirely sure how I am suppose to write a code for such a variable. Should I use a nested loop, consisting of if/else statements? Or are there any other functions which would make it easier to create such a variable. Been stuck on this for a while. Any help is appreciated! Thank you!
Attached Images
 
Reply With Quote
Reply

Tags
conditional formatting, loss triangle, nested loops, r studio

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -4. The time now is 10:45 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
*PLEASE NOTE: Posts are not checked for accuracy, and do not
represent the views of the Actuarial Outpost or its sponsors.
Page generated in 0.11180 seconds with 12 queries