There are a number of alternative sources of mortality data found on the web. I give below some sample links.
- Human Life Table Database - http://www.lifetable.de/
- The Human Mortality Database - http://www.mortality.org/
- United States Life Tables - http://www.cdc.gov/nchs/products/life_tables.htm#decennial
- Decennial Life Tables - http://www.ons.gov.uk/ons/taxonomy/index.html?nscl=Decennial+Life+Tables#tab-data-tables
- CMI Tables - http://www.actuaries.org.uk/research-and-resources/pages/base-mortality-tables-produced-cmi
- SOA Tables - http://mort.soa.org/Default.aspx
SOA TablesThe site contains a large number of tables organised by nation. The tables can be downloaded in a number of formats including Excel and CSV.
A more interesting format is XML. This is actual a standard format referred to as XTbML, which is defined by an ACORD standard.
This includes not only the rates, but also standard names and descriptions and related metadata, such as minimum and maximum ages.
Getting TablesIt is of course possible to simply download the tables of interest from the site. However, it would be useful to be able to automate this a little.
F# has a number of features that make loading data from the web simple and efficient, such as asynchronous workflows. To make this even easier, there is a client library for HTTP called Http.fs.
To download a range of files, you can then simply use this code:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19:
open HttpClient /// get mortality tables in xml format from SOA site given range of integers let getSOAtabs ints = let targurl i = @"http://mort.soa.org/data/t" + i.ToString() + ".xml" let resps = ints |> List.map (fun i -> createRequest Get (targurl i) |> getResponseAsync) |> Async.Parallel |> Async.RunSynchronously resps |> List.ofArray |> List.map (fun r -> r.EntityBody.Value) let ints = [ 1..10 ] let morts = getSOAtabs ints //write files let mortfol = @"C:\MortTabs" List.iter2 (fun i m -> (File.WriteAllText(Path.Combine(mortfol, "t" + i.ToString() + ".xml"), m))) ints morts
The function getSOAtabs reads in a list of integers. It then loads in parallel all the corresponding mortality tables from the SOA site. This list of tables is then written to a folder C:\MortTabs. This produces these results: