rflex.zones {smerc} | R Documentation |
Determine zones for flexibly shaped spatial scan test
Description
rflex.zones
determines the unique zones to
consider for the flexibly shaped spatial scan test of
Tango and Takahashi (2012). The algorithm uses a
breadth-first search to find all subgraphs connected to
each vertex (region) in the data set of size k
or
less with the constraint that the middle p-value of each
region must be less than alpha1
.
Usage
rflex.zones(
nn,
w,
cases,
ex,
alpha1 = 0.2,
type = "poisson",
pop = NULL,
cl = NULL,
loop = FALSE,
verbose = FALSE,
pfreq = 1
)
Arguments
nn |
An n by k matrix providing the k nearest
neighbors of each region, presumably produced by the
|
w |
A binary spatial adjacency matrix for the regions. |
cases |
The number of cases observed in each region. |
ex |
The expected number of cases for each region. The default is calculated under the constant risk hypothesis. |
alpha1 |
The middle p-value threshold. |
type |
The type of scan statistic to compute. The
default is |
pop |
The population size associated with each
region. The default is |
cl |
A cluster object created by |
loop |
A logical value indicating whether a loop
should be used to implement the function instead of
|
verbose |
A logical value indicating whether
progress messages should be provided.
The default is |
pfreq |
The frequency that messages are reported
from the loop (if |
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. and Takahashi, K. (2012), A flexible spatial scan statistic with a restricted likelihood ratio for detecting disease clusters. Statist. Med., 31: 4207-4218. <doi:10.1002/sim.5478>
See Also
rflex.midp
Examples
data(nydf)
data(nyw)
coords <- cbind(nydf$x, nydf$y)
nn <- knn(coords, k = 5)
cases <- floor(nydf$cases)
pop <- nydf$pop
ex <- pop * sum(cases) / sum(pop)
# zones for poisson model
pzones <- rflex.zones(nn, w = nyw, cases = cases, ex = ex)
## Not run:
pzones <- rflex.zones(nn,
w = nyw, cases = cases,
ex = ex, verbose = TRUE
)
# zones for binomial model
bzones <- rflex.zones(nn,
w = nyw, cases = cases, ex = ex,
type = "binomial", pop = pop
)
## End(Not run)