scan.test: Compute the scan test.

Description Usage Arguments Details Value Control arguments Author(s) References See Also Examples

View source: R/scan.test.R

Description

This function compute the scan test for Bernoulli and Multinomial categorical spatial process.

Usage

1
2
scan.test(formula = NULL, data = NULL, fx = NULL, coor = NULL, case = NULL, nv = NULL,
nsim = NULL, distr = NULL, windows = "circular", alternative = "High", control = list())

Arguments

formula

a symbolic description of the factor (optional).

data

an (optional) data frame or a sf object containing the variable to testing for.

fx

a factor (optional).

coor

(optional) coordinates of observations.

case

Only for bernoulli distribution. A element of factor, there are cases and non-cases for testing for cases versus non-cases

nv

Maximum windows size, default nv = N/2. The algorithm scan for clusters of geographic size between 1 and the upper limit (nv) defined by the user.

nsim

Number of permutations.

distr

distribution of the spatial process: "bernoulli" for two levels or "multinomial" for three or more levels.

windows

a string to select the type of cluster "circular" (default) of "elliptic".

alternative

Only for bernoulli spatial process. A character string specifying the type of cluster, must be one of "High" (default), "Both" or "Low".

control

List of additional control arguments.

Details

Two alternative sets of arguments can be included in this function to compute the scan test:

Option 1 A factor (fx) and coordinates (coor).
Option 2 A sf object (data) and the formula to specify the factor. The function consider the coordinates of the centroids of the elements of th sf object.

The spatial scan statistics are widely used in epidemiology, criminology or ecology. Their purpose is to analyze the spatial distribution of points or geographical regions by testing the hypothesis of spatial randomness his distribution on the basis of different distributions (e.g. Bernoulli, Poisson or Normal distributions). The scan.test function obtain the scan statistic for the Bernoulli and Multinomial distribution.

To test independence in a spatial process, under the null, the type of windows is irrelevant but under the alternative the elliptic windows can to identify with more precision the cluster.

For big data sets (N >>) the windows = "elliptic" can be so slowly

Value

A object of the htest and scantest class

method The type of test applied ().
fx Factor included as input to get the scan test.
MLC Observations included into the Most Likelihood Cluster (MLC).
statistic Value of the scan test (maximum Log-likelihood ratio).
N Total number of observations.
nn Windows used to get the cluster.
nv Maximum number of observations into the cluster.
data.name A character string giving the name of the factor.
coor coordinates.
alternative Only for bernoulli spatial process. A character string describing the alternative hypothesis select by the user.
p.value p-value of the scan test.
cases.expect Expected cases into the MLC.
cases.observ Observed cases into the MLC.
nsim Number of permutations.

Control arguments

seedinit Numerical value for the seed (only for boot version). Default value seedinit=123

Author(s)

Fernando López fernando.lopez@upct.es
Román Mínguez roman.minguez@uclm.es
Antonio Páez paezha@gmail.com
Manuel Ruiz manuel.ruiz@upct.es

References

See Also

local.sp.runs.test, dgp.spq, Q.test,

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Case 1: scan test bernoulli
rm(list = ls())
data(Spain)
formula <- ~ MenWoman
scan <- scan.test(formula = formula, data = spain.sf, case="men", nsim = 99, distr = "bernoulli")
print(scan)
summary(scan)
plot(scan, sf = spain.sf)
scan <- scan.test(formula = formula, data = spain.sf, case="men", nv = 5, nsim = 99, distr = "bernoulli")
print(scan)
plot(scan, sf = spain.sf)
scan <- scan.test(formula = formula, data = spain.sf, case="men", nv = 15, nsim = 99, distr = "bernoulli", windows ="elliptic")
print(scan)
scan <- scan.test(formula = formula, data = spain.sf, case="men", nv = 15, nsim = 99, distr = "bernoulli", windows ="elliptic", alternative = "Low")
print(scan)
plot.scantest(scan, sf = spain.sf)

# Case 2: scan test multinomial
rm(list = ls())
data(Spain)
formula <- ~ Older65
scan <- scan.test(formula = formula, data = spain.sf, nsim = 99, distr = "multinomial")
print(scan)
plot(scan, sf = spain.sf)

# Case 3: scan test multinomial
rm(list = ls())
data(FastFood)
formula <- ~ Type
scan <- scan.test(formula = formula, data = FastFood.sf, nsim = 99, distr = "multinomial", windows="elliptic", nv = 100)
print(scan)
summary(scan)
plot.scantest(scan, sf = FastFood.sf)

# Case 4: DGP two categories
rm(list = ls())
N <- 500
cx <- runif(N)
cy <- runif(N)
listw <- knearneigh(cbind(cx,cy), k = 10)
p <- c(1/2,1/2)
rho <- 0.5
fx <- dgp.spq(p = p, listw = listw, rho = rho)
scan <- scan.test(fx = fx, nsim = 9, case = "1", nv = 20, coor = cbind(cx,cy), distr = "bernoulli",windows="elliptic")
print(scan)
plot.scantest(scan)

# Case 5: DGP three categories
rm(list = ls())
N <- 1000
cx <- runif(N)
cy <- runif(N)
listw <- knearneigh(cbind(cx,cy), k = 10)
p <- c(1/3,1/3,1/3)
rho <- 0.5
fx <- dgp.spq(p = p, listw = listw, rho = rho)
scan <- scan.test(fx = fx, nsim = 19, coor = cbind(cx,cy), nv = 30, distr = "multinomial",windows="elliptic")
print(scan)
plot.scantest(scan)

paezha/spqdata documentation built on Dec. 22, 2021, 5:24 a.m.