generate_observed_expected: Generate the observed and expected information

View source: R/cluster_functions.R

generate_observed_expectedR Documentation

Generate the observed and expected information

Description

Function takes an object of class 'NearbyClusterGrids', as returned from gen_nearby_case_info(), and an object of class 'CaseGrids', as returned from generate_case_grids(), and adds observed and expected information.

Usage

generate_observed_expected(
  nearby_counts,
  case_grid,
  adjust = FALSE,
  adj_constant = 1
)

Arguments

nearby_counts

an object of class 'NearbyClusterGrids'

case_grid

an object of class 'CaseGrids'

adjust

boolean default TRUE, set to FALSE to avoid adding one to the expected when it is zero. Could result in errors.

adj_constant

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

Value

a dataframe of class 'ObservedExpectedGrid', which is simply a data frame with the observed and expected calculation incorporated for all target locations

Examples

case_grid <- generate_case_grids(
  example_count_data,
  example_count_data[, max(date)]
)
nci <- gen_nearby_case_info(
  cg = case_grid,
  distance_matrix = county_distance_matrix("OH")[["distance_matrix"]],
  distance_limit = 25
)
generate_observed_expected(
  nearby_counts = nci,
  case_grid = case_grid
)

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