scanw: Scan statistic approximation for counts in moving window

View source: R/scan.R

scanwR Documentation

Scan statistic approximation for counts in moving window

Description

Naus scan statistic approximation for Poisson counts in moving window over a particular time period

Usage

scanw(L, k, mu, n)

Arguments

L

number of time periods in the window

k

window scan time period

mu

Poisson averaged per single time period

n

number of time periods

Details

When examining counts of items happening in a specific, discrete set of windows, e.g. counts of crime per week, one can use the Poisson PMF to determine the probability of getting an observation over a particular value. For example, if you have a mean of 1 per week, the probability of observing a single week with a count of 6 or more is ppois(5,1,FALSE) , approximately 0.0006. But if you have monitored a series over 5 years, (260 weeks), then the the expected number of seeing at least one 6 count in the time period is ppois(5,1,FALSE)*260 , over 15%.

Now imagine we said "in this particular week span, I observed a count of 6". So it is not in pre-specified week, e.g. Monday through Sunday, but examining over any particular moving window. Naus (1982) provides an approximation to correct for this moving window scan. In this example, it ends up being close to 50% is the probability of seeing a moving window of 6 events.

Value

A single numeric value, the probability of observing that moving window count

References

Aberdein, J., & Spiegelhalter, D. (2013). Have London's roads become more dangerous for cyclists?. Significance, 10(6), 46-48.

Naus, J.I. (1982). Approximations for distributions of scan statistics. Journal of the American Statistical Association, 77, 177-183.

Examples


# Spiegelhalter example (replicates COOLSerdash's estimates in comments)
scanw(208,2,0.6,6)

# Example in description
scanw(260,1,1,6)


apwheele/ptools documentation built on Oct. 20, 2023, 3:12 p.m.