get.age.beta: Get Beta parameters for age groups

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/hmob_funcs.R

Description

This function finds the two shape parameters for the Beta distribution for aggregated age groups given individual-level vaccination data. The individual-level data is comprised of the age of the individual (age) and a binary indicator of vaccination status (vacc). The function first uses a Binomial GAM to estimate the mean (mu) and variance (sigma) of the proportion vaccinated for each of the defined age groups and then finds the shape parameters of the Beta distribution analytically using get.beta.params.

Usage

1
get.age.beta(age = NULL, vacc = NULL, breaks = NULL)

Arguments

age

a vector giving the age at vaccination of each individual

vacc

a binary vector indicating the vaccination status of each individual

breaks

a scalar or vector of age group breaks (passed to .bincode). If NULL (default), calculates Beta parameters for all data together.

Details

Note that a Binomial GLM is used if the number of age groups is 2 or less.

Value

A dataframe containing the sample size, mu, sigma, and Beta distribution paramters for each age group

Author(s)

John Giles

See Also

Other simulation: calc.hpd(), calc.prop.inf(), calc.prop.remain(), calc.timing.magnitude(), calc.wait.time(), decay.func(), get.beta.params(), sim.TSIR.full(), sim.TSIR(), sim.combine.dual(), sim.combine(), sim.gravity.duration(), sim.gravity(), sim.lambda(), sim.pi(), sim.rho(), sim.tau()

Other susceptibility: calc.prop.vacc.SIA(), calc.prop.vacc(), get.beta.params()

Examples

 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
# DHS vaccination coverage file downloaded from the website 
dhs <- read.csv('./data/Namibia2013.csv', stringsAsFactors=FALSE) 

# For all observations together (population mean)
tmp <- get.age.beta(age=dhs$age.in.months,
                    vacc=dhs$measles.y,
                    breaks=NULL)


# Two age groups < 12 months and > 12 months
tmp <- get.age.beta(age=dhs$age.in.months,
                    vacc=dhs$measles.y,
                    breaks=12)

par(mfrow=c(1,2))
for(i in 1:2) curve(dbeta(x, tmp$shape1[i], tmp$shape2[i]), 0, 1)


# 6-month age groups
tmp <- get.age.beta(age=dhs$age.in.months,
                    vacc=dhs$measles.y,
                    breaks=seq(0, 60, 6))

par(mfrow=c(2,5))
for(i in 1:10) curve(dbeta(x, tmp$shape1[i], tmp$shape2[i]), 0, 1)


# Each unique age in months
tmp <- get.age.beta(age=dhs$age.in.months,
                    vacc=dhs$measles.y,
                    breaks=seq(0, 60, 1))

par(mfrow=c(1,1))
plot(tmp$mu, type='l')


# 3-month age groups for each region
tmp <- foreach(i=unique(dhs$region.residence), .combine='rbind') %do% {
     
     sel <- dhs$region.residence == i
     
     cbind(
          data.frame(region=i),
          get.age.beta(age=dhs$age.in.months[sel],
                       vacc=dhs$measles.y[sel],
                       breaks=seq(0, 60, 3))
     )
}

gilesjohnr/hmob documentation built on Aug. 8, 2020, 1:26 a.m.