calc.hpd: Calculate HPD of aggregated waiting time distributions

Description Usage Arguments Value Author(s) See Also Examples

View source: R/hmob_funcs.R

Description

This function calculates the highest posterior density (HPD) interval for the aggregated waiting time distributions returned by the calc.wait.time function. The function calculates the maximum of each aggregated probability distribution along with the HPD intervals given by ci. Code adapted from the hpd function in the TeachingDemos package.

Usage

1
calc.hpd(x, ci = 0.95)

Arguments

x

aggregated waiting time distributions for each district (output from calc.wait.time)

ci

a scalar or vector giving the HPD intervals to be calculated (default = 0.95)

Value

a dataframe

Author(s)

John Giles

See Also

Other simulation: calc.prop.inf(), calc.prop.remain(), calc.timing.magnitude(), calc.wait.time(), decay.func(), get.age.beta(), 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()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
load("./output/simulations/13/influenza.Rdata")

x <- sim$B$wait.time   # basic gravity model
#x <- sim$R$wait.time   # gravity model with duration 

agg <- calc.wait.time(x)
hpd <- calc.hpd(agg, ci=c(0.5, 0.95))

par(mfrow=c(3,4))
for (i in 1:nrow(hpd)) {
     plot(agg[i,], type='l', main=paste("district ", hpd$district[i]), ylab='Waiting time density')
     abline(v=hpd$lo95[i], lty=2, col='red')
     abline(v=hpd$hi95[i], lty=2, col='red')
     abline(v=hpd$max[i], col='red')
}

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