%% Case Study for Life Tables Analysis
% This example shows how to use the basic workflow for life tables.
% Load the life table data file.

load us_lifetable_2009

%
% Calibrate life table from survival data with the default heligman-pollard parametric model.

a = lifetablefit(x, lx);

%
% Generate life table series from the calibrated mortality model.

qx = lifetablegen((0:100), a);
display(qx(1:40,:))

%
% Plot the qx series and display the legend. The series qx is the conditional probability that a person at age x will die between age x and the next age in the series

plot((0:100), log(qx));
legend(series, 'location', 'southeast');
title('Conditional Probability of Dying within One Year of Current Age');
xlabel('Age');
ylabel('Log Probability');

% Copyright 2015 The MathWorks, Inc.