Loss-Alae fitting example.

Loss-Alae is a dataset that is provided in the R copula package, which documentation can be found there. This dataset corresponds to claims received by an insurer, where the two variables loss and alae respectively correspond to the amount of the loss and to associated expenses. There is a certain dependence structure between the two, and the actual distribution generating this data is of course unknown. Our task here is to provide a parametric model that approximates this distribution.

Let us first import the data :

using Copulas, Distributions, Plots
data = [
    10.0 24.0 45.0 51.0 60.0 74.0 75.0 78.0 87.0 100.0 115.0 123.0 133.0 140.0 147.0 147.0 165.0 192.0 200.0 300.0 308.0 311.0 326.0 350.0 350.0 400.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 500.0 520.0 578.0 600.0 600.0 634.0 667.0 700.0 750.0 750.0 750.0 750.0 750.0 750.0 750.0 798.0 800.0 833.0 833.0 875.0 900.0 909.0 916.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1000.0 1075.0 1091.0 1100.0 1122.0 1125.0 1200.0 1200.0 1200.0 1250.0 1250.0 1250.0 1250.0 1250.0 1250.0 1250.0 1250.0 1298.0 1300.0 1300.0 1310.0 1333.0 1375.0 1450.0 1456.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1500.0 1522.0 1545.0 1600.0 1633.0 1658.0 1666.0 1666.0 1667.0 1667.0 1701.0 1750.0 1750.0 1750.0 1750.0 1800.0 1800.0 1800.0 1800.0 1800.0 1892.0 1913.0 1937.0 1947.0 1974.0 1980.0 1993.0 1994.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2002.0 2018.0 2022.0 2057.0 2067.0 2070.0 2100.0 2125.0 2180.0 2250.0 2250.0 2250.0 2303.0 2312.0 2325.0 2400.0 2405.0 2428.0 2486.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2500.0 2600.0 2600.0 2600.0 2700.0 2700.0 2730.0 2749.0 2750.0 2750.0 2776.0 2787.0 2850.0 2917.0 2922.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3000.0 3162.0 3250.0 3250.0 3269.0 3300.0 3300.0 3333.0 3400.0 3409.0 3436.0 3480.0 3486.0 3494.0 3500.0 3500.0 3500.0 3500.0 3500.0 3500.0 3500.0 3500.0 3500.0 3500.0 3500.0 3500.0 3500.0 3500.0 3500.0 3600.0 3685.0 3750.0 3750.0 3750.0 3750.0 3750.0 3750.0 3750.0 3750.0 3903.0 3941.0 4000.0 4000.0 4000.0 4000.0 4000.0 4000.0 4000.0 4000.0 4000.0 4000.0 4000.0 4000.0 4000.0 4000.0 4000.0 4000.0 4038.0 4250.0 4250.0 4286.0 4346.0 4350.0 4465.0 4500.0 4500.0 4500.0 4500.0 4500.0 4500.0 4500.0 4500.0 4535.0 4568.0 4600.0 4675.0 4700.0 4750.0 4750.0 4750.0 4833.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5000.0 5003.0 5010.0 5097.0 5115.0 5250.0 5390.0 5400.0 5500.0 5500.0 5500.0 5500.0 5500.0 5500.0 5500.0 5500.0 5500.0 5577.0 5600.0 5600.0 5619.0 5625.0 5625.0 5655.0 5750.0 5750.0 6000.0 6000.0 6000.0 6000.0 6000.0 6000.0 6000.0 6000.0 6000.0 6000.0 6000.0 6000.0 6000.0 6000.0 6000.0 6000.0 6066.0 6075.0 6240.0 6403.0 6406.0 6441.0 6500.0 6500.0 6500.0 6500.0 6500.0 6500.0 6500.0 6500.0 6538.0 6550.0 6666.0 6719.0 6750.0 6750.0 6750.0 6907.0 7000.0 7000.0 7000.0 7000.0 7000.0 7000.0 7000.0 7000.0 7000.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7500.0 7525.0 7625.0 7820.0 7857.0 7875.0 7961.0 8000.0 8000.0 8000.0 8000.0 8000.0 8000.0 8000.0 8000.0 8036.0 8223.0 8250.0 8330.0 8333.0 8333.0 8333.0 8333.0 8366.0 8500.0 8500.0 8500.0 8500.0 8500.0 8500.0 8500.0 8500.0 8520.0 8555.0 8640.0 8703.0 8750.0 8827.0 8939.0 9000.0 9000.0 9000.0 9000.0 9000.0 9000.0 9000.0 9000.0 9000.0 9093.0 9250.0 9250.0 9250.0 9427.0 9500.0 9500.0 9500.0 9500.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10000.0 10081.0 10199.0 10250.0 10250.0 10899.0 11000.0 11000.0 11000.0 11000.0 11000.0 11000.0 11000.0 11000.0 11000.0 11000.0 11097.0 11120.0 11280.0 11425.0 11500.0 11667.0 11723.0 11750.0 11920.0 12000.0 12000.0 12000.0 12000.0 12000.0 12000.0 12000.0 12000.0 12100.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12500.0 12566.0 12608.0 12800.0 12821.0 12830.0 12875.0 12875.0 13000.0 13000.0 13242.0 13333.0 13450.0 13500.0 13500.0 13500.0 13500.0 13750.0 13750.0 13825.0 14000.0 14000.0 14000.0 14000.0 14000.0 14500.0 14500.0 14598.0 14721.0 14750.0 14875.0 14983.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15000.0 15001.0 15069.0 15078.0 15086.0 15285.0 15500.0 15500.0 15500.0 15552.0 15643.0 15833.0 16000.0 16153.0 16486.0 16500.0 16500.0 16500.0 16500.0 16500.0 16500.0 16500.0 16666.0 16667.0 16667.0 16667.0 17258.0 17327.0 17350.0 17500.0 17500.0 17500.0 17500.0 17500.0 17500.0 17500.0 17500.0 17500.0 17770.0 18000.0 18000.0 18000.0 18000.0 18000.0 18000.0 18136.0 18175.0 18333.0 18358.0 18444.0 18500.0 18500.0 18500.0 18500.0 18544.0 18706.0 18706.0 18750.0 18750.0 19000.0 19000.0 19000.0 19375.0 19500.0 19500.0 19500.0 19500.0 19622.0 19833.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20000.0 20800.0 20802.0 20863.0 21000.0 21000.0 21000.0 21000.0 21000.0 21013.0 21110.0 21136.0 21274.0 21557.0 21666.0 21678.0 21701.0 21875.0 21951.0 22000.0 22000.0 22000.0 22000.0 22035.0 22105.0 22500.0 22500.0 22500.0 22500.0 22500.0 22500.0 22500.0 22500.0 22500.0 22500.0 22500.0 22940.0 22963.0 23000.0 23000.0 23000.0 23300.0 23320.0 23759.0 24000.0 24014.0 24334.0 24357.0 24464.0 24570.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25000.0 25002.0 25045.0 25187.0 25250.0 25396.0 25507.0 25700.0 25789.0 25800.0 25883.0 26000.0 26000.0 26075.0 26250.0 26250.0 27000.0 27000.0 27300.0 27500.0 27500.0 27500.0 27500.0 28000.0 28130.0 28281.0 28333.0 28650.0 28750.0 29026.0 29890.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30000.0 30001.0 30064.0 30750.0 30811.0 31000.0 31005.0 31250.0 31428.0 31882.0 32000.0 32000.0 32000.0 32000.0 32500.0 32500.0 32500.0 32500.0 32500.0 32500.0 32500.0 33073.0 33333.0 33333.0 33868.0 34000.0 34186.0 34190.0 34625.0 34997.0 35000.0 35000.0 35000.0 35000.0 35000.0 35000.0 35000.0 35000.0 35000.0 35000.0 35000.0 35000.0 35000.0 35000.0 35104.0 36573.0 37500.0 37749.0 37886.0 37936.0 38065.0 38200.0 38696.0 38843.0 38998.0 39060.0 40000.0 40000.0 40000.0 40000.0 40000.0 40000.0 40000.0 40000.0 40000.0 40000.0 40000.0 40052.0 40461.0 40500.0 41000.0 41807.0 41845.0 42000.0 42500.0 42717.0 43000.0 43000.0 43500.0 43500.0 44887.0 45000.0 45000.0 45000.0 45000.0 45000.0 45000.0 45000.0 45000.0 45000.0 45000.0 45000.0 45000.0 45000.0 45666.0 45955.0 46000.0 46250.0 47370.0 47500.0 47500.0 47500.0 47500.0 47500.0 47500.0 47500.0 48000.0 48349.0 49050.0 49412.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50000.0 50147.0 50176.0 50500.0 50899.0 51015.0 51085.0 52500.0 54000.0 54250.0 55000.0 55000.0 55000.0 55000.0 55000.0 55651.0 56057.0 56062.0 57000.0 57500.0 57500.0 57808.0 58064.0 58101.0 59232.0 60000.0 60000.0 60000.0 60000.0 60000.0 60000.0 60000.0 60000.0 60087.0 60250.0 62079.0 62500.0 62959.0 63000.0 65000.0 65000.0 65000.0 65000.0 65544.0 65613.0 66933.0 67500.0 67500.0 70000.0 70000.0 70000.0 70000.0 70000.0 70000.0 70000.0 70001.0 71000.0 71459.0 71710.0 72000.0 72500.0 73000.0 73000.0 73157.0 73614.0 74700.0 74970.0 75000.0 75000.0 75000.0 75000.0 75000.0 75000.0 75000.0 75000.0 75000.0 75000.0 75000.0 75000.0 75000.0 75000.0 75000.0 75000.0 75000.0 76100.0 76991.0 80000.0 80000.0 80000.0 82500.0 83500.0 84000.0 85000.0 86311.0 86667.0 87500.0 88000.0 88803.0 90000.0 90000.0 90000.0 90000.0 90451.0 92317.0 92522.0 93000.0 93868.0 95000.0 95963.0 97000.0 97000.0 98087.0 98844.0 99632.0 99991.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 100000.0 101000.0 101276.0 101422.0 103127.0 103264.0 104518.0 104767.0 105000.0 105000.0 108000.0 109500.0 110000.0 110000.0 110000.0 110659.0 112000.0 115000.0 120000.0 120475.0 124999.0 125000.0 125000.0 125000.0 125000.0 125000.0 125000.0 130000.0 130050.0 130555.0 135000.0 135000.0 137500.0 138133.0 140000.0 140837.0 145151.0 149750.0 150000.0 150000.0 150000.0 150000.0 150000.0 150000.0 150494.0 151084.0 151152.0 152744.0 153874.0 155885.0 157499.0 160300.0 161187.0 166500.0 167000.0 168751.0 170000.0 178000.0 183095.0 184925.0 187113.0 192500.0 200000.0 200000.0 200000.0 200000.0 200000.0 200000.0 200000.0 200678.0 209122.0 210000.0 210000.0 215231.0 215303.0 225000.0 225000.0 225562.0 235000.0 244000.0 245834.0 250000.0 250000.0 250000.0 251981.0 260000.0 270000.0 275000.0 275000.0 275000.0 275000.0 278705.0 289146.0 289428.0 300000.0 300000.0 300000.0 300000.0 300000.0 300000.0 301090.0 316694.0 320000.0 337500.0 365600.0 370005.0 371654.0 373915.0 375000.0 379940.0 412998.0 432500.0 445000.0 449663.0 465000.0 474400.0 475000.0 480529.0 496559.0 500000.0 500000.0 500000.0 500000.0 500000.0 500000.0 500000.0 750000.0 838701.0 854867.0 1.0e6 1.0e6 2.173595e6; 3806.0 5658.0 321.0 305.0 758.0 8768.0 1805.0 78.0 46534.0 489.0 20.0 60790.0 2305.0 1940.0 125.0 2881.0 5235.0 915.0 1361.0 348.0 30735.0 1081.0 4201.0 76.0 1255.0 1336.0 164.0 179.0 723.0 1193.0 1406.0 1480.0 1527.0 1938.0 1995.0 2215.0 2706.0 2778.0 2936.0 3815.0 4419.0 4495.0 5371.0 5609.0 6350.0 9317.0 10246.0 14752.0 19261.0 2373.0 1925.0 1458.0 5057.0 211.0 2369.0 748.0 748.0 1737.0 2147.0 3184.0 3564.0 4788.0 7865.0 1553.0 5773.0 7607.0 9900.0 4565.0 968.0 9215.0 5522.0 321.0 407.0 450.0 464.0 484.0 780.0 946.0 1088.0 1289.0 1320.0 1352.0 1872.0 1940.0 2293.0 2302.0 2481.0 2488.0 2495.0 2750.0 3388.0 3434.0 4149.0 4927.0 5675.0 6525.0 6557.0 6626.0 6829.0 6867.0 7797.0 8523.0 9412.0 11124.0 20564.0 2168.0 2199.0 170.0 1422.0 1224.0 984.0 1251.0 2456.0 365.0 371.0 479.0 531.0 774.0 2090.0 2488.0 3523.0 1032.0 1409.0 2507.0 1459.0 999.0 9459.0 2750.0 3911.0 60.0 301.0 318.0 436.0 834.0 1275.0 1315.0 1686.0 2286.0 2422.0 2919.0 3247.0 3598.0 4701.0 4860.0 4870.0 6528.0 6990.0 7689.0 8131.0 8228.0 10018.0 11994.0 17146.0 1614.0 415.0 3537.0 2585.0 337.0 261.0 12323.0 526.0 2413.0 12426.0 150.0 198.0 947.0 1930.0 776.0 1791.0 2825.0 4644.0 7829.0 1185.0 1578.0 293.0 10564.0 775.0 2706.0 1946.0 4851.0 584.0 700.0 978.0 999.0 1190.0 1395.0 1699.0 1968.0 1989.0 2453.0 2503.0 2644.0 2748.0 3089.0 3119.0 3496.0 3597.0 4505.0 4756.0 5392.0 5439.0 5491.0 5767.0 5963.0 6033.0 6858.0 6995.0 7488.0 8401.0 8650.0 9393.0 17222.0 5971.0 1322.0 610.0 11305.0 5697.0 6201.0 302.0 2387.0 9584.0 2182.0 8204.0 14528.0 803.0 19407.0 5728.0 620.0 960.0 6657.0 5417.0 50.0 115.0 145.0 184.0 415.0 540.0 544.0 656.0 852.0 895.0 1053.0 1059.0 1123.0 1150.0 1862.0 1992.0 2263.0 2268.0 2325.0 2439.0 2462.0 2874.0 2939.0 3352.0 3411.0 3583.0 4248.0 4263.0 4451.0 4669.0 4729.0 4805.0 4950.0 5000.0 5063.0 5075.0 5321.0 5385.0 5453.0 5678.0 5740.0 5758.0 6027.0 6209.0 6763.0 7000.0 7362.0 7369.0 7421.0 7467.0 8083.0 8185.0 8813.0 9073.0 9652.0 12580.0 12644.0 14842.0 824.0 2168.0 4914.0 1109.0 3531.0 112158.0 2506.0 1491.0 4540.0 4054.0 2603.0 5120.0 1715.0 7802.0 190.0 420.0 749.0 1301.0 1495.0 1594.0 1618.0 1693.0 1899.0 1952.0 2103.0 2237.0 2534.0 2949.0 3007.0 3154.0 3318.0 3365.0 5831.0 7176.0 8420.0 10330.0 11561.0 11861.0 12545.0 14485.0 18206.0 32390.0 339.0 35.0 10279.0 7081.0 690.0 3020.0 9251.0 495.0 1974.0 12072.0 15953.0 5374.0 7423.0 378.0 565.0 784.0 787.0 980.0 2531.0 2691.0 3395.0 3641.0 5079.0 5381.0 7615.0 7936.0 11240.0 25176.0 3063.0 1716.0 670.0 1369.0 1536.0 3153.0 3556.0 3637.0 4224.0 9951.0 14319.0 3689.0 50.0 88.0 298.0 355.0 1390.0 1756.0 1773.0 2411.0 2914.0 3370.0 3499.0 3640.0 3971.0 4439.0 4898.0 20142.0 5687.0 2008.0 2115.0 6522.0 18656.0 1786.0 1534.0 392.0 395.0 2316.0 2406.0 3046.0 3358.0 4420.0 7669.0 1542.0 6180.0 6004.0 2588.0 5586.0 2894.0 5293.0 32362.0 5588.0 25.0 135.0 137.0 150.0 187.0 310.0 333.0 492.0 571.0 622.0 627.0 704.0 721.0 830.0 1000.0 1162.0 1242.0 1316.0 1398.0 1764.0 1764.0 1849.0 1920.0 1965.0 2140.0 2331.0 2391.0 2646.0 2932.0 3289.0 3427.0 3604.0 3617.0 4155.0 4158.0 4336.0 4445.0 4618.0 4696.0 4756.0 4885.0 4964.0 5012.0 5235.0 5614.0 5615.0 5747.0 6226.0 6292.0 6719.0 6843.0 7009.0 7009.0 7044.0 7204.0 7279.0 7381.0 8085.0 8102.0 8541.0 8758.0 8897.0 8909.0 9858.0 12812.0 13165.0 13576.0 14683.0 16014.0 16099.0 25477.0 37264.0 5093.0 6101.0 9437.0 20383.0 4293.0 44666.0 9318.0 101.0 1293.0 1309.0 1905.0 2874.0 3412.0 3833.0 7459.0 10344.0 7001.0 4346.0 6387.0 2798.0 5571.0 29211.0 974.0 7897.0 34474.0 492.0 904.0 1307.0 2101.0 2754.0 3719.0 4389.0 5823.0 7106.0 7313.0 7322.0 8520.0 10136.0 11741.0 12383.0 149962.0 1523.0 6244.0 6765.0 5111.0 274.0 9084.0 185.0 895.0 1194.0 1789.0 3698.0 4914.0 8154.0 17397.0 12277.0 3295.0 9046.0 18254.0 518.0 2524.0 3919.0 2383.0 50.0 1900.0 3431.0 3451.0 3944.0 10593.0 12909.0 15780.0 16246.0 150.0 266.0 332.0 500.0 508.0 562.0 695.0 754.0 1351.0 1449.0 1557.0 2615.0 2873.0 3285.0 3775.0 3986.0 4057.0 4738.0 4949.0 5006.0 5244.0 5457.0 5732.0 7064.0 7083.0 7318.0 7340.0 7624.0 7894.0 7904.0 8711.0 11488.0 11724.0 11949.0 13281.0 13342.0 13620.0 15771.0 17213.0 17595.0 28311.0 65020.0 1687.0 13517.0 2763.0 479.0 54266.0 18113.0 1942.0 2099.0 2335.0 2901.0 2929.0 9671.0 12167.0 13251.0 1450.0 23351.0 1521.0 5890.0 3379.0 5116.0 9486.0 31367.0 5726.0 1060.0 1781.0 2791.0 3484.0 3869.0 5403.0 8721.0 15780.0 4189.0 15987.0 1146.0 11546.0 2682.0 3329.0 16252.0 406.0 1694.0 2337.0 2378.0 2517.0 4602.0 7823.0 11761.0 16732.0 7998.0 28.0 6238.0 23557.0 1978.0 1966.0 2995.0 3593.0 11243.0 169.0 255.0 258.0 386.0 470.0 699.0 927.0 1174.0 1561.0 1573.0 1656.0 1779.0 1787.0 1790.0 1844.0 2049.0 2129.0 2223.0 2748.0 2907.0 2976.0 3526.0 3628.0 3667.0 4007.0 4348.0 4421.0 4493.0 5111.0 5192.0 5247.0 5560.0 5650.0 6422.0 6476.0 7498.0 7700.0 7909.0 8226.0 8293.0 8623.0 9802.0 9854.0 9875.0 10623.0 10826.0 10829.0 11065.0 11257.0 11410.0 11499.0 11563.0 11793.0 11989.0 12089.0 16301.0 16663.0 17053.0 18587.0 19425.0 23461.0 25133.0 25305.0 28942.0 32239.0 36245.0 96952.0 1303.0 1578.0 16928.0 29077.0 4680.0 809.0 1532.0 2924.0 3576.0 3970.0 4372.0 4514.0 4707.0 9117.0 23362.0 14580.0 4619.0 14353.0 16664.0 1076.0 6845.0 1316.0 853.0 2869.0 202.0 1200.0 1580.0 2347.0 2521.0 2748.0 4523.0 9014.0 16320.0 165.0 325.0 552.0 673.0 935.0 2530.0 4608.0 4932.0 6160.0 6234.0 6309.0 8375.0 10371.0 10496.0 11897.0 12297.0 13842.0 14220.0 14266.0 14674.0 3270.0 2100.0 4417.0 47257.0 26.0 6721.0 7815.0 26993.0 28847.0 8814.0 6667.0 2368.0 111.0 700.0 6096.0 15302.0 4295.0 15352.0 3208.0 687.0 2201.0 3947.0 8369.0 10969.0 625.0 3072.0 3077.0 3959.0 28217.0 263.0 4977.0 24.0 168.0 480.0 1103.0 1830.0 2007.0 2072.0 2191.0 2194.0 2475.0 2561.0 2643.0 2977.0 3003.0 3036.0 3183.0 3324.0 3429.0 3525.0 3598.0 3689.0 4012.0 4541.0 4587.0 5000.0 5009.0 5110.0 5531.0 6134.0 6326.0 6766.0 6890.0 7196.0 7231.0 7288.0 7415.0 7904.0 8060.0 8634.0 9151.0 9357.0 13499.0 14727.0 15604.0 20615.0 26482.0 58507.0 59884.0 129435.0 5174.0 1403.0 16698.0 489.0 7635.0 1319.0 2950.0 3886.0 6290.0 13866.0 2422.0 4906.0 3717.0 6490.0 1117.0 2791.0 4104.0 5144.0 6657.0 8763.0 15819.0 12105.0 971.0 2333.0 5643.0 25859.0 8706.0 16096.0 2226.0 2520.0 3000.0 5936.0 7525.0 11575.0 16137.0 21740.0 23586.0 3032.0 358.0 708.0 3100.0 3419.0 8242.0 8775.0 11034.0 312.0 9440.0 8724.0 20203.0 504.0 4015.0 11070.0 12138.0 2441.0 10557.0 13576.0 10747.0 18458.0 4602.0 4870.0 8260.0 3333.0 7088.0 12569.0 13674.0 16744.0 25634.0 212.0 325.0 1447.0 2336.0 2760.0 2774.0 2863.0 3895.0 4137.0 4436.0 4542.0 5095.0 5108.0 5647.0 8103.0 9971.0 10841.0 11888.0 12304.0 13218.0 14078.0 14417.0 14999.0 16223.0 16312.0 17905.0 18124.0 23484.0 25026.0 32093.0 36109.0 36572.0 70435.0 18289.0 12980.0 8694.0 1256.0 2642.0 2727.0 2981.0 13442.0 8176.0 2344.0 11244.0 5424.0 5519.0 5116.0 15.0 18825.0 23155.0 9348.0 3483.0 3884.0 7728.0 43454.0 409.0 2485.0 731.0 1179.0 1720.0 1997.0 4892.0 5250.0 7151.0 7309.0 10366.0 10991.0 12170.0 24987.0 5675.0 5036.0 10622.0 20237.0 18896.0 4986.0 2586.0 1080.0 4177.0 17688.0 19934.0 1954.0 4919.0 360.0 387.0 535.0 583.0 1084.0 1199.0 1652.0 2012.0 2588.0 3094.0 4508.0 5230.0 5731.0 5998.0 6419.0 7004.0 7057.0 7081.0 7227.0 7253.0 7920.0 9089.0 9093.0 9814.0 10726.0 13334.0 13948.0 15116.0 16118.0 18118.0 18155.0 18238.0 20694.0 20737.0 22020.0 22857.0 22929.0 26332.0 55472.0 56519.0 20999.0 47560.0 18409.0 4389.0 45945.0 6782.0 3332.0 33437.0 2931.0 12181.0 1908.0 6111.0 2316.0 4966.0 55213.0 2533.0 29273.0 1839.0 2176.0 2381.0 4211.0 19887.0 3111.0 14568.0 2350.0 6695.0 8034.0 12375.0 6384.0 2710.0 35.0 657.0 2172.0 3803.0 3829.0 3996.0 4850.0 4908.0 5519.0 6365.0 7023.0 7439.0 7960.0 8312.0 9631.0 11353.0 12647.0 18728.0 20221.0 24706.0 38018.0 39831.0 7890.0 2208.0 8619.0 19332.0 1395.0 14182.0 3851.0 23004.0 7237.0 5889.0 8930.0 10364.0 39297.0 798.0 2638.0 3750.0 4404.0 7839.0 19667.0 27592.0 7845.0 11562.0 53048.0 6715.0 40782.0 8190.0 10853.0 23407.0 6681.0 1330.0 1577.0 2442.0 3577.0 4500.0 4541.0 5553.0 10112.0 17118.0 19397.0 20399.0 25962.0 46953.0 81128.0 7570.0 3242.0 6946.0 16290.0 3128.0 15550.0 6892.0 70922.0 78345.0 7883.0 3013.0 444.0 2019.0 3502.0 4440.0 9066.0 10177.0 10747.0 15706.0 21083.0 31532.0 44088.0 66524.0 4397.0 1469.0 617.0 20098.0 17560.0 14127.0 7872.0 88534.0 14107.0 8392.0 29307.0 8007.0 12177.0 2178.0 1182.0 1820.0 3009.0 4941.0 7735.0 9134.0 9250.0 10411.0 17557.0 19167.0 21841.0 23088.0 37529.0 5103.0 3069.0 20440.0 18874.0 11834.0 434.0 815.0 2238.0 4956.0 5013.0 12856.0 42966.0 3562.0 50611.0 17567.0 77477.0 55.0 480.0 500.0 1636.0 2165.0 2280.0 2809.0 2881.0 2985.0 3048.0 3403.0 3565.0 3634.0 4094.0 4292.0 5441.0 5974.0 7669.0 8726.0 9231.0 9609.0 10775.0 11259.0 11725.0 12210.0 12344.0 15687.0 16303.0 17768.0 25661.0 25922.0 21547.0 15000.0 2606.0 18172.0 6445.0 5485.0 11333.0 913.0 8312.0 830.0 2128.0 22981.0 24889.0 29327.0 23391.0 48076.0 210.0 14709.0 10983.0 15484.0 38341.0 11863.0 12691.0 1108.0 2438.0 4095.0 4519.0 4560.0 4762.0 6118.0 9812.0 42230.0 2580.0 501863.0 17280.0 12750.0 27738.0 4881.0 559.0 5534.0 6756.0 13762.0 27671.0 13319.0 19458.0 25767.0 160581.0 1900.0 2333.0 4555.0 14253.0 14878.0 22114.0 39247.0 7177.0 40.0 4633.0 2756.0 4966.0 799.0 13391.0 15756.0 20495.0 214.0 16063.0 12608.0 574.0 3451.0 5542.0 6125.0 6833.0 11877.0 12851.0 15913.0 17236.0 17687.0 19213.0 23566.0 26232.0 30401.0 36703.0 46494.0 72060.0 1936.0 25949.0 4863.0 5985.0 16731.0 16452.0 8072.0 4730.0 18284.0 37711.0 5792.0 16677.0 2908.0 5203.0 3367.0 3764.0 5097.0 6959.0 18232.0 12965.0 60435.0 31812.0 89826.0 12398.0 14008.0 8811.0 18919.0 3944.0 12644.0 6431.0 22092.0 557.0 1416.0 2287.0 4842.0 7270.0 10312.0 12815.0 13820.0 15268.0 17550.0 21166.0 22706.0 25034.0 25256.0 28013.0 30149.0 34716.0 38516.0 71350.0 107192.0 211573.0 101622.0 4210.0 9513.0 60487.0 7434.0 4825.0 166893.0 1782.0 35055.0 9516.0 31422.0 2004.0 7475.0 12143.0 48062.0 17645.0 7571.0 89365.0 13098.0 2257.0 4249.0 10093.0 11308.0 13227.0 14970.0 19671.0 46359.0 13364.0 18721.0 2229.0 42863.0 99412.0 22464.0 4698.0 10292.0 14082.0 32370.0 4773.0 6695.0 6945.0 12042.0 20887.0 46507.0 1588.0 35252.0 155640.0 6496.0 21354.0 4104.0 64690.0 17881.0 17601.0 21607.0 53829.0 6114.0 38276.0 1031.0 5717.0 48811.0 180615.0 46777.0 277.0 7846.0 20095.0 23137.0 27903.0 61709.0 67782.0 32414.0 25116.0 7357.0 63903.0 36573.0 41532.0 6603.0 12720.0 45613.0 38157.0 41946.0 63433.0 5448.0 24087.0 55068.0 27774.0 11875.0 10530.0 3510.0 12271.0 15748.0 29638.0 306072.0 21359.0 23086.0 310.0 9819.0 25373.0 48619.0 55010.0 62321.0 68630.0 61706.0 36559.0 15358.0 131678.0 56123.0 69658.0 10261.0 28384.0 25670.0 45095.0 7294.0 28192.0 142227.0 27272.0 160265.0 65248.0 186670.0 31738.0 15534.0 38242.0 49617.0 55080.0 55388.0 280202.0 467246.0 2940.0 3662.0 61239.0 43966.0 135653.0 134743.0
]
2×1500 Matrix{Float64}:
   10.0    24.0   45.0   51.0   60.0    74.0  …       1.0e6       2.1736e6
 3806.0  5658.0  321.0  305.0  758.0  8768.0     135653.0    134743.0

Since the dataset is bivariate, we can have a glimpse of the bivariate distribution through a simple scatter plot:

loss = data[1,:]
alae = data[2,:]
scatter(loss,alae)
Example block output

The observations seem to have extreme values. Let's move to log scales:

scatter(log.(loss),log.(alae))
Example block output

This is a much better looking scatter plot. To fit a full distribution on this dataset, we have to understand what families of marginals and of dependence structure to use. Let us first look at the marginal behaviors:

plot(histogram(log.(loss)),histogram(log.(alae)))
Example block output

This histogram look fairly Gaussian, and thus a good first guess for the distributions of the marginals would be LogNormal distributions. Now the dependence structure:

ranks = Copulas.pseudos(data)
scatter(ranks[1,:],ranks[2,:])
Example block output

The vertical strides are there because of rounding in the input data. But still, we observe that there is dependence structure in both tails, and that the dependence structure seems fairly symmetric. Let us try to fit a few different copulas:

fit_gaussian = fit(SklarDist{GaussianCopula,Tuple{LogNormal,LogNormal}}, data)
fit_clayton = fit(SklarDist{ClaytonCopula,Tuple{LogNormal,LogNormal}}, data)
fit_gumbel = fit(SklarDist{GumbelCopula,Tuple{LogNormal,LogNormal}}, data)
fit_frank = fit(SklarDist{FrankCopula,Tuple{LogNormal,LogNormal}}, data)

Let's check the negative loglikelihood on each of those models (note that they all have the same number of parameters):

nllhs = [-loglikelihood(fit,data) for fit in (fit_gaussian,fit_clayton,fit_gumbel,fit_frank)]
4-element Vector{Float64}:
 32216.375451240296
 32430.051935405932
 32174.890388465803
 32206.44183201268

So the Clayton looks a bit better. Let's look at the parametrization:

fit_clayton
SklarDist{ClaytonCopula{2, Float64}, Tuple{Distributions.LogNormal{Float64}, Distributions.LogNormal{Float64}}}(
C: ClaytonCopula{2, Float64}(
G: Copulas.ClaytonGenerator{Float64}(0.9683325060462363)
)

m: (Distributions.LogNormal{Float64}(μ=9.37345394250046, σ=1.638106235266425), Distributions.LogNormal{Float64}(μ=8.521976324212277, σ=1.4298990317418996))
)

For the marginals, we can for example check quantile quantile plots (again, on log-scale)

n = size(data,2)
plot(
    scatter(sort(log.(loss)), log.(quantile.(Ref(fit_clayton.m[1]),(1:n)./(n+1))), label="Loss"),
    scatter(sort(log.(alae)), log.(quantile.(Ref(fit_clayton.m[2]),(1:n)./(n+1))), label="Alae")
)
Example block output

These quantile-quantile plots are not perfect, we see that both tails are a bit wiggly. For the dependence structure, we can sample a new dataset from the fitted copula to check if the ranks behaviors looks like what we had before:

u = rand(fit_clayton.C, 1500)
scatter(u[1,:],u[2,:])
Example block output

There are potential improvements that can be made to this fit:

  • The tail dependency does not look like it is on the right side. To solve that, we could use SurvivalCopula to fit a flipped version of the Clayton through fit(SklarDist{SurvivalCopula{2,ClaytonCopula,(1,2)},Tuple{...}}, ...).
  • We could use other marginal proposals than LogNormals and validate (e.g., through likelihood ratio tests) that the fits are OK.
  • We could keep marginals and/or the dependence structure empirical, through e.g., EmpiricalCopula.