## Use the nbResults data frame included in the package which has the results
## of the nbProbabilities() function on a TB-like outbreak.
## Getting initial estimates of the reproductive number
# (without specifying rangeForAvg and without confidence intervals)
rInitial <- estimateR(nbResults, dateVar = "infectionDate",
indIDVar = "individualID", pVar = "pScaled",
timeFrame = "months")
## Finding the stable portion of the outbreak for rangeForAvg using plot of Rt
cut1 <- 25
cut2 <- 125
# Optional plot to determine the cutpoints above
# ggplot(data = rInitial$RtDf, aes(x = timeRank, y = Rt)) +
# geom_point() +
# geom_line() +
# geom_hline(data = rInitial$RtAvgDf, aes(yintercept = RtAvg), size = 0.7) +
# geom_vline(aes(xintercept = cut1), linetype = 2, size = 0.7) +
# geom_vline(aes(xintercept = cut2), linetype = 2, size = 0.7)
## Finding the final reproductive number estimates with confidence intervals
# NOTE should run with bootSamples > 2.
rFinal <- estimateR(nbResults, dateVar = "infectionDate",
indIDVar = "individualID", pVar = "pScaled",
timeFrame = "months", rangeForAvg = c(cut1, cut2),
bootSamples = 2, alpha = 0.05)
rFinal$RtAvgDf
Run the code above in your browser using DataLab