# Chain Ladder Curve Fitting in Base SAS

Following a request from Sajjad Meghjee I will demonstrate in this post a way of using SAS to fit a curve through a set of development factors. Curve fitting is a useful way of smoothing development factors and of obtaining a tail factor for development past the end of the triangle. I will show how to fit an exponential decay curve, an inverse power curve and a lognormal distribution curve. I will also explain how the code can be adapted to fit any sensible curve.

As ever this post is a demonstration of what can be done in SAS. It is not intended as a guide to reserving or a recommendation of one particular reserving method over another.

I will start off by using two macros that I have demonstrated in earlier posts. One creates an example loss triangle and the other calculates weighted development factors. So after running these macros I have a dataset called Development_Factors_Volume_12. This contains the month number in a column called n, the total paid in this period in a column called weight, the development factors and the log of the development factors in columns called DF and Log_DF.

Next I will run the below macro to obtain the cumulative development factors. I need these because I will be fitting the lognormal curve to the inverse of the cumulative development factors. This macro is passed the name of a dataset and the column with the development factors. It outputs the cumulative development factors into a field with the specified name.

The below code fits the three curves through the data. The curve fitting is done using Proc Nlin. This is a very useful Proc. It uses least squares to fit the curve and it can fit a curve using almost any sensible formula. The fitting parameters are specified on the Parameters line and the values of these parameters are output by the procedure into a dataset. On the next line is where to specify the formula of the curve. As I said you can change this line to be almost any relationship. A linear line would be y = mx + c and a quadratic would be y = ax2 + bx + c. On the next line I have specified the weight. In these examples I have weighted by the paid claims but you could weight by any other relevant factor. For example the claim counts or a credibility factor. To do this simply change the _Weight_ = statement to equal a different field. If you want an unweighted fit then you can delete this line.

The rest of each macro applies the formula and parameters to create the development factors in the Development_Factors_Volume_12 dataset. In the last line of the dataset is the tail factor. This is calculated by integrating the formula of the curve fit over the remaining range to infinity.

Next week I will demonstrate how SAS can be used with the over-dispersed Poisson distribution to obtain a stochastic distribution of reserves. Thank you for reading and if you like this article please remember to hit the like button.