| Title: | Information Criterion and Scan Statistic Approach for Detecting Multiple Disease Clusters |
|---|---|
| Description: | Detecting multiple disease clusters using the information criterion and scan statistic approach developed by Takahashi and Shimadzu (2020) <doi:10.1186/s12942-020-00228-y>. |
| Authors: | Takahiro Otani [aut, cre]
|
| Maintainer: | Takahiro Otani <[email protected]> |
| License: | GPL-3 |
| Version: | 0.3.0 |
| Built: | 2026-10-05 07:38:11 UTC |
| Source: | https://github.com/tkhrotn/multiflexscan |
This package provides functions for detecting multiple spatial disease clusters based on the information criterion and scan statistic approach by Takahashi and Shimadzu (2020), using the flexible spatial scan statistic (Tango and Takahashi, 2005) or Kulldorff's circular spatial scan statistic (1997) implemented in the rflexscan package (Otani and Takahashi, 2021).
Maintainer: Takahiro Otani [email protected] (ORCID)
Authors:
Takahiro Otani [email protected] (ORCID)
Kunihiko Takahashi
Takahashi K. and Shimadzu H. (2020). Detecting multiple spatial disease clusters: information criterion and scan statistic approach. International Journal of Health Geographics 19:33. doi:10.1186/s12942-020-00228-y
Tango T. and Takahashi K. (2005). A flexibly shaped spatial scan statistic for detecting clusters, International Journal of Health Geographics 4:11.
Otani T. and Takahashi K. (2021). Flexible scan statistics for detecting spatial disease clusters: The rflexscan R package. Journal of Statistical Software 99:13. doi:10.18637/jss.v099.i13
Takahashi K, Yokoyama T and Tango T. (2010). FleXScan v3.1: Software for the Flexible Scan Statistic. National Institute of Public Health, Japan, https://sites.google.com/site/flexscansoftware/home.
Useful links:
Report bugs at https://github.com/tkhrotn/multiflexscan/issues
AIC and BIC for the selected cluster model
## S3 method for class 'multiflexscan' AIC(object, ..., k = 2) ## S3 method for class 'multiflexscan' BIC(object, ...)## S3 method for class 'multiflexscan' AIC(object, ..., k = 2) ## S3 method for class 'multiflexscan' BIC(object, ...)
object |
A |
... |
Optionally, additional fitted model objects for comparison. |
k |
Numeric penalty per estimated parameter for |
These methods delegate to the standard R methods via logLik().
AIC and BIC are distinct from the criterion used to select the clusters;
use C_criterion() or RDC() for that criterion. Comparisons require
models fitted to the same response data with comparable likelihoods.
With one object, the AIC or BIC of the selected -cluster
model. With multiple objects, a data frame containing df and
AIC or BIC, as in stats::AIC().
model_criteria(), logLik.multiflexscan
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) AIC(fit) BIC(fit) AIC(fit, k = log(nobs(fit)))# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) AIC(fit) BIC(fit) AIC(fit, k = log(nobs(fit)))
Coerce selected clusters to a data frame
## S3 method for class 'multiflexscan' as.data.frame(x, row.names = NULL, optional = FALSE, ...)## S3 method for class 'multiflexscan' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
x |
A |
row.names |
Optional row names (ignored). |
optional |
Logical; ignored. |
... |
Additional arguments (ignored). |
A data frame of selected clusters (see clusters()).
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) as.data.frame(fit)# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) as.data.frame(fit)
Draw a choropleth map that highlights clusters selected by the information
criterion. The order of regions must match the input order used in
multiflexscan().
choropleth( x, regions, selected = seq_len(nclusters(x)), col = grDevices::palette(), background = "grey95", border = "grey80", border.lwd = 0.25, ... )choropleth( x, regions, selected = seq_len(nclusters(x)), col = grDevices::palette(), background = "grey95", border = "grey80", border.lwd = 0.25, ... )
x |
A |
regions |
An |
selected |
Integer vector specifying the clusters to highlight. By default, the clusters selected by the information criterion are highlighted. |
col |
Colors used for highlighted clusters. |
background |
Fill color for regions not in selected clusters. |
border |
Border color passed to the geometry plot. |
border.lwd |
Line width for polygon borders. A value smaller than the graphics default is used by default to reduce overlap in dense maps. |
... |
Additional arguments passed to the geometry plot. |
The regions object with an added cluster column (integer
cluster membership, 0 for unclustered regions), invisibly.
Requires the suggested sf package.
multiflexscan, plot.multiflexscan
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) if (requireNamespace("sf", quietly = TRUE)) { polygons <- lapply(seq_len(nrow(grid)), function(i) { x <- grid$x[i]; y <- grid$y[i] sf::st_polygon(list(cbind(x + c(-.5, .5, .5, -.5, -.5), y + c(-.5, -.5, .5, .5, -.5)))) }) regions <- sf::st_sf(id = seq_len(25), geometry = sf::st_sfc(polygons)) choropleth(fit, regions) }# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) if (requireNamespace("sf", quietly = TRUE)) { polygons <- lapply(seq_len(nrow(grid)), function(i) { x <- grid$x[i]; y <- grid$y[i] sf::st_polygon(list(cbind(x + c(-.5, .5, .5, -.5, -.5), y + c(-.5, -.5, .5, .5, -.5)))) }) regions <- sf::st_sf(id = seq_len(25), geometry = sf::st_sfc(polygons)) choropleth(fit, regions) }
Return a data frame of candidate clusters. By default only the clusters selected by the information criterion are returned.
clusters(object, selected = TRUE)clusters(object, selected = TRUE)
object |
A |
selected |
Logical; if |
A data frame with columns NumArea, MaxDist,
Case, Expected, RR, Stats, and P.
nclusters(), as.data.frame.multiflexscan, coef.multiflexscan
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) clusters(fit) clusters(fit, selected = FALSE)# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) clusters(fit) clusters(fit, selected = FALSE)
Extract selected cluster summaries
## S3 method for class 'multiflexscan' coef(object, ...)## S3 method for class 'multiflexscan' coef(object, ...)
object |
A |
... |
Additional arguments (ignored). |
A data frame of selected clusters (see clusters()).
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) coef(fit)# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) coef(fit)
Analysis settings
get_setting(object)get_setting(object)
object |
A |
A list of analysis settings stored in the object.
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) get_setting(fit)# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) get_setting(fit)
Log-likelihood of the selected cluster model
## S3 method for class 'multiflexscan' logLik(object, ...)## S3 method for class 'multiflexscan' logLik(object, ...)
object |
A |
... |
Unused; additional arguments are not supported. |
The likelihood includes the Poisson normalizing constants and is
conditional on the candidate regions. No model is refitted. The effective
parameter count is recovered from the stored identity
; it is not assumed to equal
when the model matrix is rank deficient. The Poisson dispersion is fixed.
An object of class logLik, containing the selected Poisson
model's log-likelihood, with attributes df (effective number of
estimated parameters) and nobs (number of regions).
model_criteria(), stats::AIC(), nobs()
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) logLik(fit) -2 * as.numeric(logLik(fit)) AIC(fit) BIC(fit)# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) logLik(fit) -2 * as.numeric(logLik(fit)) AIC(fit) BIC(fit)
Retrieve stored diagnostics without rerunning the analysis.
model_criteria(object, selected = FALSE) C_criterion(object) RDC(object)model_criteria(object, selected = FALSE) C_criterion(object) RDC(object)
object |
A |
selected |
Logical scalar. If |
The selected model minimizes C (equivalently maximizes
RDC); it does not necessarily minimize AIC or BIC. Ties are
resolved in favor of the smallest . The returned values describe
Poisson models conditional on the candidate regions found by the scan.
model_criteria() returns a data frame with columns K,
neg2logLik, AIC, BIC, C, and RDC.
C_criterion() and RDC() return the selected model's
corresponding criterion as a numeric scalar.
nclusters(), logLik.multiflexscan, AIC.multiflexscan
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) criteria <- model_criteria(fit) model_criteria(fit, selected = TRUE) plot(C ~ K, data = criteria, type = "b") C_criterion(fit) RDC(fit)# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) criteria <- model_criteria(fit) model_criteria(fit, selected = TRUE) plot(C ~ K, data = criteria, type = "b") C_criterion(fit) RDC(fit)
This function analyzes spatial count data using the flexible spatial scan statistic developed by Tango and Takahashi (2005) or Kulldorff's circular spatial scan statistic (1997), and detects multiple disease clusters by selecting the number of clusters with an information criterion.
multiflexscan( x, y, name, observed, expected, nb, clustertype = "HOT", clustersize = 15, clusterradius = .Machine$double.xmax, maxclusters = 10, stattype = "ORIGINAL", scanmethod = "FLEXIBLE", ralpha = 0.2, simcount = 999, verbose = FALSE, cores = max(1, parallel::detectCores() - 1), parallel_type = "PSOCK", seed = NULL )multiflexscan( x, y, name, observed, expected, nb, clustertype = "HOT", clustersize = 15, clusterradius = .Machine$double.xmax, maxclusters = 10, stattype = "ORIGINAL", scanmethod = "FLEXIBLE", ralpha = 0.2, simcount = 999, verbose = FALSE, cores = max(1, parallel::detectCores() - 1), parallel_type = "PSOCK", seed = NULL )
x |
A vector of X-coordinates. |
y |
A vector of Y-coordinates. |
name |
A vector of names of each area. |
observed |
A vector with the observed number of disease cases. |
expected |
A vector with the expected number of disease cases under the null hypothesis. This is used with the Poisson model. |
nb |
A neighbours list or an adjacency matrix. When a list is supplied, element
|
clustertype |
Type of cluster to be scanned.
|
clustersize |
Maximum spatial cluster size |
clusterradius |
Upper bound on the spatial radius of candidate scanning windows, in the same
units as |
maxclusters |
The maximum number of clusters to be detected. |
stattype |
Statistic type to be used (case-insensitive).
|
scanmethod |
Scanning method to be used (case-insensitive).
|
ralpha |
Threshold parameter of the mid-p-value for the restricted likelihood ratio statistic. |
simcount |
The number of Monte Carlo replications to calculate a p-value for statistical test. |
verbose |
Print progress messages. |
cores |
The number of CPU cores used for Monte Carlo replications. |
parallel_type |
Type of parallel backend passed to |
seed |
Optional integer seed for reproducible Monte Carlo replications. When
|
Centroid coordinates for each region should be specified by Cartesian
coordinates using arguments x and y. We recommend transforming
latitude and longitude onto an appropriate projected coordinate system before
calling this function.
The function first obtains non-overlapping candidate clusters by calling
rflexscan::runFleXScan(), then fits a sequence of Poisson generalized
linear models with cluster indicators and the expected counts as offsets. The
selected number of clusters is the value that maximizes the relative
difference criterion (RDC). The global p-value is calculated by Monte Carlo
simulation under the null hypothesis of no clustering.
The relative difference criterion for a model with clusters is
where is the information criterion of Takahashi and Shimadzu
(2020). The selected number of clusters nclust is the value of
that maximizes RDC. If several values of attain the
same maximum RDC, the smallest such is selected.
Monte Carlo p-values follow the rank-based convention used in rflexscan:
where is simcount. The overall p-value P compares the
maximum RDC from the observed data with maxima from datasets simulated
under the null Poisson model. Each null replication repeats the same
candidate search and model-selection steps on a Poisson draw under the null
expected counts. Cluster-level p-values pval compare each
candidate cluster's scan statistic stats with statistics from the
simulated datasets.
A list of class "multiflexscan" with the following components:
The matched call.
A list with coordinates (centroid matrix),
case (data frame of observed and expected counts), and
adj_mat (binary adjacency matrix with zero diagonal).
A list of candidate clusters returned by
rflexscan::runFleXScan(), each extended with Monte Carlo
rank and pval. Each element contains area (integer
indices into the input regions), name, max_dist,
n_case, expected, RR, stats, pval,
and rank.
Numeric vector of relative difference criterion values for
clusters.
Numeric vectors of model-selection
criteria for clusters.
Selected number of clusters (index with maximum
RDC).
Monte Carlo p-value for the overall clustering test.
Rank of the observed maximum RDC among simulated
maxima.
Numeric vector of maximum RDC values from Monte
Carlo replications.
A list recording analysis settings such as simcount,
maxclusters, clustersize, clusterradius,
stattype, scanmethod, and clustertype.
Tango T. and Takahashi K. (2005). A flexibly shaped spatial scan statistic for detecting clusters, International Journal of Health Geographics 4:11.
Kulldorff M. and Nagarwalla N. (1995). Spatial disease clusters: Detection and Inference. Statistics in Medicine 14:799-810.
Kulldorff M. (1997). A spatial scan statistic. Communications in Statistics: Theory and Methods, 26:1481-1496.
Tango T. (2008). A spatial scan statistic with a restricted likelihood ratio. Japanese Journal of Biometrics 29(2):75-95.
Takahashi K. and Shimadzu H. (2020). Detecting multiple spatial disease clusters: information criterion and scan statistic approach. International Journal of Health Geographics 19:33. doi:10.1186/s12942-020-00228-y
Otani T. and Takahashi K. (2021). Flexible scan statistics for detecting spatial disease clusters: The rflexscan R package. Journal of Statistical Software 99:13. doi:10.18637/jss.v099.i13
rflexscan::rflexscan, summary.multiflexscan, plot.multiflexscan, choropleth
if (requireNamespace("spdep", quietly = TRUE)) { # load sample data (North Carolina SIDS data) library(spdep) data("nc.sids") # calculate the expected numbers of cases expected <- nc.sids$BIR74 * sum(nc.sids$SID74) / sum(nc.sids$BIR74) # small settings are used here to keep the example fast; increase # 'simcount', 'clustersize', and 'maxclusters' for practical analyses fit <- multiflexscan( x = nc.sids$x, y = nc.sids$y, observed = nc.sids$SID74, expected = expected, name = rownames(nc.sids), nb = ncCR85.nb, clustersize = 5, maxclusters = 3, simcount = 99, cores = 1 ) print(fit) summary(fit) plot(fit) }if (requireNamespace("spdep", quietly = TRUE)) { # load sample data (North Carolina SIDS data) library(spdep) data("nc.sids") # calculate the expected numbers of cases expected <- nc.sids$BIR74 * sum(nc.sids$SID74) / sum(nc.sids$BIR74) # small settings are used here to keep the example fast; increase # 'simcount', 'clustersize', and 'maxclusters' for practical analyses fit <- multiflexscan( x = nc.sids$x, y = nc.sids$y, observed = nc.sids$SID74, expected = expected, name = rownames(nc.sids), nb = ncCR85.nb, clustersize = 5, maxclusters = 3, simcount = 99, cores = 1 ) print(fit) summary(fit) plot(fit) }
Number of clusters selected by the information criterion
nclusters(object)nclusters(object)
object |
A |
Integer number of selected clusters.
pvalue(), clusters(), get_setting()
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) nclusters(fit)# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) nclusters(fit)
Number of regions in the analysis
## S3 method for class 'multiflexscan' nobs(object, ...)## S3 method for class 'multiflexscan' nobs(object, ...)
object |
A |
... |
Additional arguments (ignored). |
Number of regions (rows) in the input data.
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) nobs(fit)# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) nobs(fit)
multiflexscan object. The neighborhood graph is
drawn with igraph, following plot.rflexscan().Plot method for the multiflexscan object. The neighborhood graph is
drawn with igraph, following plot.rflexscan().
## S3 method for class 'multiflexscan' plot( x, rank = seq_len(nclusters(x)), pval = 1, vertexsize = max(x$input$coordinates[, 1]) - min(x$input$coordinates[, 1]), xlab = colnames(x$input$coordinates)[1], ylab = colnames(x$input$coordinates)[2], xlim = c(min(x$input$coordinates[, 1]), max(x$input$coordinates[, 1])), ylim = c(min(x$input$coordinates[, 2]), max(x$input$coordinates[, 2])), col = palette(), frame_color = "gray40", vertex_color = "white", ... )## S3 method for class 'multiflexscan' plot( x, rank = seq_len(nclusters(x)), pval = 1, vertexsize = max(x$input$coordinates[, 1]) - min(x$input$coordinates[, 1]), xlab = colnames(x$input$coordinates)[1], ylab = colnames(x$input$coordinates)[2], xlim = c(min(x$input$coordinates[, 1]), max(x$input$coordinates[, 1])), ylim = c(min(x$input$coordinates[, 2]), max(x$input$coordinates[, 2])), col = palette(), frame_color = "gray40", vertex_color = "white", ... )
x |
A |
rank |
Integer vector specifying the clusters to highlight. |
pval |
Maximum cluster-level p-value for a candidate cluster to be highlighted. |
vertexsize |
Size of region centroids in the igraph plot. |
xlab |
Label of the x-axis. |
ylab |
Label of the y-axis. |
xlim |
Limits of the x-axis. |
ylim |
Limits of the y-axis. |
col |
Colors used for highlighted clusters. |
frame_color |
Color used for neighborhood edges and vertex frames not highlighted as clusters. |
vertex_color |
Color used for region centroids that are not highlighted as clusters. |
... |
Additional arguments passed to |
The input object, invisibly.
multiflexscan, choropleth, rflexscan::plot.rflexscan
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) plot(fit, xlab = "Grid x", ylab = "Grid y")# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) plot(fit, xlab = "Grid x", ylab = "Grid y")
Print method for multiflexscan objects.
## S3 method for class 'multiflexscan' print(x, ...)## S3 method for class 'multiflexscan' print(x, ...)
x |
A |
... |
Ignored. |
The input object, invisibly.
multiflexscan, summary.multiflexscan
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) print(fit)# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) print(fit)
Print summary of multiflexscan results to the terminal.
## S3 method for class 'summary.multiflexscan' print(x, ...)## S3 method for class 'summary.multiflexscan' print(x, ...)
x |
A |
... |
Ignored. |
The input object, invisibly.
multiflexscan, summary.multiflexscan
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) report <- summary(fit) print(report)# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) report <- summary(fit) print(report)
Overall Monte Carlo p-value
pvalue(object)pvalue(object)
object |
A |
Numeric overall p-value for the multiple-cluster detection test.
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) pvalue(fit)# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) pvalue(fit)
Summary method for multiflexscan objects.
## S3 method for class 'multiflexscan' summary(object, ...)## S3 method for class 'multiflexscan' summary(object, ...)
object |
A |
... |
Ignored. |
A list of class "summary.multiflexscan" with components
call, total_areas, total_cases, cluster
(data frame of per-cluster statistics), RDC, nclust,
P, and setting.
multiflexscan, print.summary.multiflexscan
# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) summary(fit)# A small synthetic grid; low simulation count keeps this example quick. grid <- expand.grid(x = 1:5, y = 1:5) nb <- lapply(seq_len(nrow(grid)), function(i) which( abs(grid$x - grid$x[i]) + abs(grid$y - grid$y[i]) == 1)) observed <- rep(10, 25) observed[c(1, 2, 6, 7)] <- 30 fit <- multiflexscan(grid$x, grid$y, name = as.character(seq_len(25)), observed = observed, expected = rep(mean(observed), 25), nb = nb, scanmethod = "CIRCULAR", clustersize = 4, maxclusters = 3, simcount = 19, cores = 1, seed = 20261002) summary(fit)