The plot()
function allows the user to plot significant observations.
The print()
function is used to print the number of runs in each localization. Additional information of
expected values and standard deviation, z-value ans p-value is prited for each observation.
Arguments
- x
a
localsrq
object created byQ.test
.- ...
further arguments passed to or from other methods.
- sf
optional argument for
plot()
method to include a sf object (default = NULL)- coor
optional argument for
plot()
method to include coordinates of points (default = NULL)- sig
significant level for each observation in
plot()
method. Defaultsig = 0.05
References
Ruiz, M., López, F., and Páez, A. (2021). A test for global and local homogeneity of categorical data based on spatial runs. working paper.
Author
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 |
Examples
# Example 1: Local spatial runs test based on knn
N <- 100
cx <- runif(N)
cy <- runif(N)
x <- cbind(cx,cy)
listw <- spdep::knearneigh(cbind(cx,cy), k = 10)
p <- c(1/6,3/6,2/6)
rho <- 0.5
fx <- dgp.spq(p = p, listw = listw, rho = rho)
# Asymtotic version
lsrq <- local.sp.runs.test(fx = fx, listw = listw, alternative = "less")
print(lsrq)
#> runs.i E.i Std.i z.value p.value
#> 1 5 7.183838 1.59988 -1.3650011 0.0861263477
#> 2 8 7.183838 1.59988 0.5101392 0.6950230217
#> 3 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 4 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 5 3 7.183838 1.59988 -2.6150947 0.0044601364
#> 6 5 7.183838 1.59988 -1.3650011 0.0861263477
#> 7 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 8 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 9 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 10 8 7.183838 1.59988 0.5101392 0.6950230217
#> 11 10 7.183838 1.59988 1.7602327 0.9608158220
#> 12 9 7.183838 1.59988 1.1351860 0.8718512930
#> 13 8 7.183838 1.59988 0.5101392 0.6950230217
#> 14 5 7.183838 1.59988 -1.3650011 0.0861263477
#> 15 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 16 10 7.183838 1.59988 1.7602327 0.9608158220
#> 17 8 7.183838 1.59988 0.5101392 0.6950230217
#> 18 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 19 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 20 8 7.183838 1.59988 0.5101392 0.6950230217
#> 21 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 22 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 23 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 24 2 7.183838 1.59988 -3.2401414 0.0005973521
#> 25 5 7.183838 1.59988 -1.3650011 0.0861263477
#> 26 8 7.183838 1.59988 0.5101392 0.6950230217
#> 27 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 28 5 7.183838 1.59988 -1.3650011 0.0861263477
#> 29 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 30 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 31 8 7.183838 1.59988 0.5101392 0.6950230217
#> 32 10 7.183838 1.59988 1.7602327 0.9608158220
#> 33 10 7.183838 1.59988 1.7602327 0.9608158220
#> 34 10 7.183838 1.59988 1.7602327 0.9608158220
#> 35 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 36 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 37 5 7.183838 1.59988 -1.3650011 0.0861263477
#> 38 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 39 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 40 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 41 5 7.183838 1.59988 -1.3650011 0.0861263477
#> 42 5 7.183838 1.59988 -1.3650011 0.0861263477
#> 43 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 44 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 45 4 7.183838 1.59988 -1.9900479 0.0232928297
#> 46 10 7.183838 1.59988 1.7602327 0.9608158220
#> 47 3 7.183838 1.59988 -2.6150947 0.0044601364
#> 48 4 7.183838 1.59988 -1.9900479 0.0232928297
#> 49 3 7.183838 1.59988 -2.6150947 0.0044601364
#> 50 5 7.183838 1.59988 -1.3650011 0.0861263477
#> 51 9 7.183838 1.59988 1.1351860 0.8718512930
#> 52 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 53 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 54 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 55 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 56 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 57 8 7.183838 1.59988 0.5101392 0.6950230217
#> 58 9 7.183838 1.59988 1.1351860 0.8718512930
#> 59 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 60 10 7.183838 1.59988 1.7602327 0.9608158220
#> 61 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 62 10 7.183838 1.59988 1.7602327 0.9608158220
#> 63 4 7.183838 1.59988 -1.9900479 0.0232928297
#> 64 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 65 5 7.183838 1.59988 -1.3650011 0.0861263477
#> 66 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 67 5 7.183838 1.59988 -1.3650011 0.0861263477
#> 68 5 7.183838 1.59988 -1.3650011 0.0861263477
#> 69 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 70 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 71 8 7.183838 1.59988 0.5101392 0.6950230217
#> 72 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 73 4 7.183838 1.59988 -1.9900479 0.0232928297
#> 74 5 7.183838 1.59988 -1.3650011 0.0861263477
#> 75 8 7.183838 1.59988 0.5101392 0.6950230217
#> 76 4 7.183838 1.59988 -1.9900479 0.0232928297
#> 77 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 78 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 79 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 80 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 81 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 82 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 83 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 84 9 7.183838 1.59988 1.1351860 0.8718512930
#> 85 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 86 8 7.183838 1.59988 0.5101392 0.6950230217
#> 87 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 88 3 7.183838 1.59988 -2.6150947 0.0044601364
#> 89 8 7.183838 1.59988 0.5101392 0.6950230217
#> 90 4 7.183838 1.59988 -1.9900479 0.0232928297
#> 91 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 92 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 93 9 7.183838 1.59988 1.1351860 0.8718512930
#> 94 5 7.183838 1.59988 -1.3650011 0.0861263477
#> 95 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 96 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 97 6 7.183838 1.59988 -0.7399544 0.2296638446
#> 98 4 7.183838 1.59988 -1.9900479 0.0232928297
#> 99 7 7.183838 1.59988 -0.1149076 0.4542591853
#> 100 7 7.183838 1.59988 -0.1149076 0.4542591853
plot(lsrq, sig = 0.05)