Learn R Programming

spqdep (version 0.1.3.6)

Q.map.test: Compute the QE and QI tests of Equivalence and Independence between maps

Description

This function compute the QE and QI tests for maps comparison based on symbolic entropy.

Usage

Q.map.test(formula = formula, data = data, coor = NULL, m = m, r = 1,
type = "combinations", control = list())

Value

A list with two objects of the class htest. The first one is the QE test of Equivalence between maps and the second one is the QI test of independence between maps. the elements of each test are:

methoda character string giving description of the method.
data.namea character string giving the name(s) of the data.
statisticthe value of the statistic QE or/and QI.
alternativea character string describing the alternative hypothesis.
p.valuep-value for QE or QI.
parameterfree degree of the statistic for QE or QI.
symbA matrix with the symbols.
mhm-surrounding of th map.
Tmnumber of maps (ONLY 2).
sample.sizenumber of symbolized observations.
nska matrix Tm x symbols with the frequency of the number of symbols of each map.

Arguments

formula

a symbolic description of the two factors.

data

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

coor

(optional) a 2xN vector with coordinates.

m

length of m-surrounding.

r

maximum overlapping between any two m-surroundings (default = 1).

type

Type of symbols: "permutations" or "combinations". Default "combinations"

control

Optional argument. See Control Argument section.

Control arguments

Several parameters to construct the m-surrounding

dtmaxabs

Delete degenerate surrounding based on the absolute distance between observations.

dtmaxpc

A value between 0 and 1. Delete degenerate surrounding based on the distance. Delete m-surrounding when the maximum distance between observation is upper than k percentage of maximum distance between anywhere observation.

dtmaxknn

A integer value 'k'. Delete degenerate surrounding based on the near neighborhood criteria. Delete m-surrounding is a element of the m-surrounding is not include in the set of k near neighborhood of the first element

seedinit

seed to select the initial element to star the algorithm to compute the m-surroundings.

Author

Fernando Lópezfernando.lopez@upct.es
Román Mínguezroman.minguez@uclm.es
Antonio Páezpaezha@gmail.com
Manuel Ruizmanuel.ruiz@upct.es

Details

If data is not a sf object the coor argument with the coordinates of each observation must be included.

References

  • Ruiz M, López FA and A Páez (2011). Comparison of Thematic Maps Using Symbolic Entropy. International Journal of Geographical Information Science, 26, 413-439.

  • Ruiz, M., López, FA, and Páez, A. (2010). Testing for spatial association of qualitative data using symbolic dynamics. Journal of Geographical Systems, 12(3), 281-309.0.

See Also

dgp.spq, m.surround, Q.test

Examples

Run this code

# Case 1:
N <- 200
cx <- runif(N)
cy <- runif(N)
x <- cbind(cx,cy)
listw <- spdep::nb2listw(spdep::knn2nb(
           spdep::knearneigh(cbind(cx,cy), k = 4)))
p <- c(1/6, 3/6, 2/6)
rho = 0.5
QY1 <- dgp.spq(p = p, listw = listw, rho = rho)
rho = 0.8
QY2 <- dgp.spq(p = p, listw = listw, rho = rho)
dt = data.frame(QY1,QY2)
m = 3
r = 1
formula <- ~ QY1 + QY2
control <- list(dtmaxknn = 10)
qmap <- Q.map.test(formula = formula, data = dt, coor = x, m = m, r = r,
                   type ="combinations", control = control)
print(qmap)
plot(qmap)
plot(qmap, ci=.6)
plot(qmap[[1]]$mh)
summary(qmap[[1]]$mh)

control <- list(dtmaxknn = 20)
qmap <- Q.map.test(formula = formula, data = dt, coor = x, m = m, r = r,
                   type ="permutations", control = control)
print(qmap)
plot(qmap)
plot(qmap[[1]]$mh)
qmap <- Q.map.test(formula = formula, data = dt, coor = x, m = m, r = r,
                   type ="combinations")
print(qmap)
plot(qmap)
control <- list(dtmaxknn = 10)
qmap <- Q.map.test(formula = formula, data = dt, coor = x, m = m, r = r,
                   type ="combinations", control = control)
print(qmap)
plot(qmap)

# Case 2:
data(provinces_spain)
# sf::sf_use_s2(FALSE)
m = 3
r = 1

provinces_spain$Mal2Fml <- factor(provinces_spain$Mal2Fml > 100)
levels(provinces_spain$Mal2Fml) = c("men","woman")
provinces_spain$Coast <- factor(provinces_spain$Coast)
levels(provinces_spain$Coast) = c("no","yes")
formula <- ~ Coast + Mal2Fml
qmap <- Q.map.test(formula = formula, data = provinces_spain, m = m, r = r,
                   type ="combinations")
print(qmap)
plot(qmap)
plot(qmap[[1]]$mh)

control <- list(dtmaxknn = 6)
qmap <- Q.map.test(formula = formula, data = provinces_spain, m = m, r = r,
                   type ="combinations", control = control)
print(qmap)
plot(qmap[[1]]$mh)
summary(qmap[[1]]$mh)

Run the code above in your browser using DataLab