generate_case_grids: Get test period and baseline period case counts

View source: R/cluster_functions.R

generate_case_gridsR Documentation

Get test period and baseline period case counts

Description

Given raw case counts by location, and some dates and other params return a list of frames and values that summarize the number or cases in the baseline and test period

Usage

generate_case_grids(
  cases,
  detect_date,
  baseline_length = 90,
  max_test_window_days = 7,
  guard_band = 0,
  baseline_adjustment = c("add_one", "add_one_global", "add_test", "none"),
  adj_constant = 1
)

Arguments

cases

frame of cases with counts, location(s) and dates

detect_date

date to end examination of detection of clusters

baseline_length

number of days (integer) used for baseline detection (default = 90)

max_test_window_days

integer, max number of days in a detected cluster, defaults to 7

guard_band

integer (default=0) number of days buffer between test interval and baseline

baseline_adjustment

one of three string options: "add_one" (default), "add_test", or "none". All methods except for "none" will ensure that the log(obs/expected) is always defined (i.e. avoids expected =0). For the default, this will add 1 to the expected for any individual calculation if expected would otherwise be zero. For "add_test_interval", each location in the baseline is increased by the number of cases in that location during the test interval. If "none", no adjustment is made.

adj_constant

numeric (default=1.0); this is the constant to be added if baseline_adjustment == 'add_one' or baseline_adjustment == 'add_one'

Value

an object of class 'CaseGrids' contain a list of items

  • 'baseline_counts_by_location': a frame of counts over the baseline interval by location

  • 'case_grid': a frame of cases during the test dates, with reverse cumulative counts within location, by date

  • 'case_grid_totals_by_date': reverse cumulative sum of counts over all locations, by date

  • 'test_cases': case location counts only during the test dates

  • 'detect_date': the detect date passed to this function

  • 'baseline_total': an integer holding the total counts over all locations and dates

Examples

dd <- example_count_data[, max(date)]
generate_case_grids(
  cases = example_count_data,
  detect_date = dd
)

gsClusterDetect documentation built on July 27, 2026, 5:09 p.m.