Learn R Programming

surveillance (version 1.5-4)

nowcast: Adjust observed epidemic curve for reporting delay of cases

Description

Nowcasting can help to obtain up-to-date information on epidemic trends during an outbreak situation, when reports about important indicators (such as hospitalizations) only arrive with delay. Note: This function is experimental and currently does not deal with right-truncation of the observations. An improved version is to be expected.

Usage

nowcast(s, t, D, dEventCol = "dHospital", dReportCol = "dReport",
          method = c("freq.pi","bayes.nb","bayes.betapi","bayes.bnb","uniform"),
          aggregate.by="1 day",
          control = list(
            dRange = NULL,
            timeDelay = function(d1,d2) {as.numeric(d2-d1)},
            estimateF = NULL,
            alpha = 0.05,
            y.prior.max = 300,
            B = 1e5, 
            score = FALSE, PMF=FALSE, sts.truth=FALSE))

Arguments

s
an object of class Date denoting the day at which to do the nowcast
t
a vector of Date objects denoting the day(s) for which the projections are to be done. One needs to ensure t
D
A data frame with one row per case -- for each case on needs information on the day of the event (e.g. hospitalization) and the day of report of this event.
dEventCol
The name of the column in D which contains the date of the event, e.g. hospitalization. Default: "dHospital".
dReportCol
Name of the column in D containing the date at which the report arrives at the respective register. Default: "dReport".
method
A vector of strings denoting the different methods to use. Note that results of the first name in this list are officially returned by the function. However, it is possible to specify several methods here, e.g. in order to compare score evaluations.
aggregate.by
Time scale used for the temporal aggregation of the records in the data D. See linelist2sts and seq.Date for further information.
control
A list with named arguments controlling the functionality of the nowcasting. [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Value

  • nowcast returns an object of "stsBP". The upperbound slot contains the median of the method specified at position one of the argument method.

encoding

latin1

Details

No details currently available.

References

Donker T, van Boven M, van Ballegooijen WM, Van't Klooster TM, Wielders CC, Wallinga J. (2011), Nowcasting pandemic influenza A/H1N1 2009 hospitalizations in the Netherlands, Eur J Epidemiol. 2011 Mar;26(3):195-201. Epub 2011 Mar 18.

an der Heiden M, Wadl M, H�hle{Hoehle} M (2011), Now-Casting during a huge outbreak of haemolytic-uremic syndrome in Germany 2011, Abstracts of the ESCAIDE conference, Stockholm, Sweden, 6-8 Nov, 2011.

Examples

Run this code
#Load simulated outbreak data.
url <- paste("http://www.stat.uni-muenchen.de/~hoehle/",
             "teaching/moid2011/tutorials/cast-backnow/outbreak.txt",sep="")
D <- try(read.table(url,header=TRUE,colClasses=c("integer",rep("Date",3))))

if (!inherits(D, "try-error")) {
    s <- as.Date("2011-06-02") ;
    k <- 10 ; l <- 3
    t <- seq(s-k-l+1,s-l,by="1 day")
    dRange <- as.Date(c("2011-05-01","2011-07-10"))

    #Perform the nowcast
    nc <- nowcast(s=s,t=t,D=D,dEventCol="dHospital",dReportCol="dRegister",
                  method="bayes.nb",aggregate.by="1 day",control=list(dRange=dRange))

    #Show result
    plot(nc,xaxis.years=FALSE,dx.upperbound=0,legend=NULL,lty=c(1,1,1),
            lwd=c(1,1,2),ylab="Cases",xlab="Time (days)",main="",
            ylim=c(0,max(nc@ci,na.rm=TRUE)))
    idx <- max(which(!is.na(upperbound(nc))))
    lines( c(idx-0.5,idx+0.5), rep(upperbound(nc)[idx,],2),lwd=2,col="blue")

    ##Show CIs
    for (i in 1:nrow(nc)) {
      points(i, upperbound(nc)[i,], col="indianred")
      lines( i+c(-0.3,0.3), rep(nc@ci[i,,1],2),lty=1,col="indianred2")
      lines( i+c(-0.3,0.3), rep(nc@ci[i,,2],2),lty=1,col="indianred2")
      lines( rep(i,each=2), nc@ci[i,,],lty=2,col="indianred2")
    }
    #Add "now" on the x-axis
    points( as.numeric(s-dRange[1])+1,0,pch=10,cex=1.5,col="red")
}

Run the code above in your browser using DataLab