Learn R Programming

gsClusterDetect (version 1.0.0)

compress_clusters: Compress a cluster_alert_table

Description

Function reduces an object of class `ClusterAlertTable`` to the final set of clusters and locations. The idea of this function is to retain only the most significant, non-overlapping clusters from the cluster alert table. The surrogate for significance is 'alertGap', or log(observed/expected) minus the threshold that the spline assigns to the observed value. The logic in this function keeps two running tables, the table `dt_keep` of clusters to be kept, in descending order of `alertGap`, and `dt_clust`, the remaining rows of the cluster alert table, which are reduced each time a cluster is accepted into `dt_keep`. Each row of the cluster alert table represents a candidate cluster, with a column `target`, which is the cluster center, and a column `location`, the most distant location from the center. Each time a cluster is accepted into `dt_keep`, the remaining rows of `dt_clust` are dropped if either `target` or `location` is the center of the newly accepted cluster. in `dt_keep`

Usage

compress_clusters(cluster_alert_table, distance_matrix)

Value

an object of class `clusters`, which is simply a a list including a a data.frame of clusters and another frame of individual location counts

Arguments

cluster_alert_table

an object of class `ClusterAlertTable`

distance_matrix

a square distance matrix, named on both dimensions or a list of distance vectors, one for each location

Examples

Run this code
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
)
obs_exp_grid <- generate_observed_expected(
  nearby_counts = nci,
  case_grid = case_grid
)
cla <- add_spline_threshold(oe_grid = obs_exp_grid)
compress_clusters(
  cluster_alert_table = cla,
  distance_matrix = county_distance_matrix("OH")[["distance_matrix"]]
)

Run the code above in your browser using DataLab