/// <summary> /// Constructor of an additive claims reserving model given a run-off triangle. /// </summary> /// <param name="triangle">Triangle to be developed.</param> /// <param name="premiums">Premiums earned ordered by accident year in ascending order.</param> /// <exception cref="DimensionMismatchException">Thrown when the count of premia does not match the number of periods observed.</exception> public AdditiveMethod(ITriangle triangle, IEnumerable <decimal> premiums) : base(TriangleConverter <IncrementalTriangle> .Convert(triangle)) { int n = premiums.Count(); if (n != Triangle.Periods) { throw new DimensionMismatchException(Triangle.Periods, n); } _premiums = premiums; _factors = new Lazy <IReadOnlyList <decimal> >(CalculateFactors); _cumulativeTriangle = TriangleConverter <CumulativeTriangle> .Convert(triangle); }
public void ConvertTriangles() { var points = new List <Point> { new Point(0, 1, 0), new Point(1, 0.8f, 0), new Point(0.1f, 1, 0), new Point(0, 1.1f, 0), new Point(-0.7f, 0.7f, 0), new Point(0, -1, 0), new Point(-0.9f, -0.9f, 0), new Point(-1, 0, 0), new Point(-0.8f, 0.7f, 0) }; var converter = new TriangleConverter(); var result = converter.Convert(points); Assert.Equal(points.Count, result.Count()); }
/// <summary> /// Constructor of a loss development claims reserving model given a run-off triangle. /// </summary> /// <param name="triangle">Triangle to be developed.</param> /// <param name="factors">Factors the triangle is to be developed with.</param> /// <exception cref="DimensionMismatchException">Thrown when the number of factors does not match the number of periods observed.</exception> public LossDevelopment(ITriangle triangle, IEnumerable <decimal> factors) : base(TriangleConverter <CumulativeTriangle> .Convert(triangle)) { int n = factors.Count(); if (n != Triangle.Periods) { throw new DimensionMismatchException(Triangle.Periods, n); } _factors = new Lazy <IReadOnlyList <decimal> >(() => factors.ToList().AsReadOnly()); }
/// <summary> /// Constructor of a Cape Cod model given a run-off triangle. /// </summary> /// <param name="triangle">Triangle to be developed.</param> /// <param name="factors">Factors the triangle is to be developed with.</param> /// <param name="volumeMeasures">Volume measures needed for the claims development according to the model.</param> /// <exception cref="DimensionMismatchException">Thrown when the number of factors does not match the number of periods observed.</exception> /// <exception cref="DimensionMismatchException">Thrown when the number of volume measures does not match the number of periods observed.</exception> public CapeCod(ITriangle triangle, IEnumerable <decimal> factors, IEnumerable <decimal> volumeMeasures) : base(TriangleConverter <CumulativeTriangle> .Convert(triangle)) { int factorsCount = factors.Count(); if (factorsCount != triangle.Periods) { throw new DimensionMismatchException(triangle.Periods, factorsCount); } int vmCount = volumeMeasures.Count(); if (vmCount != triangle.Periods) { throw new DimensionMismatchException(triangle.Periods, vmCount); } _factors = new Lazy <IReadOnlyList <decimal> >(() => factors.ToList().AsReadOnly()); _volumeMeasures = volumeMeasures; }
/// <summary> /// Constructor of a chain-ladder model given a run-off triangle. /// </summary> /// <param name="triangle">Cumulative triangle to be developed.</param> public ChainLadder(ITriangle triangle) : base(TriangleConverter <CumulativeTriangle> .Convert(triangle)) { _factors = new Lazy <IReadOnlyList <decimal> >(CalculateFactors); }
/// <summary> /// Constructor of a Bornhuetter-Ferguson model given a run-off triangle. /// </summary> /// <param name="triangle">Triangle to be developed.</param> /// <param name="factors">Factors the triangle is to be developed with.</param> /// <param name="alpha">Ex-ante expected final claim levels.</param> /// <exception cref="DimensionMismatchException">Thrown when the count of factors does not match the number of periods observed.</exception> /// <exception cref="DimensionMismatchException">Thrown when the number of expected final claim levels does not match the number of periods observed.</exception> public BornhuetterFerguson(ITriangle triangle, IEnumerable <decimal> factors, IEnumerable <decimal> alpha) : base(TriangleConverter <CumulativeTriangle> .Convert(triangle)) { int factorsCount = factors.Count(); if (factorsCount != Triangle.Periods) { throw new DimensionMismatchException(Triangle.Periods, factorsCount); } int alphaCount = alpha.Count(); if (alphaCount != Triangle.Periods) { throw new DimensionMismatchException(Triangle.Periods, alphaCount); } _factors = new Lazy <IReadOnlyList <decimal> >(() => factors.ToList().AsReadOnly()); _alpha = alpha.ToArray(); }