This action might not be possible to undo. Are you sure you want to continue?

Welcome to Scribd! Start your free trial and access books, documents and more.Find out more

July 9, 2010

Version 0.5-6 Date 2010-07-09 Title Epidemiology Tools Author Tomas Aragon <aragon@berkeley.edu> Maintainer Tomas Aragon <aragon@berkeley.edu> Depends R (>= 2.1.0) Description EpiTools: R Package for Epidemiologic Data and Graphics License GPL (>= 2) URL http://www.medepi.com Repository CRAN Date/Publication 2010-07-09 08:50:29

R topics documented:

ageadjust.direct . ageadjust.indirect as.hour . . . . . . as.month . . . . . as.week . . . . . binom.conf.int . . colorbrewer . . . colors.plot . . . . epicurve . . . . . epidate . . . . . . epitab . . . . . . epitable . . . . . expand.table . . . expected . . . . . julian2date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 4 6 8 10 13 14 16 17 24 26 29 31 32 34

2 kapmeier . . oddsratio . . or.midp . . . ormidp.test . oswego . . . pois.conf.int . rate2by2.test . rateratio . . . ratetable . . . riskratio . . . tab2by2.test . table.margins wcgs . . . . . wnv . . . . . Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ageadjust.direct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 36 39 41 42 43 45 47 49 51 54 56 57 58 59

ageadjust.direct

Age standardization by direct method, with exact conﬁdence intervals

Description Calculates age standardized (adjusted) rates and "exact" conﬁdence intervals using the direct method Usage ageadjust.direct(count, pop, rate = NULL, stdpop, conf.level = 0.95) Arguments count pop rate stdpop conf.level Details To make valid comparisons between rates from different groups (e.g., geographic area, ethnicity), one must often adjust for differences in age distribution to remove the confounding affect of age. When the number of events or rates are very small (as is often the case for local area studies), the normal approximation method of calculating conﬁdence intervals may give a negative number for the lower conﬁdence limit. To avoid this common pitfall, one can approximate exact conﬁdence intervals. This function implements this method (Fay 1997). Original function written by TJ Aragon, based on Anderson, 1998. Function re-written and improved by MP Fay, based on Fay 1998. vector of age-speciﬁc count of events vector of age-speciﬁc person-years or population estimates vector of age-speciﬁc rates vector of age-speciﬁc standarad population conﬁdence level (default = 0.95)

ageadjust.direct Value crude.rate adj.rate lci uci Note Visit http://www.epitools.net for the latest. Author(s) crude (unadjusted) rate age-adjusted rate lower conﬁdence interval limit upper conﬁdence interval limit

3

Michael P. Fay, <mfay@niaid.nih.gov>; Tomas Aragon, <aragon@berkeley.edu>, http: //www.medepi.com References Fay MP, Feuer EJ. Conﬁdence intervals for directly standardized rates: a method based on the gamma distribution. Stat Med. 1997 Apr 15;16(7):791-801. PMID: 9131766 Steve Selvin. Statistical Analysis of Epidemiologic Data (Monographs in Epidemiology and Biostatistics, V. 35), Oxford University Press; 3rd edition (May 1, 2004) Anderson RN, Rosenberg HM. Age Standardization of Death Rates: Implementation of the Year 200 Standard. National Vital Statistics Reports; Vol 47 No. 3. Hyattsville, Maryland: National Center for Health Statistics. 1998, pp. 13-19. Available at http://www.cdc.gov/nchs/ data/nvsr/nvsr47/nvs47_03.pdf. See Also See also ageadjust.indirect Examples

## Data from Fleiss, 1981, p. 249 population <- c(230061, 329449, 114920, 39487, 14208, 3052, 72202, 326701, 208667, 83228, 28466, 5375, 15050, 175702, 207081, 117300, 45026, 8660, 2293, 68800, 132424, 98301, 46075, 9834, 327, 30666, 123419, 149919, 104088, 34392, 319933, 931318, 786511, 488235, 237863, 61313) population <- matrix(population, 6, 6, dimnames = list(c("Under 20", "20-24", "25-29", "30-34", "35-39", "40 and over"), c("1", "2", "3", "4", "5+", "Total"))) population count <- c(107, 141, 60, 40, 39, 25, 25, 150, 110, 84, 82, 39, 3, 71, 114, 103, 108, 75, 1, 26, 64, 89, 137, 96, 0, 8, 63, 112, 262, 295, 136, 396, 411, 428, 628, 530) count <- matrix(count, 6, 6, dimnames = list(c("Under 20", "20-24", "25-29", "30-34", "35-39", "40 and over"), c("1", "2", "3", "4", "5+", "Total"))) count

95) Arguments count pop stdcount stdpop stdrate conf.direct(count[.indirect Age standardization by indirect method. 1.order5p<-ageadjust.1) birth.population[.1) birth.order5p.3].order1.order1<-ageadjust.95) . 1997 birth.direct(count[.4].direct(count[.level = 0. pop. stdpop.stdpop=standard) round(10^5*birth.stdpop=standard) round(10^5*birth.population[.population[.direct(count[.population[.level vector of age-speciﬁc count of events vector of age-speciﬁc person-years or population estimates vector of age-speciﬁc standard counts vector of age-speciﬁc standarad population vector of age-speciﬁc standard rates conﬁdence level (default = 0.direct(count[. mean) standard ### This recreates Table 1 of Fay and Feuer.5].stdpop=standard) round(10^5*birth.1]. with exact conﬁdence intervals Description Calculates age standardized (adjusted) rates and "exact" conﬁdence intervals using the indirect method Usage ageadjust.1) birth.1) ageadjust.order2.3].order2<-ageadjust.4 ageadjust.order4<-ageadjust.5].2].order3<-ageadjust.order3.stdpop=standard) round(10^5*birth.2].1].4]. stdrate = NULL.order4.indirect ### Use average population as standard standard<-apply(population[.indirect(count.stdpop=standard) round(10^5*birth.population[. stdcount.-6]. conf.1) birth.

direct Examples ##From Selvin (2004) ##enter data dth60 <.indirect Details 5 To make valid comparisons between rates from different groups (e.ageadjust. 13-19.scan() 45 201 320 670 1126 3160 9723 17935 22179 13461 2238 observed. Hyattsville. and conﬁdence interval crude.cdc. Vol 47 No.edu>. Maryland: National Center for Health Statistics.scan() 141 926 1253 1080 1869 4891 14956 30888 41725 26501 5928 pop60 <. 3. 35).gov/nchs/ data/nvsr/nvsr47/nvs47_03. V. 2004) See Also See also ageadjust.rate.crane@doh.net for the latest Author(s) Tomas Aragon. Rosenberg HM. Steve Selvin.com. expected.pdf.state. When the number of events or rates are very small (as is often the case for local area studies)..nj. the normal approximation method of calculating conﬁdence intervals may give a negative number for the lower conﬁdence limit. ethnicity).epitools. pp. This function implements this method (Anderson 1998). Available at http://www. standardized incidence ratio.g.scan() 1784033 7065148 15658730 10482916 9939972 10563872 9114202 6850263 4702482 1874619 330915 dth40 <.medepi. National Vital Statistics Reports. To avoid this common pitfall. Oxford University Press. and conﬁdence interval . 3rd edition (May 1. one can approximate exact conﬁdence intervals. adjusted rate.indirect’ function. 1998. Age Standardization of Death Rates: Implementation of the Year 200 Standard. geographic area. http://www. References Anderson RN. Thanks to Giles Crane (<giles. <aragon@berkeley.us>) for reporting error in ’ageadjust. one must often adjust for differences in age distribution to remove the confounding affect of age. Value $sir $rate Note Visit http://www. Statistical Analysis of Epidemiologic Data (Monographs in Epidemiology and Biostatistics.

hour = FALSE) Arguments x mindt Date-time object in standard format: for example. "45-54".direct' dsr <.hour(x..dth60/pop60 rate40 <. stdpop = pop60) round(100000*dsr. "2004-12-23" [required] Date-time object in standard format that will form the lower boundary of the hour or half-hour time categories. dth40. round(rate60*100000.hour #create array for display tab <. pop = pop40.indirect' isr <.000 per year ##implement indirect age standardization using 'ageadjust. "Rate"). "65-74".ageadjust. "1940")) tab ##implement direct age standardization using 'ageadjust.c(11. 2) ##standarized incidence ratio round(100000*isr$rate. 1) ##rate per 100.g.scan() 906897 3794573 10003544 10629526 9465330 8249558 7294330 5022499 2920220 1019504 142532 ##calculate age-specific rates rate60 <. half. "35-44". "1-4".000 per year as. pop40. "5-14". "Population". .hour Convert date-time object into hour units Description Convert date-time object into hour or half-hour units Usage as.list(agelabs.2)) agelabs <. maxdt. HH:00:00) or rounded off to the nearest half-hour for half-hour categories (e.. "85+") dimnames(tab) <. c("1960". pop = pop40.3. "25-34". 2) ##rate per 100.array(c(dth60.dth40/pop40 as. "2004-12-23 08:27:00". pop60.indirect(count = dth40.ageadjust. "15-24". stdcount = dth60.1)). HH:30:00).c("Deaths". mindt must less than or equal to the minimum value in x.6 pop40 <. "200412-23 08:27". stdpop = pop60) round(isr$sir.c("<1". round(rate40*100000. and must be rounded off to the nearst hour for hour categories (e.direct(count = dth40. "75-84".1).g. "55-64". mindt.

seconds minutes hours (0-23) hours (1-12) number of hours or 1/2 hours since beginning of 1970 factor (categorical variable) with number of hours of 1/2 hours since beginning of 1970 using $cstratum as the levels factor (categorical variable) in standard date-time format indicating number of hours or 1/2 hours since beginning of 1970 using $cstratum2 as the levels levels for creating $stratum2 factor levels for creating $stratum3 factor seconds from $cstratum2 minutes from $cstratum2 hours from $cstratum2 in 24-hour format hours from $cstratum2 in 12-hour format corresponding ’AM’ or ’PM’ for $chour12 corresponding ’am’ or ’pm’ for $chour12 day of the week for $cstratum2 abbreviated day of the week for $cstratum2 day of the month for $cstratum2 month for $cstratum2 abbreviated month for $cstratum2 year for $cstratum2 FALSE (default) for 1-hour categories.g.POSIXct.POSIXlt to convert this output in human legible (already done by this function).. You can use as. maxdt must greater than or equal to the minimum value in x.hour .hour maxdt 7 [required] Date-time object in standard format that will form the upper boundary of the hour or half-hour time categories. HH:00:00) or rounded off to the nearest half-hour for half-hour categories (e. HH:30:00).as. half. Value $ct Date-time object that contains the number of seconds since the beginning of 1970 as a numeric vector and produced by as.. These levels are use for converting x into a factor and for providing names for labeling the x-axis in plot. and (2) generates levels for range of values that that the new 1-hour or 1/2-hour categories can take.hours. and must be rounded off to the nearst hour for hour categories (e. This function is used by epicurves.hour Details This function (1) converts standard date-time objects into 1-hour or 1/2-hour categories. TRUE for 1/2-hour categories $sec $min $hour $hour12 $stratum $stratum2 $stratum3 $cstratum $cstratum2 $csec $cmin $chour $chour12 $campm $campm2 $cweekday $cwkday $cmday $cmonth $cmon $cyear $half.g. Set to TRUE for half-hour categories.

min.Date("1970-01-01"). "1/10/04". "4/6/05". "5/5/04". "1/7/04".as.Date.month Convert dates into months of the year for plotting epidemic curves Description Converts dates into months of the year (1-12). "1/5/05". strptime. before = 31. "7/6/04". abbreviate = TRUE) . "1/12/04". format = "%Y-%m-%d".edu>. max. "1/8/04".8 Note Visit http://www. "1/6/04".month as.date="2003-01-01") aw3 as. "8/18/04".week(dates. epicurve. "1/5/04".dates as. "3/5/04". Author(s) Tomas Aragon. "7/23/05". http://www. "12/13/05".date. NA. format = "%m/%d/%y".month. "1/14/04". "1/9/04". format = "%m/%d/%y".as.week(dates.c("1/1/04". origin = as. min.com References none See Also epitools: as. "1/2/04". format = "%m/%d/%y") aw aw2 <.as. sunday= FALSE) aw2 aw3 <.week(dates.medepi. but also creates range of calendar months that can be used to plot an epidemic curve Usage as. DateTimeClasses Examples dates <.date.month(x.net for the latest. "10/3/05") aw <. <aragon@berkeley. "1/3/04". after = 31. "1/4/04".epitools.

Mar. .. then several days are subtracted from the minimum date in x as speciﬁed by the before option [optional] maximum calendar date for plotting x-axis of an epidemic curve plot. should be f the form of "2004-08-10". etc. if no date is speciﬁed. .. Mar.. then several days are added to the maximum date in x as speciﬁed by the after option if min. Mar. often used for labeling plots This function converts dates to months (1-12).as. should be of the form of "2004-08-10". Feb.g.) for the calendar dates used for plotting the x-axis of the epidemic curve $stratum3 $cmon $cmonth $cstratum $cstratum2 $cmday $cyear .date before after origin abbreviate Details character vector of dates date format of x. 1996. .. default is of form "2004-08-10" [optional] minimum calendar date for plotting x-axis of an epidemic curve..date is not speciﬁed. Feb. Value Returns a list of the following: $dates $mon $month $stratum $stratum2 input dates are converted to standard calendar date format month of the year (1-12) month of the year (Jan.. Feb.. then these number of days are subtracted from the minimum date in x for plotting minimum calendar date for epidemic curve if max.date is not speciﬁed. In addition.) for the calendar dates used for plotting the x-axis of an epidemic curve the Julian date for the mid-month day of the $cmonth value used for plotting the x-axis of an epidemic curve the standard calendar date for the mid-month day of the $cmonth value used for plotting the x-axis of an epidemic curve the day of the mon (1-31) for the calendar dates used for plotting the x-axis of an epidemic curve the years (e.date 9 max. 2001. if no date is speciﬁed.) the Julian date for the mid-month day of the $mon value the Julian date for the mid-month day of the $mon value converted to a factor with levels determined by the Julian dates ($cstratum)used to plot an epidemic curve the mid-month day of the $mon value converted to standard calendar dates the month of the year (1-12) used for plotting the x-axis of the epidemic curve the months (Jan. then these number of days are added to the maximum date in x for plotting maximum calendar date for epidemic curve allows user to specify an alternative origin for Julian dates that are generated by this function (default = "1970-01-01") abbreviate month names to Jan.month Arguments x format min.. a range of calendar months are generated that can be used to plot the x-axis of an epidemic curve.

after = 7. "1/14/04".as.month(dates.dates as. epicurve. "12/13/05". "1/5/04". "5/5/04". NA. "3/5/04". http://www. "1/2/04". "1/8/04".10 Note Visit http://www.week Convert dates object in ’disease week’ for plotting epidemic curves Description Convert dates into "disease week" with values of 1 to 53 for plotting epidemic curves Usage as. format = "%m/%d/%y". <aragon@berkeley. format = "%Y-%m-%d".c("1/1/04". "1/4/04". before = 7. sunday = TRUE) .net for the latest. "1/9/04". DateTimeClasses Examples as.epitools.Date("1970-01-01").com References none See Also epitools: as. "1/6/04". "7/6/04".date. "1/7/04".medepi.week(x. format = "%m/%d/%y") aw aw2 <. Author(s) Tomas Aragon.week dates <. "1/5/05".date="2003-01-01") aw2 as. min. "8/18/04". max.as. "1/3/04". "7/23/05". "1/10/04". "4/6/05".edu>. strptime.month(dates.Date. min. "10/3/05") aw <. "1/12/04".week.date. origin = as.

note that week 52 or 53 can represent both last week of a year but also the ﬁrst few days at the beginning of the year the Julian date for the mid-week day of the $week value the Julian date for the mid-week day of the $week value converted to a factor with levels determined by the Julian dates ($cstratum) used to plot the epidemic curve the mid-week day of the $week value converted to standard calendar dates the week of the year used for plotting the x-axis of an epidemic curve the Julian date for the mid-week day of the $cweek value used for plotting the x-axis of an epidemic curve $stratum3 $cweek $cstratum .week Arguments x format min. should be f the form of "2004-08-10".week functions facilitates working with multiple years and generating epidemic curves. The week before week 1 takes on the value (52 or 53) from the last week of the previous year. then several days are added to the maximum date in x as speciﬁed by the after option if min. the as.date is not speciﬁed. weeks are numbered from 0 to 53 in the same year.date before after origin sunday Details In public health. Value Returns a list of the following: $dates $firstday $week $stratum $stratum2 input dates are converted to standard calendar date format ﬁrst day of the week is reported week of the year (1-53). reportable diseases are often reported by ’disease week’ (either week of reporting or week of symptom onset). then several days are subtracted from the minimum date in x as speciﬁed by the before option [optional] maximum calendar date for plotting x-axis of an epidemic curve plot. if no date is speciﬁed. The ﬁrst day of week 1 starts with either the ﬁrst Sunday or Monday of the year. should be of the form of "2004-08-10". default is of form "2004-08-10" 11 [optional] minimum calendar date for plotting x-axis of an epidemic curve.as.date character vector of dates date format of x. In contrast to R. Days before week 1 are numbered as 0s. if no date is speciﬁed. The as. then these number of days are added to the maximum date in x for plotting maximum calendar date for epidemic curve allows user to specify an alternative origin for Julian dates that are generated by this function (default = "1970-01-01") First day of the week is Sunday (default = TRUE).date is not speciﬁed. In R.week function generates weeks numbered from 1 to 53. then these number of days are subtracted from the minimum date in x for plotting minimum calendar date for epidemic curve if max. setting to FALSE makes Monday the ﬁrst day of the week max.

. "1/8/04".medepi. "1/12/04". min.week the standard calendar date for the mid-week day of the $cweek value used for plotting the x-axis of an epidemic curve the day of the mon (1-31) for the calendar dates used for plotting the x-axis of an epidemic curve the months (Jan.net for the latest. "1/6/04".week(dates. 1996. format = "%m/%d/%y". "1/2/04". "10/3/05") aw <. Feb. http://www. .as. Mar. sunday= FALSE) aw2 aw3 <. "5/5/04".month. "1/3/04". <aragon@berkeley. "1/10/04".dates as. "3/5/04". Author(s) Tomas Aragon. "7/6/04". "1/4/04". "8/18/04". epicurve. "12/13/05"..) for the calendar dates used for plotting the x-axis of an epidemic curve Note Visit http://www. "1/5/04".week(dates.as. NA.as.12 $cstratum2 $cmday $cmonth $cyear as. "1/14/04"..c("1/1/04".. . "1/5/05".edu>. "1/7/04".) for the calendar dates used for plotting the x-axis of an epidemic curve the years (e. format = "%m/%d/%y") aw aw2 <..date="2003-01-01") aw3 . "4/6/05". DateTimeClasses Examples dates <.week(dates.epitools.com References none See Also epitools: as. format = "%m/%d/%y". "7/23/05". "1/9/04".Date.g. 2001. strptime.

conf.level Note Visit http://www.95).conf. This function uses R’s binom. can be a vector conﬁdence level (default = 0. n. however.wilson(x.int 13 binom. Value This function returns a n x 6 matrix with the following colnames: x n prop lower upper conf.conf. can be a vector number of Bernoulli trials. number of successes in n trials number of Bernoulli trials proportion = x/n lower conﬁdence interval limit upper conﬁdence interval limit conﬁdence level number of successes in n trials.net for the latest. n.95) Arguments x n conf. The arguments to this function can be numeric vectors of any length (Rothman).level = 0. binom. conf. binom.test function. calculates conﬁdence intervals for binomial counts or proportions using Wilson’s formula which approximate the exact method. calculates conﬁdence intervals for binomial counts or proportions using a normal approximation to the binomial distribution. conf.exact(x. the arguments to this function can be numeric vectors of any length.level Details The function. The arguments to this function can be numeric vectors of any length. can be a vector .binom. The function.epitools. binom.level = 0.approx. n.int Conﬁdence intervals for binomial counts or proportions Description Calculates conﬁdence intervals for binomial counts or proportions Usage binom.exact.approx(x.95) binom. The function.level = 0.wilson. calculates exact conﬁdence intervals for binomial counts or proportions.95) binom.

Usage colorbrewer.wilson(1:10. 10)) colorbrewer Display and create ColorBrewer palettes Description Display and create ColorBrewer palettes based on Cindy Brewer’s website at www. type = c("qualitative". type = c("qualitative". 100.display(nclass = 5.data() Arguments nclass type col.exact(1:10. binom. et al.approx(1:10. "diverging"). 10)) binom. Oxford University Press. 1st Edition. Epidemiology: An Introduction.bg = "white") colorbrewer.com References colorbrewer Tomas Aragon.edu>. ’sequential’. <aragon@berkeley. seq(10. net Kenneth Rothman (2002). seq(10. "sequential".bg palette number of classes or categories to be compared graphically select either ’qualitative’ (default). "sequential".14 Author(s) Tomas Aragon.test Examples binom. col.org.exact.epitools. http://www. 100. or ’diverging’ set background color (default is white) select palette (letter) from displayed plot . 100. Applied Epidemiology Using R. seq(10.medepi.palette(nclass = 5. See Also pois. Available at http://www. palette = letters[1:18]) colorbrewer.colorbrewer. "diverging"). 10)) binom.

and The Pennsylvania State University.edu>. "sequential". create a color palette for use in R graphics functions (e. First. Third. A more visually appealing display of the ColorBrewer schemes is available in the RColorBrewer package.display(9. and to have the same 3-step selection order as the www.display to display the available ColorBrewer palette for a given type and number of classes. "blue") . colorbrewer. <cbrewer@psu. These functions for epitools were created to make the ColorBrewer palettes readily available to epitools users.colorbrewer. use colorbrewer. http://www.palette returns rgb vector palette Note Visit http://www.colorbrewer Details 15 These R functions includes color speciﬁcations and designs developed by Cynthia Brewer (http: //www.com References ColorBrewer. sequential vs. Fourth. select the type of comparison (qualitative vs. by Cynthia Brewer. Value colorbrewer. Author(s) Tomas Aragon.colorbrewer. where mypal was created from colorbrewer. Copyright and license information at http://www. using the colorbrewer.g. select the number of classes or categories to be compared (nclass). "sequential") ##change background to blue colorbrewer.epitools. Second.org accessed on 2004-11-26 See Also epitools package: colors.colorbrewer.org.org). Note that you can change the background color. col = mypal.edu>. All rights reserved. For more details on color selection please visit this excellent site. <aragon@berkeley. diverging).medepi.palette function.palette). http: //www. Pennsylvanis State University.plot Examples ##display available palettes for given nclass and type colorbrewer. org site. Mark Harrower. The ColorBrewer palettes have been included in this R package with permission of the copyright holder.display(9.net for the latest.display displays ColorBrewer selection and invisibly returns data that corresponds to graphical display colorbrewer. ColorBrewer is Copyright (c) 2002 Cynthia Brewer.

"sequential") cbrewer. To see the matrix it must be assigned an object name and then displayed.matrix can be used alone to create the matrix of name without generating a plot.matrix has no arguments. col = mycolors.colorbrewer. lty = 1.colorbrewer. then R returns the selected color names. type = "q".outer(1:10. right click on the mouse and select ’Stop’.axis change size of axes labels colors.yy. palette = "b") xx <.9s <.matrix() Arguments colors.matrix function is used by colors.palette(10. Details The colors. cex.16 colors.display(9.plot function plots R’s 657 named colors.plot: activates ’locator’ for interactive selection of color names (default is FALSE) locator cex.plot to create the matrix of color names that corresponds to the graph created by colors.plot. To end selection. "*") matplot(xx. type="l". display and choose palette (letter) colorbrewer. The colors. extract and use ColorBrewer palette mycolors <.axis = 0. If locator=TRUE then you can interactively point and click to select the colors for which you want names. 1:10. "q") ##second.plot ##display available palettes for given nclass and type. lwd = 4) colors.plot Plots R’s 657 named colors for selection Description Plots R’s 657 named colors for selection Usage colors.plot(locator = FALSE.1:10 yy <. colors.7) colors.9s ##Display and use ColorBrewer palette ##first. ##but also display RGB numbers to create your own palette cbrewer.palette(nclass = 10. .

epicurve Value

17

colors.plot generates plot with R colors and, when locator=TRUE, returns matrix with graph coordinates and names of colors selected colors.matrix quietly returns matrix of names Note Visit http://www.epitools.net for the latest. Author(s) Tomas Aragon, <aragon@berkeley.edu>, http://www.medepi.com References none See Also colorbrewer.display, colorbrewer.palette, colorbrewer.data colors Examples

##creates matrix with color names cm <- colors.matrix() cm[1:3, 1:3] ##generates plot colors.plot() ##generates plot and activates 'locator' ##don't run ##colors.plot(TRUE)

epicurve

Construct an epidemic curve

Description Construct an epidemic curve

18 Usage epicurve.dates(x, format = "%Y-%m-%d", strata = NULL, min.date, max.date, before = 7, after = 7, width = 1, space = 0, tick = TRUE, tick.offset = 0.5, segments = FALSE, ...)

epicurve

epicurve.weeks(x, format = "%Y-%m-%d", strata = NULL, min.date, max.date, before = 7, after = 7, width = 1, space = 0, tick = TRUE, tick.offset = 0.5, segments = FALSE, origin = as.Date("1970-01-01"), sunday = TRUE, ...) epicurve.months(x, format = "%Y-%m-%d", strata = NULL, min.date, max.date, before = 31, after = 31, width = 1, space = 0, tick = TRUE, tick.offset = 0.5, segments = FALSE, origin = as.Date("1970-01-01"), ...) epicurve.hours(x, mindt, maxdt, strata = NULL, half.hour = FALSE, width = 1, space = 0, tick = TRUE, tick.offset = 0.5, segments = FALSE, ...) epicurve.table(x, width = 1, space = 0, tick = TRUE, tick.offset = 0.5, segments = FALSE, ...)

Arguments x format strata min.date character vector of dates date format of x; default is of form "2004-08-10" [optional] categorical vector (character or factor) for stratifying x [optional] minimum calendar date for plotting x-axis of an epidemic curve; should be of the form of "2004-08-10"; if no date is speciﬁed, then several days are subtracted from the minimum date in x as speciﬁed by the before option [optional] maximum calendar date for plotting x-axis of an epidemic curve; should be of the form of "2004-08-10"; if no date is speciﬁed, then several days are added to the maximum date in x as speciﬁed by the after option if min.date is not speciﬁed, then these number of days are subtracted from the minimum date in x for plotting minimum calendar date for epidemic curve if max.date is not speciﬁed, then these number of days are added to the maximum date in x for plotting maximum calendar date for epidemic curve [required] Date-time object in standard format that will form the lower boundary of the hour or half-hour time categories. The mindt option must less than or equal to the minimum value in x, and must be rounded off to the nearst hour for hour categories (e.g., HH:00:00) or rounded off to the nearest half-hour for half-hour categories (e.g., HH:30:00).

max.date

before after mindt

epicurve maxdt

19 [required] Date-time object in standard format that will form the upper boundary of the hour or half-hour time categories. The maxdt option must greater than or equal to the minimum value in x, and must be rounded off to the nearst hour for hour categories (e.g., HH:00:00) or rounded off to the nearest half-hour for half-hour categories (e.g., HH:30:00). Set to TRUE for half-hour categories in epicurve.hours. width of bars in the epidemic curve; this value is passed to barplot function space between bars in the epidemic curve; this value is passed to barplot function adds tick marks to the x-axis (default = TRUE) offsets tick marks so that they plotted between the bars segments bars so that each box represents one case allows user to specify an alternative origin for Julian dates that are generated by this function (default = "1970-01-01") First day of the week is Sunday (default = TRUE); setting to FALSE makes Monday the ﬁrst day of the week options are passed to the barplot function

half.hour width space tick tick.offset segments origin sunday ... Details

These functions makes plotting epidemic curves much easier in R. Normally, to plot an epidemic curve in R, one must do the following: (1) have disease onset dates in some calendar date format, (2) convert these onset dates into a factor with the levels speciﬁed by the range of calendar dates for the x-axis of the epidemic curve, (3) convert this factor into a table (with or without stratiﬁcation), (4) use this table as an argument in the barplot function to plot the epidemic curve, and (5) make ﬁnal adjustments (labels, titles, etc.). Why use the barplot function? Strictly speaking, an epidemic curve is a histogram displaying the distribution of onset times which are categorized into, for example, dates. However, histogram functions seems to work better for measurements that our continuous (e.g., height, weight). In contrast, epidemic curves are constructed from onset time data that has been categorized into days, weeks, or months. For this type of categorical data, the barplot does a better job. The caveat, however, is that we need to specify the range of possible calendar dates, weeks, or months in order to construct an appropriate plot. To do this we convert the data into a factor with the levels speciﬁed by the possible calendar date values. To make this whole process much easier, and to generate additional data that can be use for labeling your epidemic curve, the epicurve functions were created. Value epicurve.dates returns list: $dates $dates2 input dates are converted to standard calendar date format input dates are also converted to a factor with levels determined by the calendar dates ($cdates) used to plot the epidemic curve

) for the calendar dates used for plotting the x-axis of the epidemic curve epicurve. Feb.. this comes from the barplot function the week of the year used for plotting the x-axis of the epidemic curve the Julian date for the mid-week day of the $cweek value used for plotting the x-axis of the epidemic curve the standard calendar date for the mid-week day of the $cweek value used for plotting the x-axis of the epidemic curve the day of the mon (1-31) for the calendar dates used for plotting the x-axis of the epidemic curve the months (Jan. 1996.. this comes from the barplot function the calendar dates used for plotting the epidemic curve the day of the mon (1-31) for the calendar dates used for plotting the x-axis of the epidemic curve the months (Jan.) for the calendar dates used for plotting the x-axis of the epidemic curve epicurve.. ..weeks returns list: $dates $firstday $week $stratum $stratum2 input dates are converted to standard calendar date format ﬁrst day of the week is reported week of the year (1-53). 1996.. Feb. Mar. .. Mar..) for the calendar dates used for plotting the x-axis of the epidemic curve $stratum3 $xvals $cweek $cstratum $cstratum2 $cmday $cmonth $cyear the years (e.g. Mar..g. note that week 52 or 53 can represent both last week of a year but also the ﬁrst few days at the beginning of the year the Julian date for the mid-week day of the $week value the Julian date for the mid-week day of the $week value converted to a factor with levels determined by the Julian dates ($cstratum) used to plot the epidemic curve the mid-week day of the $week value converted to standard calendar dates x-axis numeric values used for plotting the epidemic curve. .months returns list: $dates $mon $month $stratum $stratum2 input dates are converted to standard calendar date format month of the year (1-12) month of the year (Jan. ...) for the calendar dates used for plotting the x-axis of the epidemic curve the years (e.) the Julian date for the mid-month day of the $mon value the Julian date for the mid-month day of the $mon value converted to a factor with levels determined by the Julian dates ($cstratum)used to plot the epidemic curve . 2001.20 $xvals $cdates $cmday $cmonth $cyear epicurve x-axis numeric values used for plotting the epidemic curve. 2001.. .. Feb.

1996...epicurve $stratum3 $xvals $cmon $cmonth $cstratum $cstratum2 $cmday $cyear the mid-month day of the $mon value converted to standard calendar dates 21 x-axis numeric values used for plotting the epidemic curve. this comes from the barplot function the month of the year (1-12) used for plotting the x-axis of the epidemic curve the months (Jan.. Mar. .) for the calendar dates used for plotting the x-axis of the epidemic curve epicurve.. You can use as.POSIXct.hours returns list: $ct Date-time object that contains the number of seconds since the beginning of 1970 as a numeric vector and produced by as. 2001..) for the calendar dates used for plotting the x-axis of the epidemic curve the Julian date for the mid-month day of the $cmonth value used for plotting the x-axis of the epidemic curve the standard calendar date for the mid-month day of the $cmonth value used for plotting the x-axis of the epidemic curve the day of the mon (1-31) for the calendar dates used for plotting the x-axis of the epidemic curve the years (e. .POSIXlt to convert this output in human legible (already done by this function).g. Feb. seconds minutes hours (0-23) hours (1-12) number of hours or 1/2 hours since beginning of 1970 factor (categorical variable) with number of hours of 1/2 hours since beginning of 1970 using $cstratum as the levels factor (categorical variable) in standard date-time format indicating number of hours or 1/2 hours since beginning of 1970 using levels for creating $stratum2 factor levels for creating $stratum3 factor seconds from $cstratum2 minutes from $cstratum2 hours from $cstratum2 in 24-hour format hours from $cstratum2 in 12-hour format corresponding ’AM’ or ’PM’ for $chour12 corresponding ’am’ or ’pm’ for $chour12 day of the week for $cstratum2 abbreviated day of the week for $cstratum2 day of the month for $cstratum2 $sec $min $hour $hour12 $stratum $stratum2 $stratum3 $xvals $cstratum $cstratum2 $csec $cmin $chour $chour12 $campm $campm2 $cweekday $cwkday $cmday .

sample(c("Male".Date("2004-07-15").dates(x) epicurve.edu>. rep=TRUE) xs <.weeks sampdates <. segments = TRUE) rr . as. 1) x <. as.22 $cmonth $cmon $cyear month for $cstratum2 abbreviated month for $cstratum2 year for $cstratum2 epicurve $half. strata = xs. at = rr$xvals. strptime Examples ##epicurve.epicurve.dates(x. axisnames = FALSE) axis(1. strata = xs) rr <. 100.epitools. http://www. TRUE for 1/2-hour categories epicurve. labels = rr$cmday.hour FALSE (default) for 1-hour categories. labels = rr$cmonth.table returns numeric vector: xvals x-axis numeric values used for plotting the epidemic curve. at = rr$xvals. rep=TRUE) xs <.weeks(x. strata = xs. tick = FALSE.Date("2004-09-15").Date("2004-09-15"). rep=TRUE) epicurve. segments = TRUE."Female"). Author(s) Tomas Aragon.epicurve. 100. this comes from the barplot function Note Visit http://www.seq(as. strata = xs) rr <. 100.sample(c("Male". line = 0) axis(1.com References none See Also barplot.net for the latest. 1) x <. rep=TRUE) epicurve.Date("2004-07-15")."Female").sample(sampdates.weeks(x) epicurve. 100.seq(as.medepi.weeks(x.sample(sampdates.dates sampdates <.dates(x. line = 1) ##epicurve. tick = FALSE. <aragon@berkeley.

NA. "1/4/04".2) axis(1. April 18-19. min.months dates <. "%m/%d/%Y %I:%M %p") meal. "1/7/04". axisnames = FALSE. labels = hlab[hh2]. Cases of Gastrointestinal Illness by Time of Onset of Symptoms (Hour Category) Oswego County. oswego$meal.dt."/1940".as. "#E0F3DB") par. "10/3/05") aw <. "1/14/04". "4/6/05".hours(onset. at = xv$xval[hh]. "1940-04-19 12:00:00". "1/5/05". "1940-04-18 12:00:00". New York. labels = hlab2[hh3]. line = -. "#A8DDB5". xlab = "Time of Onset".c("1/1/04". "3/5/04". las = 1) title(main = "Figure 1.xv$chour12==1 hlab <. "1/9/04".c("#43A2CA".dt[1:10] ## create vector with onset date and time odt <. labels = xv$chour12[hh].xv$cmday) axis(1. line = 1.dt[1:10] ##set colors col3seq.epicurve ##epicurve.3. format = "%m/%d/%y") aw aw2 <.xv$campm2. "5/5/04".sep="") hlab2 <.dt <.time) mdt[1:10] ## convert into standard date and time meal. tick = FALSE. oswego$onset. "1/8/04".month(dates.par()$fin par(fin=c(5. format = "%m/%d/%y".xv$chour12==3 | xv$chour12== 6 | xv$chour12== 9 hh2 <.strptime(mdt. "%m/%d/%Y %I:%M %p") onset.epicurve.date. "7/23/05". axes = FALSE.paste(paste(oswego$onset.hours data(oswego) ## create vector with meal date and time mdt <. "1/6/04". ylim = c(0. "8/18/04". segments = TRUE.sep="").paste(xv$cmonth. tick = FALSE.paste("4/18/1940". "1/10/04".11).d[1].2) axis(1.month(dates. "1/5/04".xv$chour12==12 hh3 <. "1/3/04". "12/13/05". tick = FALSE.paste(xv$chour12. 2004".dt <. at = xv$xval[hh3].time) odt[1:10] ## convert into standard date and time onset. at = xv$xval[hh2].as. strata = oswego$sex) hh <.4)) ##1-hour categories xv <. ylab = "Cases") ##1/2-hour categories . col = col3seq.d <. "7/6/04". "1/2/04". line = -.fin <.strptime(odt.date="2003-01-01") aw2 23 ##epicurve. "1/12/04".0) axis(2.

after = 7. line = 1. axes = FALSE.4. labels = hlab[hh2].table(xmtx) epicurve. seg = TRUE) epidate Convert dates into multiple legible formats Description Convert character vector of dates into multiple legible formats.2) axis(1.d[1]. format = "%m/%d/%Y".table(xvec) xmtx <. Usage epidate(x. xvec) rownames(xmtx) <. tick = FALSE.table(xvec) names(xvec) <. at = xv$xval[hh]. before = 7. axisnames = FALSE.2.xv$campm2. line = -. Cases of Gastrointestinal Illness by Time of Onset of Symptoms (1/2 Hour Category) Oswego County.xv$chour12==12 hh3 <.c("Male".1) epicurve.4. "1940-04-19 12:00:00". half.xv$chour12==1 hlab <.1991:1999 epicurve.table xvec <. segments = TRUE. tick = FALSE.paste(xv$cmonth.dt.fin) ##epicurve. strata = oswego$sex) hh <.3.5. labels = xv$chour12[hh].hours(onset. ylim = c(0.11). "1940-04-18 12:00:00". ylab = "Cases") par(fin=par. labels = hlab2[hh3]. "Female") epicurve.paste(xv$chour12. line = -.epicurve.0) axis(2.xv$chour12==3 | xv$chour12== 6 | xv$chour12== 9 hh2 <.2.24 epidate xv <. at = xv$xval[hh2]. col = col3seq.table(xmtx.sep="") hlab2 <.c(1. tick = FALSE. cal. at = xv$xval[hh3]. sunday = TRUE) . xlab = "Time of Onset".xv$cmday) axis(1. las = 1) title(main = "Figure 2.rbind(xvec. April 18-19.3.hour = TRUE.dates = FALSE. 2004".2) axis(1. New York.

2001.. dates wtih date-time class number of days since 1970-01-01 day of the month: 1-31 month of the year: 0-11 month: January.. Feb. Value dates julian mday mon month month2 firstday week year yr wday weekday wkday yday quarter cdates cjulian Note Visit http://www.. November 12.dates: default is 7 days after latest date in x ﬁrst day of the week is either Sunday (default) or Monday Dates can come in many formats (e.epidate Arguments x format cal.. Wed. day of the year: 0-365 quarter of the year: Q1. graphical displays. ﬁrst day of the week: Sunday or Monday week of the year: 0-53 year: YYYY year: YY day of the week: 0-6 weekday: Monday. generating reports. 12Nov01. 11/12/01. month: Jan. . Tuesday. March.. February. For complete options for the format option see strptime. Q3. There is tremendous ﬂexibility in converting any character vector with sufﬁcient information to be converted into a unique date.dates before after sunday Details character vector of dates to be converted format of character vector of dates 25 Calendar dates that contains x.epitools.g. 200111-12) and need to be converted into other formats for data analysis. starting 7 days ’before’ (default) until 7 days ’after’ x deﬁnes lower limit of cal. ...dates: default is 7 days before earliest date in x deﬁnes upper limit of cal. Q2. etc. Q4 Calendar dates that contains dates Julian calendar dates .net for the latest. Tue... Mar. 11/12/2001. . weekday: Mon. . Wednesday.

epidate(wk2date. TRUE) # ###convert vector of disease weeks into vector of mid-week dates #dwk <. "small"). "8/18/04") #epidate(x. format = "%U/%a") #wk2date2$dates[1:20] epitab Epidemiologic tabulation for a cohort or case-control study Description Calculates risks. verbose = FALSE) .edu>. conf. "rateratio"). sep="") #wk2date[1:10] #wk2date2 <. "both"). y = NULL.95. correction = FALSE. "chi2").week DateTimeClasses to learn about date-time classes epitab format. risk ratio. NA. odds ratio. "midp"). and conﬁdence intervals for epidemiologic data Usage epitab(x. "1/7/04". "1/14/04".sample(0:53.paste(dwk. "11/2/03". <aragon@berkeley. "fisher". "Wed". "rows". format = "%m/%d/%y".exact". rev = c("neither". method = c("oddsratio".c("12/1/03". "small").medepi. rateratio = c("wald". "midp". replace = TRUE) #wk2date <. oddsratio = c("wald". "columns". 100. "/". riskratio = c("wald". http://www.com References none See Also epitools: as. "boot". format = "%m/%d/%y") #epidate(x.Date to convert character vector of dates into calendar dates with date-time class (done by epidate) strptime to convert date-time character strings into a date-time class Examples #x <.level = 0. pvalue = c("fisher.exact". "midp.26 Author(s) Tomas Aragon. "riskratio".

a single numeric vector of counts combined with y which would be a numeric vector of corresponding person time at risk For odds ratio or risk ratio. or rate ratios for rx2 tables. or single factor or character vector that will be combined with y into a table. The conﬁdence intervals are estimated using a normal approximation (Wald). if provided. "colums". "both". The conﬁdence intervals are estimated using normal approximation. a single numeric vector of counts followed by person time at risk. or "neither" (default) selection estimation method: "wald" (default). vector of numbers from a contigency table (will be transformed into r x 2 table in row-wise order). or mid-p exact method. "boot". For rate ratio. or small sample adjusted method.exact" not calculated set to TRUE for Yate’s continuity correction (default is FALSE) set to TRUE to return more detailed results (default is FALSE) y method conf. "midp. The risk ratios are estimated using unconditional maximum likelihood (Wald). hypergeometric exact (Fisher). "chi2" (normal approximation). The rate ratios are estimated using unconditional maximum likelihood estimation (Wald). or small-sample adjusted. "midp". "riskratio". median-unbiased method (mid-p). mid-p exact.level rev oddsratio riskratio rateratio pvalue correction verbose Details The epitab calculates odds ratios. "small" selection estimation method: "wald" (default). The odds ratios are estimated using unconditional maximum likelihood (Wald).epitab Arguments x 27 For odds ratio or risk ratio. risk ratios.exact" (default). input data can be one of the following: r x 2 table where ﬁrst column contains disease counts and second column contains person time at risk. "ﬁsher". x must be a numeric vector of disease counts select measure of association: "oddsratio" (default). "midp" "ﬁsher. a numeric vector of person-time at risk. "small" "wald" (default). or "rateratio" conﬁdence level (default is 0. Notice the expected structure of the data to be given to ’epitab’: Disease Exposure No (ref) Level 1 (ref) a Level 2 c Yes b d . or small-sample adjusted.exact". for rate ratio. conditional maximum likelihood (Fisher). The conﬁdence intervals are estimated using a normal approximation (Wald). a single factor or character vector that will be combined with x into a table (default is NULL) For rate ratio.95) reverse order of "rows". "ﬁsher. or median unbiased method (mid-p). input data can be one of the following: r x 2 table. or bootstrap estimation.

edu>. mid-p exact. 1st Edition. Statistics for Epidemiology. Author(s) Tomas Aragon. Epidemiology: An Introduction. just use the rev option to "reverse" the rows.epitools. or normal approximation method.exposed p.28 Level 3 e f epitab This function expects the following table struture for rate ratios: counts n00 n10 n20 n30 person-time t01 t11 t21 t31 exposed=0 (ref) exposed=1 exposed=2 exposed=3 If the table you want to provide to this function is not in the preferred form. Oxford University Press primary table odds ratio. each row of the rx2 table is compared to the exposure reference level and test of independence two-sided p values are calculated using ﬁsher exact. Lippincott-Raven Publishers Kenneth J. risk ratio.com References Nicolas P Jewell. 2004.net for the latest. or both. http://www. Value tab measure conf.medepi. Rothman and Sander Greenland (1998).outcome p. However. columns. you can set the reference of a factor using the relevel function.value correction Note Visit http://www.level pvalue x data p. Modern Epidemiology. If you are providing categorical variables (factors or character vectors). the ﬁrst level of the "exposure" variable is treated as the reference. Rothman (2002). Chapman & Hall Kenneth J. Likewise. or rate ratio conﬁdence level p value method data input data with margin totals proportion exposed proportion outcome p value TRUE if Yate’s continuity correction was used . <aragon@berkeley.

"High") ) r243 r243b <. rateratio Examples r243 <. or "neither" (default) .2)[2:1. or see details number of columns = 2 (default) when a table is constructed from a vector or sequence of numbers Default is TRUE and single vector or collection of numbers is read in row-wise.2. ncol =2.list(Diarrhea = c("Yes". (3) r x 2 contingency table.t(r243) r243b epitab(r243. "both". rev = c("neither".. 28010.. Yes).]. verbose = TRUE) 29 epitable Create r x c contigency table (exposure levels vs. verbose = TRUE) epitab(matrix(c(41. ncol byrow rev Details Creates r x 2 table with r exposure levels and 2 outcome levels (No vs. method="rateratio"...2.. reverse order of "rows". method="riskratio". 19017). "columns". "Antibody level" = c("Low". binary outcome) Description Create r x c contigency table for r exposure levels and c outcome levels Usage epitable(. "No").epitable See Also riskratio. byrow = TRUE. Arguments can be one of the following: (1) four or more integers that be converted into r x 2 table (the number of integers must be even). "rows". oddsratio. verbose = TRUE) epitab(r243. 2.matrix(c(12.7.rev = "b". "both")) Arguments . rev = "b". "colums". 15. 2) dimnames(r243) <. (2) two categorical vectors (1st vector is exposure with r levels. Set to FALSE to read in column-wise. 2nd vector is outcome with 2 levels).9).

"Med".2.medepi. "High").factor(sample(c("Low". Author(s) Tomas Aragon. rev = "c") epitable(zz. levels=c("Low". 347) epitable(dat) ## 4 or more integers epitable(1. "Disease"=outcome) zz epitable(zz. "Med".epitable("Exposure Level"=exposure. "High")) outcome <.net for the latest.edu>. rep=TRUE).4. outcome) epitable("Exposure"=exposure. 555. the epitab function. rep=TRUE)) epitable(exposure. rev = "r") epitable(zz. 100. Value Returns r x 2 contingency table. http://www. 2)) ## two categorical vectors exposure <. for example. 20.factor(sample(c("No".30 (4) single vector that be converted into r x 2 table (the number of integers must be even). "Disease"=outcome) ## reversing row and/or column order zz <. usually for additional analyses. "Yes").com References none See Also epitable Examples ## single vector dat <. rev = "b") .6) ## single matrix epitable(matrix(1:6. epitable The contingency table created by this function is usually used for additional analyses.epitools.5. Note Visit http://www.c(88. 3. 100.3. <aragon@berkeley.

An ftable object.. Study the Titanic example to compare how a data frame can contain either individual-level data or group-level data. say ftab. names(dimnames(x))]. x. http://www.table needs to process the ﬁeld names and the possible values for each ﬁeld.net for the latest.table 31 expand.table. one may want to convert a multi-dimensional contingency table into an individual-level data frame.com References none table or array with dimnames(x) and names(dimnames(x)) . expand. can be expanded using expand.table Expand contingency table into individual-level data set Description Expands contingency table or array into individual-level data set.e. An array can be created using the array command.epitools.medepi. In order to generate a data frame. The array x must have dimension names [i. Study the examples. In R.table(x) Arguments x Details For educational purposes. <aragon@berkeley. that is processed by expand.table(ftab)). multi-dimensional contigency tables are represented by arrays. Author(s) Tomas Aragon. The expand.edu>. It is this array. dimnames(x)] and ﬁeld names [i.e.table(as. Usage expand.expand. or the table command with 3 or more vectors (usually ﬁelds from a data frame). Value Returns an individual-level data frame Note Visit http://www..table function converts names(dimnames(x)) to ﬁeld names and the dimnames(x) to factor levels for each ﬁeld.

"Yes")) names(dimnames(tab)) <.list(c("No". calculates expected values in a matrix or table.table(Titanic)[1:20."Yes").data.32 See Also expand. Disease = df$Dis. is a matrix or table .ftable(tab2) ftab2 expand.] ##Convert Titanic data into group-level data frame as. c(2.table(as. Confounder = df$Conf) expand.table(tab2) ##Expanding ftable object ftab2 <.table(tab) df expected ##Creating array using 'table' function and expanding it tab2 <. Usage expected(x) Arguments x Details Assuming independence."Yes"). calculates expected values in a matrix or table.frame(Titanic) expected Expected values in a table Description Assuming independence.table(ftab2)) ##Convert Titanic data into individual-level data frame data(Titanic) expand. "Confounder") tab df <. 2. c("No".array(1:8.expand. c("No". "Disease".grid Examples ##Creating array using 'array' function and expanding it tab <. 2)) dimnames(tab) <.c("Exposure".table(Exposure = df$Exp.

"one") ##expected ei <. p. nrow =2) colnames(oi) <.2 ##year = year of birth ##one+ = one or more congenital defects ##one = one congenital defect dat <.T. Oxford University Press See Also See also margin.epitools.sum((oi .com References 33 Steve Selvin (2001).ei)^2/ei) pchisq(q = chi2.tail = FALSE) .expected Value expected values Note Visit http://www.edu>.expected(oi) ##Pearson chi-square test chi2. Epidemiologic Analysis: A Case-Oriented Approach. df = 8.table Examples ##From Selvin. 2001.net for the latest.T <. lower. <aragon@berkeley.c("one+".medepi. http://www.scan() 369 460 434 434 506 487 521 518 526 488 605 481 649 477 733 395 688 348 ##observed oi <.matrix(dat. Author(s) Tomas Aragon.1983:1991 rownames(oi) <.

weekdays Examples mydates <.medepi.epitools. However. Author(s) Tomas Aragon.Date.Date(mydates. "8/18/04"). "1/7/04".as. the julian function converts a date-time object into a Julian date: the number of day since day 0 (default is 1970-01-01). that is. there is no function. format = "%m/%d/%y") mydates myjulian <. mydates <.net for the latest.julian(mydates) myjulian julian2date(myjulian) julian date. the number of days since day 0 (default is 1970-01-01) . Value Return standard calendar date format. The julian2date function does this conversion.c("1/1/04". "1/14/04". that converts a Julian date back into a date object.edu>.com References none See Also format. without loading another package. "1/2/04". http://www. <aragon@berkeley. Note Visit http://www.34 julian2date julian2date Convert a julian date into standard a date format Description Convert a julian date into a standard calendar date format Usage julian2date(x) Arguments x Details In R.

and dimnames. subjects censored at time tj are considered at-risk and included in nj). order. See examples.dj) / nj] for all tj <= t. status) Arguments time status numeric vector with individual observation times integer vector indicating status at the end of the observation time: 1 = event. <aragon@berkeley. Author(s) Tomas Aragon.com . Usage kapmeier(time. http://www. where tj are event times (i. A primary purpose of this function was to demonstrate the use of available R functions to implement a simple statistical method. cumprod. The survfit function in this package implements the product-limit method and much more. 0 = censored Details This function implements the product-limit method for estimating survival probability for time-toevent data with censoring: S(t) = product[(nj . nj are the number at risk at time tj (by convention.edu>. For serious survival analysis load the survival package.epitools. For example. Studying this function carefully helps one understand and appreciate the utility of R functions to implement simple methods. Value Returns an individual-level data frame Note Visit http://www. kapmeier uses sort. unique.net for the latest.e. times at which one or more events occur).kapmeier 35 kapmeier Implements product-limit (Kaplan-Meier) method Description Implements product-limit (Kaplan-Meier) method for time-to-event data with censoring. tapply. cbind. and dj are the number of events at time tj.medepi. duplicated..

13.17.2.1.36 References oddsratio Selvin S.10.1.0.1. 3rd edition (May 1.0.3) ss <. "rows". "rows". Usage oddsratio(x.24.level = 0. rev = c("neither".level = 0. ss). "wald". conf. verbose = FALSE.level = 0. . "both").c(1.16. y = NULL. "both"). 35). "columns". and normal approximation with small sample adjustment (small).9. conf.wald(x. "columns".1. conf.c(1. V.95. "rows".midp(x. "fisher". method = c("midp". rev = c("neither". "rows". verbose = FALSE) oddsratio. rev = c("neither". verbose = FALSE) oddsratio.95. correction = FALSE.20.0. Oxford University Press. y = NULL. unconditional maximum likelihood estimation (Wald). rev = c("neither".level = 0.95. y = NULL.1) round(kapmeier(tt. conditional maximum likelihood estimation (Fisher).95.fisher(x. correction = FALSE. "columns". 1000)) oddsratio. "both"). interval = c(0. Statistical Analysis of Epidemiologic Data (Monographs in Epidemiology and Biostatistics.0. "small"). correction = FALSE. "columns". normal approximation (Wald). "both"). Conﬁdence intervals are calculated using exact methods (mid-p and Fisher). 2004) See Also See also survfit Examples ##Product-limit method using 'kapmeier' function tt <. conf. y = NULL. and small sample adjustment (small). 3) oddsratio Odds ratio estimation and conﬁdence intervals Description Calculates odds ratio by median-unbiased estimation (mid-p).

rev = c("neither". conditional maximum likelihood estimation (Fisher). verbose = FALSE) oddsratio. vector of numbers from a contigency table (will be transformed into r x 2 table in row-wise order). unconditional maximum likelihood estimation (Wald). y method conf. correction = FALSE.95. "both").midp passes optional arguments to tab2by2. Conﬁdence intervals are calculated using exact methods (mid-p and Fisher). "colums". and adding replicates = n where n is an integer specifying the number of iterations (default is 2000) of the Monte Carlo simulation method of calculating p values. y = NULL.test for calculatng tests of independence (p values): adding correction = TRUE implements Yate’s continuity correction (default is FALSE). verbose = FALSE) Arguments x 37 input data can be one of the following: r x 2 table. normal approximation (Wald). or single factor or character vector that will be combined with y into a table. "columns"..95) reverse order of "rows". "rows".oddsratio correction = FALSE. single factor or character vector that will be combined with x into a table (default is NULL) method for calculating odds ratio and conﬁdence interval conﬁdence level (default is 0. "both". This function expects the following table struture: disease=0 n00 n10 n20 n30 disease=1 n01 n11 n21 n31 exposed=0 (ref) exposed=1 exposed=2 exposed=3 The reason for this is because each level of exposure is compared to the reference level.level rev correction verbose interval .small(x. and small sample adjustment (small). If you are providing a 2x2 table the following table is preferred: .level = 0. conf. or "neither" (default) set to TRUE for Yate’s continuity correction (default is FALSE) set to TRUE to return more detailed results (default is FALSE) interval for the uniroot that ﬁnds the odds ratio median-unbiased estimate and mid-p exact conﬁdence interval for oddsratio. Details Calculates odds ratio by median-unbiased estimation (mid-p).. and normal approximation with small sample adjustment (small).

Fisher’s Exact. the ﬁrst level of the "exposure" variable is treated as the reference. Likewise. However. each row of the rx2 table is compared to the exposure reference level and test of independence two-sided p values are calculated using mid-p exact. 2004. the following table is equivalent: disease=1 n11 n01 disease=0 n10 n00 exposed=1 exposed=0 If the table you want to provide to this function is not in the preferred form. Jewell (2004). Epidemiology: An Introduction. Lippincott-Raven Publishers Kenneth J.outcome measure conf. Rothman and Sander Greenland (1998). 1st Edition.38 disease=0 n00 n10 disease=1 n01 n11 oddsratio exposed=0 (ref) exposed=1 however.medepi. http://www. and the chi-square test. Value x data p. pp. you can set the reference of a factor using the relevel function.level p. Monte Carlo simulation. Modern Epidemiology.edu>. columns.epitools.exposed p. 73-81 table that was used in analysis (verbose = TRUE) same table as x but with marginal totals proportions exposed (verbose = TRUE) proportions experienced outcome (verbose = TRUE) risk ratio and conﬁdence interval conﬁdence level used (verbose = TRUE) p value for test of independence number of replicates used in Monte Carlo simulation p value (verbose = TRUE) logical specifying if continuity correction was used .value replicates correction Note Visit http://www. Oxford University Press Nicolas P. Author(s) Tomas Aragon. If you are providing categorical variables (factors or character vectors).net for the latest. just use the rev option to "reverse" the rows. or both. Statistics for Epidemiology. Rothman (2002). <aragon@berkeley. for odds ratios from 2x2 tables. Chapman & Hall.com References Kenneth J.

1000)) Arguments x conf. "Control") dat <. 64.byrow=TRUE) dimnames(dat) <.test.small(dat. ormidp.level = 0. byrow = TRUE.midp(dat. Usage or. rateratio. 12. conf. 6).midp Details Calculates odds ratio by median-unbiased estimation and exact conﬁdence interval using the mid-p method (Rothman 1998.level byrow interval input data can be 2x2 matrix or vector of length 4 conﬁdence level (default is 0.test. riskratio.3. rev="c") oddsratio.c("Case".2. p. rev="c") oddsratio. 35. This function expects the following 2x2 table struture: .midp Odds ratio estimation and conﬁdence intervals using mid-p method Description Calculates odds ratio by median-unbiased estimation and exact conﬁdence interval using the mid-p method (Rothman 1998).fisher(dat.matrix(c(2. rev="c") oddsratio. "Outcome" = outc) oddsratio(dat. interval = c(0. rev="c") 39 or.midp See Also tab2by2. "Intermediate".c("Lowest".95) integer vectors are read in row-wise (default) interval for the uniroot that ﬁnds the odds ratio median-unbiased estimate and mid-p exact conﬁdence interval for oddsratio. epitab Examples ##Case-control study assessing whether exposure to tap water ##is associated with cryptosporidiosis among AIDS patients tapw <.95. 251).or. 29.wald(dat.list("Tap water exposure" = tapw. "Highest") outc <. rev="c") oddsratio.midp(x.

<aragon@berkeley. Author(s) Tomas Aragon.2.7.2.net for the latest. a0. 79 z3 <. b1.midp(z2) or.matrix(c(12.40 exposed not exposed disease a1 a0 no disease b1 b0 or.level Note Visit http://www.2.z3[2:1.epitools.midp(z1) or.com References Kenneth J.byrow=TRUE) z2 <.88).2. Rothman and Sander Greenland (1998). 243 z1 <.9).midp. b0). Lippincott-Raven Publishers See Also oddsratio Examples ##rothman p.edu>.2:1] ##jewell p.midp(z3) or.z1[2:1.medepi.20.2.byrow=TRUE) z4 <. Modern Epidemiology.midp or a numeric vector of the form c(a1.2:1] or. Value x data estimate conf.matrix(c(347.midp(z4) table that was used in analysis same table as x but with marginal totals median unbiased odds ratio conﬁdence level used . http://www. This function is used by oddsratio.555.

test.test(a1.medepi. 2004. Lippincott-Raven Publishers Kenneth J. 1st Edition. or = 1) Arguments a1 a0 b1 b0 or Details Test for independence using the mid-p method (Rothman 1998) Value $one. Rothman (2002). 73-81 See Also tab2by2.com References Kenneth J. riskratio one-sided p value two-sided p value number of exposed cases number of unexposed cases number of exposed noncases (controls) number of unexposed noncases (controls) odds ratio reference value (default is no association) .net for the latest. Jewell (2004). Rothman and Sander Greenland (1998). oddsratio.test odds ratio test for independence (p value) for a 2x2 table Description Test for independence using the mid-p method (Rothman 1998) Usage ormidp. http://www. Epidemiology: An Introduction. b1. a0. pp. <aragon@berkeley. Oxford University Press Nicolas P. Chapman & Hall. Author(s) Tomas Aragon.sided Note Visit http://www.sided $two.edu>.epitools. Statistics for Epidemiology. Modern Epidemiology.ormidp.test 41 ormidp. b0.

Dr. collecting information about the occurrence and time of onset of symptoms. Usage ##data(oswego) Format • id subject identiﬁcaton number • age age • sex sex: F = Female. all recovered within 24 to 30 hours. Foods were contributed by numerous members of the congregation. the local health ofﬁcer in the village of Lycoming.date onset date: "4/18" = April 18th. 46 persons reported gastrointestinal illness.m. Accordingly. New York.42 Examples ##rothman p. The approximate time of eating supper was collected for only about half the persons who had gastrointestinal illness. He completed Interviews with 75 of the 80 persons known to have attended.time meal time on April 18th • ill developed illness: Y = Yes N = No • onset. Rubin focused the investigation on the supper.test(347.test(12. The onset of illness in all cases was acute. 1940.20. A. diarrhea.2. Data regarding onset of illness and food eaten or water drunk by each of the 75 persons interviewed are provided in the attached line listing (Oswego dataset). "4/19" = April 19th . 79 ormidp. and continued until 11:00 p. reported the occurrence of an outbreak of acute gastrointestinal illness to the District Health Ofﬁcer in Syracuse. 1940 Description On April 19. No fecal specimens were obtained for bacteriologic examination. M. epidemiologist-in-training. and abdominal pain. he learned from the health ofﬁcer that all persons known to be ill had attended a church supper held on the previous evening. M = Male • meal. Approximately 20 physicians. 243 ormidp. When Dr. Family members who did not attend the church supper did not become ill. characterized chieﬂy by nausea. Dr.m. Rubin arrived in the ﬁeld. vomiting. Oswego County. The supper was held in the basement of the village church. was assigned to conduct an investigation. and foods consumed. Of the 75 persons interviewed. Rubin.9) ##jewell p.7. April 18.555. The supper began at 6:00 p. Food was spread out on a table and consumed over a period of several hours.88) oswego oswego Outbreak of Gastrointestinal Illness in Oswego County. None of the ill persons reported having an elevated temperature.

conf.conf.level count or vector of counts person-time at risk (default = 1) or vector of person-times conﬁdence level (default = 0. pt = 1.int Conﬁdence intervals for Poisson counts or rates Description Calculates conﬁdence intervals for Poisson counts or rates Usage pois. conf. Epidemic Intelligence Service References onset.byar(x. Training modules available at http://www. conf. the classic.potato consumed item: Y = Yes N = No cabbage.ice.pois. conf.level = 0.95) pois. aureus outbreak among church picnic attendees.int • • • • • • • • • • • • • • Source Center for Disease Control and Prevention. pt = 1.95) .time onset time: HH:MM AM/PM baked. 1940.95) pois.cream consumed item: Y = Yes N = No fruit.gov/eis/ casestudies/casestudyex.ice. pt = 1.htm.exact(x.95) Arguments x pt conf.approx(x.daly(x.bread consumed item: Y = Yes N = No milk consumed item: Y = Yes N = No coffee consumed item: Y = Yes N = No water consumed item: Y = Yes N = No cakes consumed item: Y = Yes N = No vanilla.salad consumed item: Y = Yes N = No jello rolls consumed item: Y = Yes N = No brown.ham consumed item: Y = Yes N = No spinach consumed item: Y = Yes N = No mashed. pt = 1. straightforward outbreak investigation in a deﬁned population.level = 0. pois.cream consumed item: Y = Yes N = No chocolate.cdc.level = 0.salad consumed item: Y = Yes N = No 43 Oswego: An Outbreak of Gastrointestinal Illness Following a Church Supper (updated 2003): S.conf.95) pois.level = 0.

996. gamma distribution (pois.exact Poisson count person-time at risk crude rate = x/pt lower conﬁdence interval limit upper conﬁdence interval limit conﬁdence level .daly returns 2.epitools. Both x and pt can be either a number or a vector of numbers. See Also binom. for the upper conﬁdence limit pois. When x = 0.int These functions calculate conﬁdence intervals for a Poisson count or rate using an exact method (pois. net Leslie Day (1992). 1st Edition.44 Details pois.epitools.level Note Visit http://www.approx). et al. Oxford University Press.org> References Tomas Aragon. Byar’s formula (pois. <fdimzon@yahoo. with contributions by Scott Nabity.com>. To calculate an exact conﬁdence interval for a crude rate (count divided by person-time at risk).689 and pois. with contributions by Francis Dimzon. Value This function returns a n x 6 matrix with the following colnames: x pt rate lower upper conf." Comput Biol Med. Applied Epidemiology Using R.exact function except when x = 0.daly function gives essentially identical answers to the pois.com.exact returns 3. Author(s) Tomas Aragon. or normal approximation to the Poisson distribution (pois.medepi.exact).byar). <scott.conf. set pt equal to the person-time at risk. "Simple SAS macros for the calculation of exact binomial and Poisson conﬁdence limits. Epidemiology: An Introduction.net for the latest. 22(5):351-361 Kenneth Rothman (2002).nabity@sfdph.edu>. Available at http://www. http://www.daly). <aragon@berkeley. The pois.

"both". "columns". "both")) Arguments x input data can be one of the following: r x 2 table where ﬁrst column contains disease counts and second column contains person time at risk. or a single numeric vector for counts followed by person time at risk vector of person-time at risk. Usage rate2by2.byar(1:10.test Comparative tests of independence in rx2 rate tables Description Tests for independence where each row of the rx2 table is compared to the exposure reference level and test of independence two-sided p values are calculated using mid-p xxact.exact(1:10) pois. "rows".daly(1:10) pois. if provided.daly(1:10.approx(1:10. y = NULL. rr = 1. x must be a vector of disease counts rate ratio reference value (default is no association) reverse order of "rows". and normal approximation. 101:110) pois.approx(1:10) pois. 101:110) pois.rate2by2.exact(1:10.byar(1:10) pois. This function expects the following table struture: counts n00 n10 n20 n30 person-time t01 t11 t21 t31 exposed=0 (ref) exposed=1 exposed=2 exposed=3 . or "neither" (default) y rr rev Details Tests for independence where each row of the rx2 table is compared to the exposure reference level and test of independence two-sided p values are calculated using mid-p xxact. 101:110) pois.test Examples pois. "colums". rev = c("neither".test(x. and normal approximation. 101:110) 45 rate2by2.

epitools.medepi. Examples ##Examples from Rothman 1998.edu>.15. 238 bc <."PYears")) ##midp rate2by2.com References Kenneth J. Outcome=c("BC". each row of the rx2 table is compared to the exposure reference level and test of independence two-sided p values are calculated using mid-p exact method and normal approximation.test(c(15.c(Unexposed = 15. This function can be used to construct a p value function by testing the MUE to the null hypothesis (rr=1) and alternative hypotheses (rr not equal to 1) to calculate two-side mid-p exact p values. Lippincott Williams and Wilkins Publishers Kenneth J. Epidemiology: An Introduction. the ﬁrst level of the "exposure" variable is treated as the reference. If the table you want to provide to this function is not in the preferred form. Rothman (2002).19017). Value x p. 28010).test(bc.2. Author(s) Tomas Aragon. 41. Modern Epidemiology. rev = "r") rate2by2.test(dd.28010. However.test(matrix(c(15. Exposed = 41) pyears <. Oxford University Press See Also rateratio. If you are providing categorical variables (factors or character vectors). 41. <aragon@berkeley.2) dimnames(dd) <."No").matrix(c(41. 28010)) table that was used in analysis p value for test of independence . you can set the reference of a factor using the relevel function. 19017. 19017. see Rothman.value Note Visit http://www. Exposed = 28010) dd <.net for the latest. http://www. p.test The reason for this is because each level of exposure is compared to the reference level. just use the rev option to "reverse" the rows. Likewise. columns.list(Exposure=c("Yes".2)) rate2by2.2. Rothman and Sander Greenland (2008).c(Unexposed = 19017.pyears) rate2by2.46 rate2by2. For more detail. or both.

"columns". rev = c("neither".wald(x. and normal approximation (Wald). "both". y = NULL. method = c("midp". "both").95) reverse order of "rows".level = 0. and normal approximation (Wald). y = NULL. "rows".level = 0. rev = c("neither". verbose = FALSE) rateratio. "rows". a single numeric vector of counts combined with y which would be a numeric vector of corresponding person time at risk numeric vector of person-time at risk. x must be a numeric vector of disease counts method for calculating rate ratio and conﬁdence interval conﬁdence level (default is 0. verbose = FALSE) rateratio. conf. "columns". a single numeric vector of counts followed by person time at risk.95.95. Conﬁdence intervals are calculated using exact methods (mid-p).rateratio 47 rateratio Rate ratio estimation and conﬁdence intervals Description Calculates rate ratio by median-unbiased estimation (mid-p). if provided. This function expects the following table struture: . Usage rateratio(x. y = NULL. "colums".level rev verbose Details Calculates rate ratio by median-unbiased estimation (mid-p). conf. "rows". verbose = FALSE) Arguments x input data can be one of the following: r x 2 table where ﬁrst column contains disease counts and second column contains person time at risk. rev = c("neither". "wald"). "columns". "both"). and unconditional maximum likelihood estimation (Wald). and unconditional maximum likelihood estimation (Wald).95. "both"). conf. Conﬁdence intervals are calculated using exact methods (mid-p).midp(x. or "neither" (default) set to TRUE to return more detailed results (default is FALSE) y method conf.level = 0.

columns. If you are providing categorical variables (factors or character vectors).epitools.48 counts n00 n10 n20 n30 person-time t01 t11 t21 t31 rateratio exposed=0 (ref) exposed=1 exposed=2 exposed=3 The reason for this is because each level of exposure is compared to the reference level.com References Kenneth J. the ﬁrst level of the "exposure" variable is treated as the reference. riskratio.level p. Rothman (2002).edu>.net for the latest. However. Epidemiology: An Introduction.org>. oddsratio. Modern Epidemiology. just use the rev option to "reverse" the rows. or both. Tomas Aragon.medepi. http://www. Lippincott-Raven Publishers Kenneth J. each row of the rx2 table is compared to the exposure reference level and test of independence two-sided p values are calculated using mid-p exact method and normal approximation (Wald). Rothman and Sander Greenland (1998). <aragon@berkeley. If the table you want to provide to this function is not in the preferred form. Oxford University Press See Also rate2by2. Likewise. epitab table that was used in analysis (verbose = TRUE) same table as x but with marginal totals rate ratio and conﬁdence interval conﬁdence level used (verbose = TRUE) p value for test of independence .value Note Visit http://www.shiau@sfdph.test. Author(s) Rita Shiau (original author). <rita. you can set the reference of a factor using the relevel function. Value x data measure conf.

wald(matrix(c(15. 28010)) ##wald rateratio. 41. "rows". or "neither" (default) . 19017.2)) rateratio.. byrow rev see details Default is TRUE and single vector or collection of numbers is read in row-wise. 28010).c(Unexposed = 19017. "both")) Arguments .. rev = c("neither". rev = "r") rateratio(matrix(c(15. 28010). 238 bc <.2)) rateratio(c(15. 41. 19017. "columns".28010. 41.. 19017. Outcome=c("BC".c(Unexposed = 15. "colums".pyears) rateratio. 19017. 28010).15.2. Set to FALSE to read in column-wise..wald(dd.pyears) rateratio(dd. 41. 28010)) ##midp rateratio.2) dimnames(dd) <.matrix(c(41.ratetable Examples ##Examples from Rothman 1998.midp(c(15.midp(dd.pyears) rateratio.2.wald(bc. rev = "r") rateratio. "both". Exposed = 28010) dd <. reverse order of "rows". 19017. p.midp(bc. Exposed = 41) pyears <. 41.wald(c(15. 41. rev = "r") rateratio..19017).2."PYears")) ##midp rateratio(bc.list(Exposure=c("Yes". 19017."No"). byrow = FALSE.2. 28010)) 49 ratetable Create r x 2 count and person-time table for calculating rates Description Create r x 2 count and person-time table for calculating rates Usage ratetable(.midp(matrix(c(15.2)) rateratio.

PT1 (4) One numeric vector of the following form: c(a. Author(s) Tomas Aragon.28010 .19017 py1 <. b. b. PT0.net for the latest. and the 2nd vector should be vector of person-times at risk.50 Details ratetable Creates r x 2 table with r exposure levels and 2 columns (counts and person-time exposed).41 py0 <. Note Visit http://www. For example. Arguments can be one of the following: (1) r x 2 table of the following form: Outcome Exposure cases pyears E = 0 (ref) a PT0 E = 1 b PT1 (2) Two numeric vectors: 1st should be vector of counts. b) pyears <. PT0. 238 bc0 <. cases <.epitools. PT1) (3) >= 4 numbers in the following order: a. p.com References none See Also epitable Examples ##Breast cancer cases from radiation treatment for tuberculosis ##Rothman 1998. <aragon@berkeley.medepi.15 bc1 <. PT1) Value Returns r x 2 rate table.c(a. usually for additional analyses. http://www.c(PT0.edu>.

Usage riskratio(x. bc1. y = NULL. "rows".wald(x. rev = c("neither".years = pyears) ##1 matrix r238 <.95.level = 0. conf. py1) ratetable(bc. correction = FALSE. "Radiation" = c("Yes".riskratio 51 ##4 numbers ratetable(bc0.c(py0. "rows". "both"). "No")) r238 r238b <. "columns". "columns". "both"). "columns".c(bc0. bc1) pyears <. . 19017). "small".t(r238) r238b ratetable(r238b. verbose = FALSE) riskratio. py0. and small sample adjustment (small). person. correction = FALSE. rev = c("neither".matrix(c(41.c(bc0. verbose = FALSE. "rows". "boot"). y = NULL. py0. py1) ##1 vector dat <. 28010. Conﬁdence intervals are calculated using normal approximation (Wald). "both"). conf. py1) ratetable(dat) ##2 vectors cases <.95. and bootstrap method (boot).small(x. method = c("wald". 2. and normal approximation with small sample adjustment (small). conf. 15. 2) dimnames(r238) <.list(c("BC cases".95. bc1. y = NULL. replicates = 5000) riskratio.level = 0. rev = c("neither".level = 0. "Person-years"). rev = "r") riskratio Risk ratio estimation and conﬁdence intervals Description Calculates risk ratio by unconditional maximum likelihood estimation (Wald).cases = cases.

and normal approximation with small sample adjustment (small). "both"). Conﬁdence intervals are calculated using normal approximation (Wald). conf.level = 0.52 riskratio correction = FALSE.95. "columns". single factor or character vector that will be combined with x into a table (default is NULL) method for calculating risk ratio and conﬁdence interval conﬁdence level (default is 0. rev = c("neither". "rows". or single factor or character vector that will be combined with y into a table.95) reverse order of "rows".level rev correction verbose replicates Details Calculates risk ratio by unconditional maximum likelihood estimation (Wald). and small sample adjustment (small). y = NULL. replicates = 5000) Arguments x input data can be one of the following: r x 2 table.boot(x. "colums". verbose = FALSE) riskratio. correction = FALSE. and bootstrap method (boot). This function expects the following table struture: disease=0 n00 n10 n20 n30 disease=1 n01 n11 n21 n31 exposed=0 (ref) exposed=1 exposed=2 exposed=3 The reason for this is because each level of exposure is compared to the reference level. verbose = FALSE. or "neither" (default) set to TRUE for Yate’s continuity correction (default is FALSE) set to TRUE to return more detailed results (default is FALSE) Number of bootstrap replicates (default = 5000) y method conf. If you are providing a 2x2 table the following table is preferred: disease=0 n00 n10 disease=1 n01 n11 exposed=0 (ref) exposed=1 . "both". vector of numbers from a contigency table (will be transformed into r x 2 table in row-wise order).

73-81 Steve Selvin (1998).level conﬁdence level used (verbose = TRUE) boot.medepi. If you are providing categorical variables (factors or character vectors). Rothman and Sander Greenland (1998). http://www. the ﬁrst level of the "exposure" variable is treated as the reference. Modern Applied Biostatistical Methods Using S-Plus.com References Kenneth J. Epidemiology: An Introduction. 1st Edition. each row of the rx2 table is compared to the exposure reference level and test of independence two-sided p values are calculated using Fisher’s Exact. pp. <aragon@berkeley.test.edu>.exposed p. Oxford University Press Nicolas P.replicates number of replicates used in bootstrap estimation of conﬁdence intervals (verbose = TRUE) p.net for the latest. 1st Edition. Rothman (2002). epitab logical specifying if continuity correction was used . However. Statistics for Epidemiology. Lippincott-Raven Publishers Kenneth J. or both. Jewell (2004).replicates number of replicates used in Monte Carlo simulation p value (verbose = TRUE) correction Note Visit http://www.value p value for test of independence mc. 2004. Modern Epidemiology. columns. Likewise.outcome measure table that was used in analysis (verbose = TRUE) same table as x but with marginal totals proportions exposed (verbose = TRUE) proportions experienced outcome (verbose = TRUE) risk ratio and conﬁdence interval conf. just use the rev option to "reverse" the rows. oddsratio. Chapman & Hall. Monte Carlo simulation. Oxford University Press See Also tab2by2. Value x data p. Author(s) Tomas Aragon.riskratio 53 If the table you want to provide to this function is not in the preferred form.epitools. rateratio. and the chi-square test. you can set the reference of a factor using the relevel function.

or single factor or character vector that will be combined with y into a table. "both". "columns". "Outcome" = outc) riskratio(dat. rev = "b".c("Case".list("Behavior type" = c("Type A".2. rev="c") ##Selvin 1998. "both")) Arguments x input data can be one of the following: r x 2 table. "rows". y = NULL. single factor or character vector that will be combined with x into a table (default is NULL) set to TRUE for Yate’s continuity correction (default is FALSE) reverse order of "rows". 64.54 Examples ##Case-control study assessing whether exposure to tap water ##is associated with cryptosporidiosis among AIDS patients tab2by2. 6). 289 sel <. rev = "b") riskratio. and the chi-square test.wald(dat. rev = "b". rev = c("neither". 2. "Intermediate". "colums". vector of numbers from a contigency table (will be transformed into r x 2 table in row-wise order). "Type B").3. or "neither" (default) y correction rev .list("Tap water exposure" = tapw. "Control") dat <. Usage tab2by2. rev="c") riskratio. 12. method = "boot") tab2by2.matrix(c(178. 29. p.boot(sel.matrix(c(2. "No CHD") ) riskratio.boot(sel.test(x. "Outcome" = c("CHD".test tapw <. 35.small(dat.byrow=TRUE) dimnames(dat) <. Fisher’s Exact. rev="c") riskratio. "Highest") outc <.c("Lowest". 2) dimnames(sel) <. 79. correction = FALSE.test Comparative tests of independence in rx2 contigency tables Description Tests for independence where each row of the rx2 table is compared to the exposure reference level and test of independence two-sided p values are calculated using mid-p exact. 1486). 1411. verbose = TRUE) riskratio(sel.

you can set the reference of a factor using the relevel function. Monte Carlo simulation. riskratio table that was used in analysis p value for test of independence logical specifying if continuity correction was used . Fisher’s Exact.com References Kenneth J. Modern Epidemiology. or both. Rothman and Sander Greenland (1998). and the chi-square test.tab2by2. columns. 2004. Lippincott-Raven Publishers Kenneth J. and the chi-square test. 1st Edition. Epidemiology: An Introduction.epitools.test Details 55 Tests for independence where each row of the rx2 table is compared to the exposure reference level and test of independence two-sided p values are calculated using mid-p exact. Chapman & Hall. Author(s) Tomas Aragon. Statistics for Epidemiology. Rothman (2002). the ﬁrst level of the "exposure" variable is treated as the reference.net for the latest. Fisher’s Exact. Value x p.edu>. http://www.value correction Note Visit http://www.medepi. Jewell (2004). 73-81 See Also oddsratio. each row of the rx2 table is compared to the exposure reference level and test of independence two-sided p values are calculated using mid-p exact. If you are providing a 2x2 table order does not matter: If the table you want to provide to this function is not in the preferred form. If you are providing categorical variables (factors or character vectors). <aragon@berkeley. Oxford University Press Nicolas P. just use the rev option to "reverse" the rows. Likewise. However. This function expects the following table struture: disease=0 n00 n10 n20 n30 disease=1 n01 n11 n21 n31 exposed=0 (ref) exposed=1 exposed=2 exposed=3 The reason for this is because each level of exposure is compared to the reference level. pp.

64. Usage table. 35.2.c("Lowest". table. or array . <aragon@berkeley. 29.c("Case". table.matrix(c(2.margins Marginal totals of a table Description Calculates marginal totals of a matrix.medepi. "Outcome" = outc) tab2by2.56 Examples ##Case-control study assessing whether exposure to tap water ##is associated with cryptosporidiosis among AIDS patients table. 12. "Intermediate". or array.net for the latest.margins(x) Arguments x Details Calculates marginal totals of a matrix. "Control") dat <.com References none is a matrix.list("Tap water exposure" = tapw. or array.epitools. table. http://www. 6). Value Returns original object with marginal totals Note Visit http://www. "Highest") outc <.edu>.3.byrow=TRUE) dimnames(dat) <. rev="c") table.margins tapw <.test(dat. Author(s) Tomas Aragon.

cholesterol. diastolic blood pressure. These subjects were primarily selected to study the relationship between behavior pattern and the risk of coronary hearth disease (CHD). 2. 1 = Type A • chd69 Coronary heart disease event: 0 = none. weight.table Examples x <. A number of other risk factors were also measured to provide the best possible assessment of the CHD risk associated with behavior type. systolic blood pressure. Usage ##data(wcgs) Format • id Subject ID: • age0 Age: age in years • height0 Height: height in inches • weight0 Weight: weight in pounds • sbp0 Systolic blood pressure: mm Hg • dbp0 Diastolic blood pressure: mm Hg • chol0 Cholesterol: mg/100 ml • behpat0 Behavior pattern: • ncigs0 Smoking: Cigarettes/day • dibpat0 Dichotomous behavior pattern: 0 = Type B. a prospective cohort studye. 2) table. recruited middleaged men (ages 39 to 59) who were employees of 10 California companies and collected data on 3154 individuals during the years 1960-1961. Additional variables collected include age. 1 = yes • typechd to be done • time169 Observation (follow up) time: Days • arcus0 Corneal arcus: 0 = none.margins(x) 57 wcgs Western Collaborative Group Study data Description The Western Collaborative Group Study (WCGS). height. 1 = yes .wcgs See Also See also margin.matrix(1:4. and corneal arcus. smoking.

58 Source UC Berkeley School of Public Health References pending wnv wnv West Nile Virus human cases reported in California. as of December 14. USA. 2004 Description Public Health Surveillance data Usage ##data(wnv) Format pending Source California Department of Health Services References pending .

40 rate2by2. 17 colors. 30. 14 colors. 17 colors. 51 ∗Topic survival kapmeier. 12 as.int).month. 24 epitab.grid. 8. 6. 56 ∗Topic models ageadjust. 25 epicurve. 46 riskratio.data.int.test. 12 epidate. 12 as. 12 colorbrewer.conf.palette. 7. 29. 12 binom.table. 17 colorbrewer. 58 ∗Topic hplot epicurve.conf. 20 as. 6. 6 as.conf. 39 rateratio.test.indirect.direct.conf. 6 as.int. 33 kapmeier.margins. 8 as. 3 as. 33 ∗Topic color colorbrewer. 3 epitab.int).indirect.int. 22 binom.POSIXct.exact.display. 12. 32 format. 44 tab2by2.Date. 9. 16 DateTimeClasses. 31 expand. 15.dates.plot.Date.wilson (binom.exact (binom. 7.table. 26.conf. 9.int). 30 expected. 53 epitable. 16 ∗Topic datasets oswego.month.hour. 25. 1 ageadjust.approx (binom. 17 epicurve.hour.conf.matrix (colors. 7. 50 expand.midp. 12 pois. 49 table. 57 wnv. 1. 25 barplot. 26 oddsratio. 44 binom.POSIXlt. 30 expected. 9.week. 17 colorbrewer. 48. 12 binom. 3.direct. 38. 32 ratetable. 13 binom. 7. 36 or. 5 59 ageadjust.plot). 17 ∗Topic htest ormidp.week. 10. 24 julian2date. 9. 34 .test.plot. 34 julian2date. 34 ∗Topic univar binom. 10 epidate. 20 as. 16 colors. 14 colorbrewer. 29 expand.Index ∗Topic chron as. 54 ∗Topic manip epitable.test. 12 binom. 41 wcgs. 43 ageadjust.

int). 43 pois. 54 table. 43 pois. 36. 43 pois.conf. 52. 41. 46. 28. 28.approx (pois.midp. 43 rate2by2.daly (pois. 12. 27.test.int. 41. 48 rateratio.int).test.margins.conf.60 margin. 45. 28. 7.conf. 56 oddsratio. 54 riskratio. 57 weekdays. 55 oddsratio. 38. 38. 53 ratetable. 55 strptime. 49 relevel. 34 wnv.table. 24. 48. 37.int). 53. 25 survfit. 13 pois. 46. 38. 56 uniroot.exact. 51. 41. 37. 53.midp. 41 pois. 35 tab2by2. 39 ormidp.exact (pois. 37. 40 oswego. 43 pois. 33. 39 wcgs.byar (pois.conf. 47. 44. 48.test. 38. 40.conf.int). 39 or. 22. 58 INDEX . 9.

- Automatic Summarization of Events From Social Media
- IJETTCS-2014-04-08-074
- A computational system for support to actions on dengue fever control and management
- Health Care Fraud Detection Using Non Negative
- 10.1.1.131.1586
- 1
- Parkinson's Disease Motor Symptoms In
- Receiver Operating Characteristic (ROC) Curve
- Motulsky-2015-British Journal of Pharmacology
- Resource Person Manual f
- Incremental Outlier Detection
- Simple Epidemiology for Clinicians - Thomas R Vetter - Lecture Note
- medical quality management.docx
- quality management in healthcare.docx
- Nose
- Biometrics With Topics in Face Recogntion- Age Progression
- SP-1259 HSE Specification - Safety Training Observation Programme (STOP)
- UN_MLT_86.pdf
- Cursors s Sssssssss
- Pre Registration Template
- STAT015 Summer 2011 Lectures Lecture 1 to 4 (1)
- Inhibit and Overrides
- Proof Test Procedure Effectiveness on Safety Instrumented Systems
- Methodology
- Temporal Expressions in Bio Medical Texts
- Logical Framework Modifications Based on Experience
- Unit III Planning
- Jobswire.com Resume of henleyinsc
- BASICS OF TRIPS.docx

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue listening from where you left off, or restart the preview.

scribd