calculate_stratified_prevalence: Title

Description Usage Arguments Value Examples

Description

description...

Usage

1
2
calculate_stratified_prevalence(data, stratify.vars, pops = NULL,
  region.head = "region", conf.level = 0.95, scale = 1)

Arguments

data

A line list-type data frame (one line per case), including a column with the region in which the case occurred and columns with stratification variables.

stratify.vars

A vector of strings containing the names of the column specifying the stratification variables. These columns should be factors.

pops

A data frame containing one line per region/stratification variable combination in data. The first column should give the region name, then should come the stratification variables, and finally the population size in that region and stratum. If pops is NULL, the population in each area and stratum is taken as 1, and numbers of cases (rather than prevalences) are calculated.

region.head

A string containing the name of the column specifying the region for each case.

conf.level

Level of confidence interval required for prevalence estimates.

scale

Scaling with which to report prevalence (per head, per 100 000, etc.)

Value

A list containing 1) prevalence.list, a list of data frames containing total population, number of cases and prevalence by region, for each unique combination of stratification variables. 2) stratification.levels, a vector of the stratification levels, in the same order that the stratified prevalence data frames are presented.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
my.data <- data.frame(	county.id = ceiling(3*runif(10)),
                     	age = rlnorm(10),
							sex = factor(floor(2*runif(10)), levels=c(0,1), labels=c("male", "female"))
                     )

my.data$age.group = floor(my.data$age)
my.populations <- my.data[!duplicated(my.data[,c(1,3,4)]),]
my.populations$population <- nrow(my.data) + ceiling(abs(rnorm(nrow(my.populations), 10, 5)))

# example without any population data
calculate_stratified_prevalence(my.data, stratify.vars=c("sex", "age.group"), region.head="county.id")

# example with stratified population data
calculate_stratified_prevalence(my.data, stratify.vars=c("sex", "age.group"), pops=my.populations, region.head="county.id")

Hackout2/mapData documentation built on May 6, 2019, 9:48 p.m.