Description Usage Arguments Value Note Examples
Compute period mortality estimates, or tabulate exposures/deaths, using DHS or IHME methods
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | periodMortality(age_death, birth_int, cluster_id, windows_lower = c(0, 1, 3,
6, 12, 24, 36, 48), windows_upper = c(0, 2, 5, 11, 23, 35, 47, 59),
ages_lower = c(0, 0), ages_upper = c(12, 60), nperiod = 1,
period = 60, period_end = NULL, interview_dates = NULL,
method = c("monthly", "direct"), cohorts = c("one", "three"),
inclusion = c("enter", "exit", "both", "either"), mortality = c("bin",
"monthly"), delay = NULL, glm = FALSE, verbose = TRUE, n_cores = 1,
...)
periodTabulate(age_death, birth_int, cluster_id, windows_lower = c(0, 1, 3, 6,
12, 24, 36, 48), windows_upper = c(0, 2, 5, 11, 23, 35, 47, 59),
nperiod = 1, period = 60, period_end = NULL, interview_dates = NULL,
method = c("monthly", "direct"), cohorts = c("one", "three"),
inclusion = c("enter", "exit", "both", "either"), mortality = c("bin",
"monthly"), delay = NULL, verbose = TRUE, n_cores = 1)
|
age_death |
numeric vector giving the age of death in months of each
child. Note that if the child is still alive at the time of interview,
corresponding elements of |
birth_int |
numeric vector giving the time in month between the child's birth and the interview |
cluster_id |
vector giving the cluster identifier (can be numeric, cahracter or factor) |
windows_lower, windows_upper |
numeric vectors giving the non-overlapping lower and upper ages in months of each survival window |
ages_lower, ages_upper |
numeric vectors giving the non-overlapping lower and upper ages in months of the age windows for which to estimate mortality rates |
nperiod |
the number of consecutive periods to calculate for. I.e.
if |
period |
the length of time in months for which mortality rates should be estimated - scalar |
period_end |
an optional |
interview_dates |
an optional vector of |
method |
the method used to tabulate exposures and deaths, either by
combining monthly exposures within the window ( |
cohorts |
the number of cohorts used to tabulate exposures and deaths
for each age bins. If |
inclusion |
which individuals to include in each cohort:
|
mortality |
whether to aggregate births/deaths or mortality to return
mortality across each age bin (if |
delay |
the length of time in months prior to the interview date
to end the (last) period (I.e. the period runs from |
glm |
whether to infer the window-specific survival probabilities
using a binomial random effects model across cluster, window and cohort.
If |
verbose |
whether to regularly report the stage of the analysis |
n_cores |
the number of cores on which to carry out computations.
|
... |
other arguments to pass to |
periodMortality
: a list with one element for each period,
each element being a dataframe with the same number of columns as elements
in ages_lower
, each column giving the estimated mortality rates for
the corresponding age bin in each cluster.
periodTabulate
: a dataframe with number of rows equal to all combinations of
clusters, age bins and periods; i.e.
length(unique(cluster_id)) * length(windows_lower) * nperiod
,
and four columns:
cluster_id
identifier for the cluster
exposed
number exposed in a given period and age bin
died
number exposed and died in a given period and age bin
period
the corresponding period number
age_bin
the corresponding age bin number
These functions enable reconstruction of the DHS three-cohort method,
as well as the IHME method, for estimating period mortality rates via
specification of the method
,cohorts
and inclusion
arguments. For the IHME method, the user should specify:
method = 'monthly', cohorts = 'one', inclusion = 'enter'
and for the DHS method:
method = 'direct', cohorts = 'three', inclusion = 'both'
.
Note that mixing and matching these argument in other ways will likely not
lead to sane mortality rate estiamtes, since indivivduals could be recorded
multiple times.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | # set seed for reproducibility
set.seed(1)
# make fake mortality data
n <- 1000
birth_int <- rpois(n, 100)
age_death <- rpois(n, exp(rnorm(n, 2)))
cluster_id <- sample(1:5, n, replace = TRUE)
# if any children died after the interview, their age at death chouls be
# recorded as being higher than the upper window max
age_death[age_death > birth_int] <- 6000
# run with default settings
ans <- periodTabulate(age_death,
birth_int,
cluster_id)
head(ans)
# use four age bins
ans <- periodTabulate(age_death,
birth_int,
cluster_id,
windows_lower = c(0, 1, 12, 36),
windows_upper = c(0, 11, 35, 59))
head(ans)
# DHS method for four age bins
ans <- periodTabulate(age_death,
birth_int,
cluster_id,
windows_lower = c(0, 1, 12, 36),
windows_upper = c(0, 11, 35, 59),
method = 'direct',
cohorts = 'three',
inclusion = 'both')
head(ans)
# IHME method for four age bins
ans <- periodTabulate(age_death,
birth_int,
cluster_id,
windows_lower = c(0, 1, 12, 36),
windows_upper = c(0, 11, 35, 59),
method = 'monthly',
cohorts = 'one',
inclusion = 'enter')
head(ans)
# IHME method for four age bins, tabulating monthly exposures
ans <- periodTabulate(age_death,
birth_int,
cluster_id,
windows_lower = c(0, 1, 12, 36),
windows_upper = c(0, 11, 35, 59),
method = 'monthly',
cohorts = 'one',
inclusion = 'enter',
mortality = 'monthly')
head(ans)
# calculate mortality rates over fixed periods
# assign an interview date to each cluster
(int_date_cluster <- Sys.Date() - rpois(5, exp(rnorm(5, 6))))
int_date <- int_date_cluster[cluster_id]
# & define the final month of the final estimation period
# E.g. for 3x 5-year bins starting in 2000, the final period would end in
# December 2014
ans <- periodTabulate(age_death,
birth_int,
cluster_id,
windows_lower = c(0, 1, 12, 36),
windows_upper = c(0, 11, 35, 59),
method = 'monthly',
cohorts = 'one',
nperiod = 3,
period = 60,
period_end = as.Date('2014-12-01'),
interview_dates = int_date,
inclusion = 'enter',
mortality = 'monthly')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.