Skip to contents

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.

Usage

# S3 method for class 'localjc'
print(x, ...)

# S3 method for class 'localjc'
plot(x, ..., sf = NULL, coor = NULL, sig = 0.05)

Arguments

x

a localjc object created by Q.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. Default sig = 0.05

Value

No return value, called for side effects

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ópezfernando.lopez@upct.es
Román Mínguezroman.minguez@uclm.es
Antonio Páezpaezha@gmail.com
Manuel Ruizmanuel.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        7 7.183838 1.59988 -0.1149076 0.4542591853
#> 2        7 7.183838 1.59988 -0.1149076 0.4542591853
#> 3        3 7.183838 1.59988 -2.6150947 0.0044601364
#> 4        8 7.183838 1.59988  0.5101392 0.6950230217
#> 5        8 7.183838 1.59988  0.5101392 0.6950230217
#> 6        4 7.183838 1.59988 -1.9900479 0.0232928297
#> 7        5 7.183838 1.59988 -1.3650011 0.0861263477
#> 8        5 7.183838 1.59988 -1.3650011 0.0861263477
#> 9        5 7.183838 1.59988 -1.3650011 0.0861263477
#> 10       9 7.183838 1.59988  1.1351860 0.8718512930
#> 11       5 7.183838 1.59988 -1.3650011 0.0861263477
#> 12       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 13       5 7.183838 1.59988 -1.3650011 0.0861263477
#> 14       6 7.183838 1.59988 -0.7399544 0.2296638446
#> 15       8 7.183838 1.59988  0.5101392 0.6950230217
#> 16       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 17       8 7.183838 1.59988  0.5101392 0.6950230217
#> 18       5 7.183838 1.59988 -1.3650011 0.0861263477
#> 19      10 7.183838 1.59988  1.7602327 0.9608158220
#> 20       8 7.183838 1.59988  0.5101392 0.6950230217
#> 21       8 7.183838 1.59988  0.5101392 0.6950230217
#> 22       5 7.183838 1.59988 -1.3650011 0.0861263477
#> 23       5 7.183838 1.59988 -1.3650011 0.0861263477
#> 24       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 25       9 7.183838 1.59988  1.1351860 0.8718512930
#> 26       4 7.183838 1.59988 -1.9900479 0.0232928297
#> 27       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 28       3 7.183838 1.59988 -2.6150947 0.0044601364
#> 29       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 30       8 7.183838 1.59988  0.5101392 0.6950230217
#> 31       8 7.183838 1.59988  0.5101392 0.6950230217
#> 32       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 33       6 7.183838 1.59988 -0.7399544 0.2296638446
#> 34       8 7.183838 1.59988  0.5101392 0.6950230217
#> 35       3 7.183838 1.59988 -2.6150947 0.0044601364
#> 36       9 7.183838 1.59988  1.1351860 0.8718512930
#> 37       6 7.183838 1.59988 -0.7399544 0.2296638446
#> 38       6 7.183838 1.59988 -0.7399544 0.2296638446
#> 39       6 7.183838 1.59988 -0.7399544 0.2296638446
#> 40       9 7.183838 1.59988  1.1351860 0.8718512930
#> 41       5 7.183838 1.59988 -1.3650011 0.0861263477
#> 42       6 7.183838 1.59988 -0.7399544 0.2296638446
#> 43       6 7.183838 1.59988 -0.7399544 0.2296638446
#> 44       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 45       6 7.183838 1.59988 -0.7399544 0.2296638446
#> 46       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 47       9 7.183838 1.59988  1.1351860 0.8718512930
#> 48       5 7.183838 1.59988 -1.3650011 0.0861263477
#> 49       4 7.183838 1.59988 -1.9900479 0.0232928297
#> 50       8 7.183838 1.59988  0.5101392 0.6950230217
#> 51       6 7.183838 1.59988 -0.7399544 0.2296638446
#> 52       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 53      11 7.183838 1.59988  2.3852795 0.9914669250
#> 54       8 7.183838 1.59988  0.5101392 0.6950230217
#> 55       8 7.183838 1.59988  0.5101392 0.6950230217
#> 56       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 57       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 58       5 7.183838 1.59988 -1.3650011 0.0861263477
#> 59       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 60       2 7.183838 1.59988 -3.2401414 0.0005973521
#> 61       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 62       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 63       4 7.183838 1.59988 -1.9900479 0.0232928297
#> 64       4 7.183838 1.59988 -1.9900479 0.0232928297
#> 65       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 66       6 7.183838 1.59988 -0.7399544 0.2296638446
#> 67       8 7.183838 1.59988  0.5101392 0.6950230217
#> 68       3 7.183838 1.59988 -2.6150947 0.0044601364
#> 69       3 7.183838 1.59988 -2.6150947 0.0044601364
#> 70       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 71       5 7.183838 1.59988 -1.3650011 0.0861263477
#> 72       4 7.183838 1.59988 -1.9900479 0.0232928297
#> 73       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 74       8 7.183838 1.59988  0.5101392 0.6950230217
#> 75       8 7.183838 1.59988  0.5101392 0.6950230217
#> 76       4 7.183838 1.59988 -1.9900479 0.0232928297
#> 77       6 7.183838 1.59988 -0.7399544 0.2296638446
#> 78       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 79       5 7.183838 1.59988 -1.3650011 0.0861263477
#> 80       3 7.183838 1.59988 -2.6150947 0.0044601364
#> 81       9 7.183838 1.59988  1.1351860 0.8718512930
#> 82       8 7.183838 1.59988  0.5101392 0.6950230217
#> 83       8 7.183838 1.59988  0.5101392 0.6950230217
#> 84       5 7.183838 1.59988 -1.3650011 0.0861263477
#> 85       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 86       6 7.183838 1.59988 -0.7399544 0.2296638446
#> 87       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 88       5 7.183838 1.59988 -1.3650011 0.0861263477
#> 89       3 7.183838 1.59988 -2.6150947 0.0044601364
#> 90       9 7.183838 1.59988  1.1351860 0.8718512930
#> 91       3 7.183838 1.59988 -2.6150947 0.0044601364
#> 92       5 7.183838 1.59988 -1.3650011 0.0861263477
#> 93       8 7.183838 1.59988  0.5101392 0.6950230217
#> 94       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 95      10 7.183838 1.59988  1.7602327 0.9608158220
#> 96       7 7.183838 1.59988 -0.1149076 0.4542591853
#> 97       6 7.183838 1.59988 -0.7399544 0.2296638446
#> 98       8 7.183838 1.59988  0.5101392 0.6950230217
#> 99       6 7.183838 1.59988 -0.7399544 0.2296638446
#> 100      8 7.183838 1.59988  0.5101392 0.6950230217
plot(lsrq, sig = 0.05)