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.
MortParamsPlot module exports the following functions:
LongTable(indbfile = joinpath(mgendir, "chartgen.db"))-- Converts the tables in the SQLite database
indbfilefrom 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 by
LongTableand selects a subset of rows given by the other parameters, where
agesis a vector of integers,
ageformatis used to select relevant columns from the original data, and the values of
yearcan be anything defined in chartgen.yaml. The query result is then transposed by the column given by
FitParams(indict, func, functype)-- If
indictis an array of dictionaries returned by
FitFrames, 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. If
indictis 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). If
func = "weibull", data are fitted to a two-parameter Weibull function; if
func = "gompertz", data are fitted to a Gompertz function. If
functype = "rate", age-specific mortality rates are fitted; if
functype = "surv", age-specific survival probabilites are fitted.
ParamsPlot(fitdict, plot = "params")-- Takes a dictionary returned by
plot = "params", a scatterplot showing correlations between linearized versions of the estimated parameters for the survival or mortality functions is drawn. If
plot = "trend"and
indictis 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 by
FitParamsNonnormand plots observed values for the data points (years, causes or countries) given by
pointsagainst predicted values for these points for the ages given by
trans = "gomp_lin, the data is transformed so that the plotted curves are linear if the data fits a Gompertz function. If
trans = "weib_lin, the data is transformed so that the plotted curves are linear if the data fits a Weibull function. If
trans_time_coords = true, the time coordinates along the X axis are transformed according to the given transformation. If
trans_y_coords = true, this is done with the Y axis coordinates.
over 4 years ago