get.incidence: Compute incidence

Description Usage Arguments Details Value Author(s) Examples

Description

get.incidence is a generic function with a method for Date, obkData, obkSequences and obkContacts objects. In obkSequences and obkContacts objects, it uses collection/occurence dates to derive incidence data. In obkData, more options are available as different types of information can be used. The procedure looks for a time-stamped data with a given named field, and as an option allows for selecting specific dates based on the values of that field, provided as a range (numeric data), a list of retained values, or a regular expression. This allows for defining 'positives' in a flexible way.

In all procedures, one can specify the first and last date, as well as the time interval to be used.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
get.incidence(x, ...)

## S4 method for signature 'Date'
get.incidence(x, from=NULL, to=NULL,
          interval=1, add.zero=TRUE, ...)

## S4 method for signature 'obkSequences'
get.incidence(x, from=NULL, to=NULL,
          interval=1, add.zero=TRUE, ...)

## S4 method for signature 'obkContacts'
get.incidence(x, from=NULL, to=NULL,
          interval=1, add.zero=TRUE, ...)

## S4 method for signature 'obkData'
get.incidence(x, data, where=NULL,
          val.min=NULL, val.max=NULL, val.kept=NULL, regexp=NULL,
          from=NULL, to=NULL,
          interval=1, add.zero=TRUE, ...)

Arguments

x

an input object to seek incidence from.

from

the first date to be considered, in Date format, or a character string in the form 'YYYY-mm-dd' (e.g. 1982-08-20); if numeric, will be interpreted as number of days from the first date.

to

the last date to be considered, in Date format, or a character string in the form 'YYYY-mm-dd' (e.g. 1982-08-20); if numeric, will be interpreted as number of days from the first date.

interval

the time interval to be used to computed incidence, in number of days.

add.zero

a logical indicating if a zero should be added at the end of the output.

data

a character string indicating the name of the data field to look for, as in get.data.

where

an optional character string indicating the where the data field should be looked for, as in get.data.

val.min

an optional numeric value indicating the minimum value of the data to be retained in the incidence (e.g. minimum body temperature).

val.max

an optional numeric value indicating the maximum value of the data to be retained in the incidence (e.g. maximum CD4 counts).

val.kept

an optional vector containing all values to be retained in the incidence.

regexp

an optional character string providing a regular expression to be used to select which data are used in the incidence.

...

further arguments to be passed to 'grep', for the obkData procedure.

Details

Incidence is computed for intervals (\[D1;D2\[) which are named after the first date (D1), including the first date, and excluding the second one (D2).

Value

A data.frame with two columns, the first one being dates in the Date format, and the second being integers giving the incidence (number of new items for that date).

Author(s)

Thibaut Jombart t.jombart@imperial.ac.uk.

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
## SIMPLE EXAMPLE ##
dates <- as.Date("2001-01-01") + c(0,1,2,1,1,4)
get.incidence(dates)
get.incidence(dates, interval=2)
get.incidence(dates, interval=2, from="2001-01-03")

## OBKDATA/OBKCONTACTS/OBKSEQUENCES OBJECTS ##
data(ToyOutbreak)

## incidence of DNA sequences collection
get.incidence(ToyOutbreak, "dna")
plot(get.incidence(ToyOutbreak, "dna"), type="s",
     main="Incidence of DNA sequences collection")

## incidence of contacts
get.incidence(ToyOutbreak, "contacts")
plot(get.incidence(ToyOutbreak, "contacts"), type="s",
     main="Incidence of contact occurence")


## incidence of temperature measurements
get.incidence(ToyOutbreak, "temperature")

## same, keeping temperatures above 39
get.incidence(ToyOutbreak, "temperature", val.min=39)
plot(get.incidence(ToyOutbreak, "temperature", val.min=39),
     type="s", main="Incidence: temperature>=39")

## same, temperature>40, interval=2days
inc <- get.incidence(ToyOutbreak, "temperature", val.min=40, interval=2)
plot(inc, type="s", main="Incidence: temperature>=40")

thibautjombart/OutbreakTools documentation built on Oct. 26, 2019, 10:56 p.m.