Title: | Fit a Two-Component Epidemic Count Model using MCMC |
---|---|
Description: | Fits a negative-binomial epidemic model as described in Held et al. (2006) <doi:10.1093/biostatistics/kxj016> to a univariate time series of counts. The "quick & dirty" C++ code implementing 'algo.twins()' was previously distributed as part of the R package 'surveillance' (up to version 1.23.1) but is now archived in this stand-alone package. |
Authors: | Mathias Hofmann [aut], Michael Hoehle [aut] , Volker Schmid [aut], Michaela Paul [ctb], Daniel Sabanes Bove [ctb], Sebastian Meyer [cre, ctb] |
Maintainer: | Sebastian Meyer <[email protected]> |
License: | GPL-2 |
Version: | 0.1 |
Built: | 2024-12-08 05:46:49 UTC |
Source: | https://codeberg.org/EE-hub/twins |
Fits a negative-binomial model as described in Held et al. (2006) to a univariate time series of counts.
algo.twins(disProgObj, control=list(burnin=1000, filter=10, sampleSize=2500, noOfHarmonics=1, alpha_xi=10, beta_xi=10, psiRWSigma=0.25,alpha_psi=1, beta_psi=0.1, nu_trend=FALSE, logFile="twins.log"))
algo.twins(disProgObj, control=list(burnin=1000, filter=10, sampleSize=2500, noOfHarmonics=1, alpha_xi=10, beta_xi=10, psiRWSigma=0.25,alpha_psi=1, beta_psi=0.1, nu_trend=FALSE, logFile="twins.log"))
disProgObj |
object of class |
control |
control object:
|
Returns an object of class atwins
with elements
control |
specified control object |
disProgObj |
specified |
logFile |
contains the returned samples of the parameters |
logFile2 |
contains the sample means of the variables |
This function is not a surveillance algorithm, but only a modelling approach as described in the Held et. al (2006) paper.
Note also that the function writes three logfiles in the current
working directory getwd()
: ‘twins.log’,
‘twins.log.acc’ and ‘twins.log2’.
Thus you need to have write permissions in the current working
directory.
M. Hofmann and M. Hoehle with contributions by M. Paul, D. Sabanes Bove and S. Meyer
Held, L., Hofmann, M., Hoehle, M. and Schmid V. (2006) A two-component model for counts of infectious diseases. Biostatistics, 7, 422–437. doi:10.1093/biostatistics/kxj016.
# Load the data used in the Held et al. (2006) paper data("hepatitisA") # Fix seed - this is used for the MCMC samplers in twins set.seed(123) # Call algorithm and save result (use short chain without filtering for speed) oldwd <- setwd(tempdir()) # where logfiles will be written otwins <- algo.twins(hepatitisA, control=list(burnin=500, filter=1, sampleSize=1000)) setwd(oldwd) # This shows the entire output (use ask=TRUE for pause between plots) if (requireNamespace("surveillance")) plot(otwins, ask=FALSE) # Direct access to MCMC output hist(otwins$logFile$psi,xlab=expression(psi),main="") if (require("coda")) print(summary(mcmc(otwins$logFile[,c("psi","xipsi","K")])))
# Load the data used in the Held et al. (2006) paper data("hepatitisA") # Fix seed - this is used for the MCMC samplers in twins set.seed(123) # Call algorithm and save result (use short chain without filtering for speed) oldwd <- setwd(tempdir()) # where logfiles will be written otwins <- algo.twins(hepatitisA, control=list(burnin=500, filter=1, sampleSize=1000)) setwd(oldwd) # This shows the entire output (use ask=TRUE for pause between plots) if (requireNamespace("surveillance")) plot(otwins, ask=FALSE) # Direct access to MCMC output hist(otwins$logFile$psi,xlab=expression(psi),main="") if (require("coda")) print(summary(mcmc(otwins$logFile[,c("psi","xipsi","K")])))
Weekly number of reported hepatitis A infections in Germany 2001-2004.
data("hepatitisA")
data("hepatitisA")
A "disProg"
object containing
observations starting from week 1 in 2001 to week 52 in 2004.
Robert Koch-Institut: SurvStat: https://survstat.rki.de/; Queried on 11-01-2005.
data("hepatitisA") str(hepatitisA) if (requireNamespace("surveillance")) plot(hepatitisA)
data("hepatitisA") str(hepatitisA) if (requireNamespace("surveillance")) plot(hepatitisA)
algo.twins
ModelsPlot results of fitting a twins model using MCMC output. Plots similar to those in the Held et al. (2006) paper are generated.
## S3 method for class 'atwins' plot(x, which=c(1,4,6,7), ask=TRUE, ...)
## S3 method for class 'atwins' plot(x, which=c(1,4,6,7), ask=TRUE, ...)
x |
An object of class |
which |
a vector containing the different plot types to show
|
ask |
Boolean indicating whether to ask for a newline before showing the next plot (only if multiple are shown). |
... |
Additional arguments for |
For details see the plots in the paper. Basically MCMC output is
visualized. This function is experimental, as is algo.twins
.
M. Hofmann and M. Hoehle
Held, L., Hofmann, M., Hoehle, M. and Schmid V. (2006) A two-component model for counts of infectious diseases. Biostatistics, 7, 422–437. doi:10.1093/biostatistics/kxj016.
algo.twins
(with an example)