scanstatistics: Space-Time Anomaly Detection using Scan Statistics

Detection of anomalous space-time clusters using the scan statistics methodology. Focuses on prospective surveillance of data streams, scanning for clusters with ongoing anomalies. Hypothesis testing is made possible by the generation of Monte Carlo p-values.

Install the latest version of this package by entering the following in R:
AuthorBenjamin Kjellson [aut, cre]
Date of publication2016-09-29 11:37:32
MaintainerBenjamin Kjellson <>
LicenseGPL (>= 3)

View on CRAN

Man pages

add_duration: Add a column 'duration' to a 'data.table' with column 'time'.

add_llr: Calculate the log-likelihood ratios from given...

calc_zipstat_over_duration: Calculate the ZIP window statistic over all durations, for a...

closest_subsets: Set of increasing sets from left to right of input vector.

column_to_int: Replaces a column with integers, its unique and sorted values...

connected_neighbors: Find the connected sets for a location and its k nearest...

connected_to: Return those elements in the second set which are connected...

convolute_denominator: Computes the sum in the increasing score denominator.

convolute_numerator: Computes the sum in the increasing score numerator.

coords_to_knn: Get the k nearest neighbors for each location, given its...

create_table: Create a 'data.table' with all combinations of the supplied...

cumsum_duration: Calculates the cumulative sum of columns over duration, by...

dist_to_knn: Given a distance matrix, find the k nearest neighbors.

enumerate_character: Enumerate the unique, sorted values of a column, returned as...

estimate_d: Estimate the indicators of excess zeros for a ZIP...

estimate_d_dagger: Estimate the ZIP excess zero indicators under null hypothesis...

estimate_zip_relrisk: Estimate the relative risk for an outbreak using a ZIP...

extract_mlc: Extract the most likely cluster (MLC) and the value of the...

extract_scanstatistic: Extract value of scan statistic from per-window statistics.

first_keys_match: Do the first few keys of the supplied table match the...

flexible_zones: Computes the flexibly shaped zones as in Tango (2005).

generate_poisson_counts: Randomly generate and add Poisson counts to a table.

generate_zip_counts: Randomly generate and add ZIP-distributed counts to a table.

gen_negbin_counts: Randomly generate and add negative binomial counts to a...

get_all_streams: Extract the sorted names of all data streams from a...

get_column_values: Extract the values of a 'data.table' column by the column...

get_enumerated_character: Get the name (as character) corresponding to the given...

getkeys: Get the keys from a data.table.

get_set: Get the set with the given index from an implicitly ordered...

get_zone: Extract a zone from the set of all zones.

has_converged: Is the relative error between two numbers is less than the...

haskeys: Determine if table has all the given keys.

if_connected: Return a set of the location and its neighbors if they are...

is_connected: Returns TRUE if the neighboring locations are connected to...

join_zones: Creates a new 'data.table' from a table containing locations,...

knn_zones: Find the increasing subsets of k nearest neighbors for all...

kulldorff_baseline: Estimate the _baselines_ (expected counts) by the Kulldorff...

mc_pvalue: Calculate the Monte Carlo p-value for a scan statistic.

negbin_calculations: Calculate the ordinary NegBin score for each space-time...

negbin_increasing_calculations: Calculate the increasing score for each space-time window.

negbin_increasing_score: Calculate the increasing score for each space-time window.

negbin_mcsim: Monte Carlo simulation of negative binomial score scan...

negbin_overdispersion: Computes the overdispersion parameter for a fitted negative...

negbin_score: Computes the ordinary score for each space-time window.

negbin_score_terms: Computes the numerator and denominator terms for the NegBin...

NM_geo: Longitude and latitude of New Mexico county seats.

NM_map: Data to plot the counties of New Mexico.

NM_popcas: Population and brain cancer cases in New Mexico counties...

partition_zones: Partition a set of zones.

poisson_calculations: Calculate the expectation-based Poisson statistic for each...

poisson_mcsim: Monte Carlo simulation of expectation-based Poisson scan...

poisson_relrisk: Add column for relative risk MLE to table with aggregate...

poisson_score_terms: Computes the numerator and denominator terms for the Poisson...

poisson_statistic: Calculate the expectation-based Poisson statistic for each...

powerset_zones: Creates a set of all non-empty subsets of the integers from 1...

print.scanstatistic: Print a scanstatistic object.

scan_negbin: Calculate the negative binomial scan statistic.

scan_poisson: Calculate the Poisson scan statistic.

scanstatistic_object: Creates an S3 object of class scanstatistic.

scanstatistics: scanstatistics: Space-time anomaly detection using scan...

scan_zip: Calculate the ZIP scan statistic.

score_locations: Score each location over zones and duration.

score_zone_sums: Sums the numerator and denominator terms over all locations...

sim_negbin_statistic: Simulate a single negative binomial score scan statistic.

simulate_poisson_scanstatistic: Simulate a single expectation-based Poisson scan statistic.

simulate_zip_scanstatistic: Simulate a single expectation-based ZIP-EM scan statistic.

times_and_durations: Creates a 'data.table' with columns 'time' and 'duration'.

top_clusters: Get the top (non-overlappig) clusters.

validate_colnames: Check that the input table has the right columns. Raises...

validate_scan: Check that input to scanstatistic function is valid.

validate_values: Check that the input table does not contain any missing...

validate_zones: Check that the zones argument is a list of integer or factor...

window_zip_statistic: Calculate the ZIP statistic for a single space-time window.

zip_calculations: Calculate the (logarithm of the) ZIP statistic for each...

zip_em_estimates: Estimates the ZIP relative risk and excess zero indicators...

zip_mcsim: Monte Carlo simulation of expectation-based Poisson scan...

zip_statistic: Calculates the ZIP statistic for each space-time window.

zip_statistic_factor: Factor(s) in the product of the EB-ZIP window statistic.

zip_statistic_term: Calculate a term in the sum of the logarithm of the ZIP...

zone_sum: Sum columns over all location in each zone, for each...

zone_table_creator: Converts a list of zones to a 'data.table' of zones and...


add_duration Man page
add_llr Man page
calc_zipstat_over_duration Man page
closest_subsets Man page
column_to_int Man page
connected_neighbors Man page
connected_to Man page
convolute_denominator Man page
convolute_numerator Man page
coords_to_knn Man page
create_table Man page
cumsum_duration Man page
dist_to_knn Man page
enumerate_character Man page
estimate_d Man page
estimate_d_dagger Man page
estimate_zip_relrisk Man page
extract_mlc Man page
extract_scanstatistic Man page
first_keys_match Man page
flexible_zones Man page
generate_poisson_counts Man page
generate_zip_counts Man page
gen_negbin_counts Man page
get_all_streams Man page
get_column_values Man page
get_enumerated_character Man page
getkeys Man page
get_set Man page
get_zone Man page
has_converged Man page
haskeys Man page
if_connected Man page
is_connected Man page
join_zones Man page
knn_zones Man page
kulldorff_baseline Man page
mc_pvalue Man page
negbin_calculations Man page
negbin_increasing_calculations Man page
negbin_increasing_score Man page
negbin_mcsim Man page
negbin_overdispersion Man page
negbin_score Man page
negbin_score_terms Man page
NM_geo Man page
NM_map Man page
NM_popcas Man page
partition_zones Man page
poisson_calculations Man page
poisson_mcsim Man page
poisson_relrisk Man page
poisson_score_terms Man page
poisson_statistic Man page
powerset_zones Man page
print.scanstatistic Man page
scan_negbin Man page
scan_poisson Man page
scanstatistic_object Man page
scanstatistics Man page
scanstatistics-package Man page
scan_zip Man page
score_locations Man page
score_zone_sums Man page
sim_negbin_statistic Man page
simulate_poisson_scanstatistic Man page
simulate_zip_scanstatistic Man page
times_and_durations Man page
top_clusters Man page
validate_colnames Man page
validate_scan Man page
validate_values Man page
validate_zones Man page
window_zip_statistic Man page
zip_calculations Man page
zip_em_estimates Man page
zip_mcsim Man page
zip_statistic Man page
zip_statistic_factor Man page
zip_statistic_term Man page
zone_sum Man page
zone_table_creator Man page


tests/testthat/test_utility_functions.R tests/testthat/test_zone_utility_functions.R tests/testthat/test_scan_zip.R tests/testthat/test_zones.R tests/testthat/test_scan_negbin.R tests/testthat/test_baseline_estimation.R tests/testthat/test_scan_poisson.R tests/testthat/test_aggregation_functions.R
R/scan_negbin.R R/baseline_estimation.R R/aggregation_functions.R R/scan_poisson.R R/data.R R/zones.R R/scanstatistics.R R/utility_functions.R R/datatable_utility_functions.R R/scanstatistics_general.R R/scan_zip.R R/zone_utility_functions.R
man/scanstatistic_object.Rd man/if_connected.Rd man/negbin_calculations.Rd man/validate_values.Rd man/column_to_int.Rd man/connected_neighbors.Rd man/add_duration.Rd man/coords_to_knn.Rd man/simulate_zip_scanstatistic.Rd man/score_zone_sums.Rd man/convolute_denominator.Rd man/extract_mlc.Rd man/scanstatistics.Rd man/validate_zones.Rd man/scan_poisson.Rd man/closest_subsets.Rd man/poisson_statistic.Rd man/window_zip_statistic.Rd man/negbin_overdispersion.Rd man/times_and_durations.Rd man/validate_scan.Rd man/top_clusters.Rd man/is_connected.Rd man/negbin_score.Rd man/zip_mcsim.Rd man/create_table.Rd man/scan_zip.Rd man/get_all_streams.Rd man/zip_statistic_term.Rd man/haskeys.Rd man/convolute_numerator.Rd man/NM_popcas.Rd man/calc_zipstat_over_duration.Rd man/poisson_relrisk.Rd man/negbin_increasing_score.Rd man/poisson_score_terms.Rd man/partition_zones.Rd man/connected_to.Rd man/first_keys_match.Rd man/kulldorff_baseline.Rd man/has_converged.Rd man/negbin_mcsim.Rd man/negbin_increasing_calculations.Rd man/score_locations.Rd man/zip_em_estimates.Rd man/negbin_score_terms.Rd man/extract_scanstatistic.Rd man/zip_statistic.Rd man/zone_sum.Rd man/powerset_zones.Rd man/NM_map.Rd man/knn_zones.Rd man/getkeys.Rd man/cumsum_duration.Rd man/get_zone.Rd man/poisson_calculations.Rd man/scan_negbin.Rd man/generate_poisson_counts.Rd man/mc_pvalue.Rd man/simulate_poisson_scanstatistic.Rd man/join_zones.Rd man/dist_to_knn.Rd man/enumerate_character.Rd man/zip_statistic_factor.Rd man/get_enumerated_character.Rd man/NM_geo.Rd man/estimate_zip_relrisk.Rd man/zip_calculations.Rd man/add_llr.Rd man/estimate_d.Rd man/sim_negbin_statistic.Rd man/get_column_values.Rd man/poisson_mcsim.Rd man/estimate_d_dagger.Rd man/flexible_zones.Rd man/get_set.Rd man/zone_table_creator.Rd man/print.scanstatistic.Rd man/gen_negbin_counts.Rd man/generate_zip_counts.Rd man/validate_colnames.Rd

Questions? Problems? Suggestions? or email at

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.