Last chance! 50% off unlimited learning
Sale ends in
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 alpha1
.
rflex.zones(
nn,
w,
cases,
ex,
alpha1 = 0.2,
type = "poisson",
pop = NULL,
cl = NULL,
loop = FALSE,
verbose = FALSE,
pfreq = 1
)
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.
An n by k matrix providing the k nearest
neighbors of each region, presumably produced by the
knn
function.
A binary spatial adjacency matrix for the regions.
The number of cases observed in each region.
The expected number of cases for each region. The default is calculated under the constant risk hypothesis.
The middle p-value threshold.
The type of scan statistic to compute. The
default is "poisson"
. The other choice
is "binomial"
.
The population size associated with each
region. The default is NULL
since this argument
is only needed for type = "binomial"
.
A cluster object created by makeCluster
,
or an integer to indicate number of child-processes
(integer values are ignored on Windows) for parallel evaluations
(see Details on performance).
It can also be "future"
to use a future backend (see Details),
NULL
(default) refers to sequential evaluation.
A logical value indicating whether a loop
should be used to implement the function instead of
pbapply
. The default is
FALSE
. If TRUE
, then memory-saving steps
are also taken.
A logical value indicating whether
progress messages should be provided.
The default is FALSE
. If both loop
and
verbose
are TRUE
, informative messages
are displayed that can be useful for diagnosing where
the sequences of connected subgraphs are slowing down
or having problems.
The frequency that messages are reported
from the loop (if verbose = TRUE
). The default
is pfreq = 1
, meaning a message is returned for
each index of the loop.
Joshua French
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>
rflex.midp
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)
if (FALSE) {
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
)
}
Run the code above in your browser using DataLab