Learn R Programming

scanstatistics (version 1.1.1)

scan_bayes_negbin_cpp: Calculate the "Bayesian Spatial Scan Statistic" by Neill et al. (2006).

Description

Calculate the "Bayesian Spatial Scan Statistic" by Neill et al. (2006), adapted to a spatio-temporal setting. The scan statistic assumes that, given the relative risk, the data follows a Poisson distribution. The relative risk is in turn assigned a Gamma distribution prior, yielding a negative binomial marginal distribution for the counts.

Usage

scan_bayes_negbin_cpp(
  counts,
  baselines,
  zones,
  zone_lengths,
  outbreak_prob,
  alpha_null,
  beta_null,
  alpha_alt,
  beta_alt,
  inc_values,
  inc_probs
)

Value

A list with elements priors (list), posteriors (list), and marginal_data_prob (scalar). The list priors has elements

null_prior

The prior probability of no anomaly.

alt_prior

The prior probability of an anomaly.

inc_prior

A vector (matrix with 1 row) of prior probabilities of each value in the argument m_values.

window_prior

The prior probability of an outbreak in any of the space-time windows.

The list posteriors has elements

null_posterior

The posterior probability of no anomaly.

alt_posterior

The posterior probability of an anomaly.

inc_posterior

A data frame with columns inc_values and inc_posterior.

window_posteriors

A data frame with columns zone, duration, log_posterior and log_bayes_factor, each row corresponding to a space-time window.

space_time_posteriors

A matrix with the posterior anomaly probability of each location-time combination.

location_posteriors

A vector (matrix with 1 row) with the posterior probability of an anomaly at each location.

Arguments

counts

An integer matrix (most recent timepoint in first row).

baselines

A matrix with positive entries (most recent timepoint in first row).

zones

An integer vector (all zones concatenated; locations indexed from 0 and up).

zone_lengths

An integer vector.

outbreak_prob

A scalar; the probability of an outbreak (at any time, any place).

alpha_null

A scalar; the shape parameter for the gamma distribution under the null hypothesis of no anomaly.

beta_null

A scalar; the scale parameter for the gamma distribution under the null hypothesis of no anomaly.

alpha_alt

A scalar; the shape parameter for the gamma distribution under the alternative hypothesis of an anomaly.

beta_alt

A scalar; the scale parameter for the gamma distribution under the alternative hypothesis of an anomaly.

inc_values

A vector of possible values for the increase in the mean (and variance) of an anomalous count.

inc_probs

A vector of the prior probabilities of each value in inc_values.