This package can be used to perform statistical analysis on mortality data generated from the mortchartgen scripts. It implements some functionality in specchartgen.r and mortparams.py in a more general manner using the functions defined in the LifeTable package.
The MortParamsPlot module exports the following functions:
LongTable(indbfile = joinpath(mgendir, "chartgen.db"))-- Converts the tables in the SQLite databaseindbfilefrom wide to long format. The function returns a dictionary with the tables in long format.FitFrames(indict, sex, ages, ageformat, dimension, cause, country, year)-- Takes a dictionary returned byLongTableand selects a subset of rows given by the other parameters, whereagesis a vector of integers,ageformatis used to select relevant columns from the original data, and the values ofsex,cause,countryandyearcan be anything defined in chartgen.yaml. The query result is then transposed by the column given bydimension.FitParams(indict, func, functype)-- Ifindictis an array of dictionaries returned byFitFrames, the first dictionary is assumed to contain data for cause-specific mortality and the second data for total mortality, so that the analysis is normalized to the proportion of the population dying of the cause in question. Ifindictis a single dictionary, analysis is performed without this normalization (this should always be used to fit total mortality, since normalizing obviously would be redundant in this case). Iffunc = "weibull", data are fitted to a two-parameter Weibull function; iffunc = "gompertz", data are fitted to a Gompertz function. Iffunctype = "rate", age-specific mortality rates are fitted; iffunctype = "surv", age-specific survival probabilites are fitted.ParamsPlot(fitdict, plot = "params")-- Takes a dictionary returned byFitParamsorFitParamsNonnorm. Ifplot = "params", a scatterplot showing correlations between linearized versions of the estimated parameters for the survival or mortality functions is drawn. Ifplot = "trend"andindictis grouped by years, a time trend of the X parameter is plotted.ObspredPlot(fitdict, points, ages, trans = "none", trans_time_coords = false, trans_y_coords = false)-- Takes a dictionary returned byFitParamsorFitParamsNonnormand plots observed values for the data points (years, causes or countries) given bypointsagainst predicted values for these points for the ages given byages. Iftrans = "gomp_lin, the data is transformed so that the plotted curves are linear if the data fits a Gompertz function. Iftrans = "weib_lin, the data is transformed so that the plotted curves are linear if the data fits a Weibull function. Iftrans_time_coords = true, the time coordinates along the X axis are transformed according to the given transformation. Iftrans_y_coords = true, this is done with the Y axis coordinates.