flex.test
11
flex.test
Flexibly Shaped Spatial Scan Test
Description
flex.test performs the flexibly shaped spatial scan test of Tango and Takahashi (2005).
Usage
flex.test(coords, cases, pop, w, k = 10, ex = sum(cases)/sum(pop) * pop,
type = "poisson", nsim = 499, alpha = 0.1, nreport = nsim + 1,
lonlat = FALSE, parallel = TRUE)
Arguments
coords
An n × 2 matrix of centroid coordinates for the regions.
cases
The number of cases observed in each region.
pop
The population size associated with each region.
w
A binary spatial adjacency matrix.
k
An integer indicating the maximum number of regions to inclue in a potential
cluster. Default is 10
ex
The expected number of cases for each region. The default is calculated under
the constant risk hypothesis.
type
The type of scan statistic to implement. Default is
"poisson". Only "poisson"
is currently implemented.
nsim
The number of simulations from which to compute the p-value.
alpha
The significance level to determine whether a cluster is signficant. Default is
0.10.
nreport
The frequency with which to report simulation progress. The default is
nsim+ 1,
meaning no progress will be displayed.
lonlat
The default is
FALSE, which specifies that Euclidean distance should be used.If
lonlat is TRUE, then the great circle distance is used to calculate the inter-
centroid distance.
parallel
A logical indicating whether the test should be parallelized using the
parallel::mclapply function.
Default is
TRUE. If TRUE, no progress will be reported.
Details
The test is performed using the spatial scan test based on the Poisson test statistic and a fixed number
of cases. The first cluster is the most likely to be a cluster. If no significant clusters are found, then
the most likely cluster is returned (along with a warning).
12
flex.test
Value
Returns a list of length two of class scan. The first element (clusters) is a list containing the signifi-
cant, non-ovlappering clusters, and has the the following components:
coords
The centroid of the significant clusters.
r
The radius of the window of the clusters.
pop
The total population in the cluser window.
cases
The observed number of cases in the cluster window.
expected
The expected number of cases in the cluster window.
smr
Standarized mortaility ratio (observed/expected) in the cluster window.
rr
Relative risk in the cluster window.
loglikrat
The loglikelihood ratio for the cluster window (i.e., the log of the test statistic).
pvalue
The pvalue of the test statistic associated with the cluster window.
The second element of the list is the centroid coordinates. This is needed for plotting purposes.
Author(s)
Joshua French
References
Tango, T., & Takahashi, K. (2005). A flexibly shaped spatial scan statistic for detecting clusters.
International journal of health geographics, 4(1), 11. Kulldorff, M. (1997) A spatial scan statistic.
Communications in Statistics – Theory and Methods 26, 1481-1496.
See Also
scan.stat
,
plot.scan
,
scan.test
,
uls.test
,
dmst.test
,
bn.test
Examples
data(nydf)
data(nyw)
coords = with(nydf, cbind(longitude, latitude))
out = flex.test(coords = coords, cases = floor(nydf$cases),
w = nyw, k = 3,
pop = nydf$pop, nsim = 49,
alpha = 0.12, lonlat = TRUE)
data(nypoly)
library(sp)
plot(nypoly, col = color.clusters(out))
flex.zones
13
flex.zones
Determine zones for flexibly shaped spatial scan test
Description
flex.zones determines the unique zones to consider for the flexibly shaped spatial scan test of
Tango and Takahashi (2005). The algorithm uses a breadth-first search to find all subgraphs con-
nected to each vertex (region) in the data set of size k or less.
Usage
flex.zones(coords, w, k = 10, lonlat = FALSE, parallel = TRUE)
Arguments
coords
An n × 2 matrix of centroid coordinates for the regions.
w
A binary spatial adjacency matrix.
k
An integer indicating the maximum number of regions to inclue in a potential
cluster. Default is 10
lonlat
The default is
FALSE, which specifies that Euclidean distance should be used.If
lonlat is TRUE, then the great circle distance is used to calculate the inter-
centroid distance.
parallel
A logical indicating whether the test should be parallelized using the
parallel::mclapply function.
Default is
TRUE. If TRUE, no progress will be reported.
Value
Returns a list of zones to consider for clustering. Each element of the list contains a vector with the
location ids of the regions in that zone.
Author(s)
Joshua French
References
Tango, T., & Takahashi, K. (2005). A flexibly shaped spatial scan statistic for detecting clusters.
International journal of health geographics, 4(1), 11.
Examples
data(nydf)
data(nyw)
coords = cbind(nydf$longitude, nydf$latitude)
flex.zones(coords = coords, w = nyw, k = 3, lonlat = TRUE)