{"action":"created","issue":{"url":"https://api.github.com/repos/mages/ChainLadder/issues/36","repository_url":"https://api.github.com/repos/mages/ChainLadder","labels_url":"https://api.github.com/repos/mages/ChainLadder/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/mages/ChainLadder/issues/36/comments","events_url":"https://api.github.com/repos/mages/ChainLadder/issues/36/events","html_url":"https://github.com/mages/ChainLadder/issues/36","id":229264073,"node_id":"MDU6SXNzdWUyMjkyNjQwNzM=","number":36,"title":"Simple and and vol-weighted averages for \"non-square\" triangules","user":{"login":"actuaryactually","id":3886102,"node_id":"MDQ6VXNlcjM4ODYxMDI=","avatar_url":"https://avatars1.githubusercontent.com/u/3886102?v=4","gravatar_id":"","url":"https://api.github.com/users/actuaryactually","html_url":"https://github.com/actuaryactually","followers_url":"https://api.github.com/users/actuaryactually/followers","following_url":"https://api.github.com/users/actuaryactually/following{/other_user}","gists_url":"https://api.github.com/users/actuaryactually/gists{/gist_id}","starred_url":"https://api.github.com/users/actuaryactually/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/actuaryactually/subscriptions","organizations_url":"https://api.github.com/users/actuaryactually/orgs","repos_url":"https://api.github.com/users/actuaryactually/repos","events_url":"https://api.github.com/users/actuaryactually/events{/privacy}","received_events_url":"https://api.github.com/users/actuaryactually/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-05-17T07:43:23Z","updated_at":"2018-11-01T17:42:01Z","closed_at":null,"author_association":"NONE","body":"If I want a volume all, or simple all set of link ratios a call to ata(paid.tri) works fine (where paid.tri = cumulative paid development triangle).\r\n\r\nIf I want to create a volume-weighted fit on the last five years worth of LDF factors I have found that I can utilise the weights argument as follows: chainladder(paid.tri,weights=wgt.vol.5), where I supply an input triangle of weights.  \r\n\r\nFor \"annual-annual\" triangles, a five-year weighted average can be achieved using this method provided that the user supplies a weights triangle where the latest 6 diagonals are set = 1 and the balance are NAs.  However, when I try the same on a annual/quarterly input triangle (i.e. non square) it fails and returns the following...\r\n\r\n\"Error in checkTriangle(Triangle) : \r\n  Number of origin periods, 10, is less than the number of development periods, 39.\"\r\n\r\nBy annual/quarterly I mean annual origin cohorts but tracking development progress quarter on quarter, which is common for Lloyd's and reinsurance companies.  In my case I had data running out to 9.75 development years, and had 10 origin years.  The error message therefore makes sense but essentially indicates that the chainladder algorithm requires a square-input matrix. \r\n\r\nI'm wondering if there is a smart way to overcome this?  Personally i know that a lot of people would find it easier to adopt Chainladder if they could easily derive simple and volume-weighted averages using a call to a pre-built UDF, e.g. chainladder(paid.tri, no.diag=5, TypeOfAverage=\"Vol\")\r\n\r\nI've found that a n-year simple average can be achieved using the following and I think this would be a good addition to your help file even if you don't recast the \"chainladder\"function.\r\n\r\n######################################\r\nrequire(zoo)\r\n\r\n#quick UDF to get rid of NAs:\r\nlink_ratio_simple_n_yrs<-function(x,no.diag){   \r\n        mean(tail(na.trim(x,sides=\"both\"),no.diag))\r\n      } \r\n\r\n#derive link ratios using build in UDF:\r\npaid.link.ratios<-ata(paid.tri)\r\n\r\n#get simple average as:\r\napply(paid.link.ratios,2,link_ratio_simple_n_yrs,no.diag=5)\r\n\r\n######################################\r\n\r\nHowever I can't tell (and this is annoying) how to achieve the same type of thing for volume weighted averages?  Any thoughts? or a pain in a a$$?\r\n\r\nI suspect my work around for simple weighted average will fail if there are inf values in the triangle.  The following page may provide a better alternative to na.trim above: https://artax.karlin.mff.cuni.cz/r-help/library/IDPmisc/html/NaRV.omit.html\r\n"},"comment":{"url":"https://api.github.com/repos/mages/ChainLadder/issues/comments/435123394","html_url":"https://github.com/mages/ChainLadder/issues/36#issuecomment-435123394","issue_url":"https://api.github.com/repos/mages/ChainLadder/issues/36","id":435123394,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTEyMzM5NA==","user":{"login":"mages","id":1146581,"node_id":"MDQ6VXNlcjExNDY1ODE=","avatar_url":"https://avatars0.githubusercontent.com/u/1146581?v=4","gravatar_id":"","url":"https://api.github.com/users/mages","html_url":"https://github.com/mages","followers_url":"https://api.github.com/users/mages/followers","following_url":"https://api.github.com/users/mages/following{/other_user}","gists_url":"https://api.github.com/users/mages/gists{/gist_id}","starred_url":"https://api.github.com/users/mages/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mages/subscriptions","organizations_url":"https://api.github.com/users/mages/orgs","repos_url":"https://api.github.com/users/mages/repos","events_url":"https://api.github.com/users/mages/events{/privacy}","received_events_url":"https://api.github.com/users/mages/received_events","type":"User","site_admin":false},"created_at":"2018-11-01T17:42:01Z","updated_at":"2018-11-01T17:42:01Z","author_association":"OWNER","body":"Hi David,\r\n\r\nSorry for the long radio silence from my side.\r\n\r\nIf you would like to base your chain-ladder factors on the last 5 diagonals, ie calendar years, you do the following: \r\n\r\n```r\r\n## Only use the last 5 diagonals, i.e. the last 5 calendar years\r\n(weights <- ifelse(row(RAA) + col(RAA) <= 6 | row(RAA) + col(RAA) > 11, 0, 1))\r\nMackChainLadder(GenIns, weights=weights, est.sigma = \"Mack\")\r\n```\r\n\r\nThe argument `alpha` in `MackChainLadder` allows you to decide if you want to use volume weighted (`alpha=1`), simple averages (`alpha=0`), or a classic linear regression through the origin (`alpha=2`). Of course `alpha` can be a vector as well. \r\n\r\nIn the development version of ChainLadder 0.2.8 we have updated and hopefully also clarified the documentation of the `weights` argument in `chainladder` and `MackChainLadder` and added examples like the above.\r\n\r\nI hope this helps."}}
{"actor":{"display_login":"mages"}}