Reports the local Moran Coefficient for each unit.
Tests for the presence of spatial autocorrelation in variables as indicated by the Moran coefficient. The variance is calculated under the normality assumption.
MI.local(x, W, alternative = "greater")
MI.vec(x, W, alternative = "greater", symmetrize = TRUE)a vector or matrix
spatial connectivity matrix
specification of alternative hypothesis as 'greater' (default), 'lower', or 'two.sided'
symmetrizes the connectivity matrix W by: 1/2 * (W + W') (TRUE/ FALSE).
Returns an object of class data.frame that contains the
following information for each variable:
Iiobserved value of local Moran's I
EIiexpected value of local Moran coefficients
VarIivariance of local Moran's I
zIistandardized local Moran coefficient
pIip-value of the test statistic
Returns an object of class data.frame that contains the
following information for each variable:
Iobserved value of the Moran coefficient
EIexpected value of Moran's I
VarIvariance of Moran's I (under normality)
zIstandardized Moran coefficient
pIp-value of the test statistic
If x is a matrix, this function computes the Moran
test for spatial autocorrelation for each column.
The calculation of the statistic and its moments follows Anselin (1995) and Sokal et al. (1998).
Estimation of the variance (under the normality assumption)
follows Cliff and Ord (1981), see also Upton and Fingleton (1985).
It assumes the connectivity matrix W to be symmetric.
For inherently non-symmetric matrices, it is recommended to specify
symmetrize=TRUE.
Anselin, Luc (1991): Local Indicators of Spatial Association-LISA. Geographical Analysis, 27 (2): pp. 93 - 115.
Bivand, Roger S. and David W. S. Wong (2018): Comparing Implementations of Global and Local Indicators of Spatial Association. TEST, 27: pp. 716 - 748.
Sokal, Robert R., Neal L. Oden, Barbara A. Thomson (1998): Local Spatial Autocorrelation in a Biological Model. Geographical Analysis, 30 (4): pp. 331 - 354.
Cliff, Andrew D. and John K. Ord (1981): Spatial Processes: Models & Applications. Pion, London.
Upton, Graham J. G. and Bernard Fingleton (1985): Spatial Data Analysis by Example, Volume 1. New York, Wiley.
Bivand, Roger S. and David W. S. Wong (2018): Comparing Implementations of Global and Local Indicators of Spatial Association. TEST 27: pp. 716 - 748.
data(fakedata)
x <- fakedataset$x2
(MIi <- MI.local(x = x, W = W, alternative = "greater"))
#> Ii EIi VarIi zIi pIi
#> 1 -0.1605244807 -0.02020202 1.943397 -0.1006575573 5.400888e-01
#> 2 -0.2045168571 -0.03030303 2.885612 -0.1025566146 5.408426e-01
#> 3 -0.1952635640 -0.03030303 2.885612 -0.0971093638 5.386802e-01
#> 4 -0.2006724317 -0.03030303 2.885612 -0.1002934690 5.399443e-01
#> 5 -0.1258476149 -0.03030303 2.885612 -0.0562454159 5.224268e-01
#> 6 3.2764878469 -0.03030303 2.885612 1.9466496080 2.578838e-02 *
#> 7 0.0449130519 -0.03030303 2.885612 0.0442783842 4.823413e-01
#> 8 6.7177964251 -0.03030303 2.885612 3.9724874199 3.556300e-05 ***
#> 9 4.5319624724 -0.03030303 2.885612 2.6857254306 3.618627e-03 **
#> 10 3.4070226935 -0.02020202 1.943397 2.4584522436 6.976867e-03 **
#> 11 -1.5989822781 -0.03030303 2.885612 -0.9234538731 8.221146e-01
#> 12 0.1420217092 -0.04040404 3.808170 0.0934819985 4.627603e-01
#> 13 0.4898396510 -0.04040404 3.808170 0.2717173430 3.929197e-01
#> 14 -0.0764245736 -0.04040404 3.808170 -0.0184583122 5.073634e-01
#> 15 -0.4892996972 -0.04040404 3.808170 -0.2300314688 5.909663e-01
#> 16 1.0365712215 -0.04040404 3.808170 0.5518837121 2.905140e-01
#> 17 0.6654888579 -0.04040404 3.808170 0.3617267795 3.587781e-01
#> 18 2.2578597838 -0.04040404 3.808170 1.1777191320 1.194543e-01
#> 19 -1.3571502901 -0.04040404 3.808170 -0.6747516251 7.500832e-01
#> 20 0.5045425431 -0.03030303 2.885612 0.3148541787 3.764362e-01
#> 21 -0.1383694593 -0.03030303 2.885612 -0.0636168054 5.253623e-01
#> 22 0.8470667658 -0.04040404 3.808170 0.4547743111 3.246358e-01
#> 23 -0.3795626483 -0.04040404 3.808170 -0.1737979674 5.689879e-01
#> 24 0.1254267971 -0.04040404 3.808170 0.0849781248 4.661394e-01
#> 25 0.9046200627 -0.04040404 3.808170 0.4842668429 3.140983e-01
#> 26 -4.1461523363 -0.04040404 3.808170 -2.1039439721 9.823083e-01
#> 27 0.0449570156 -0.04040404 3.808170 0.0437423014 4.825549e-01
#> 28 -0.0067201597 -0.04040404 3.808170 0.0172609212 4.931142e-01
#> 29 -0.6050902281 -0.04040404 3.808170 -0.2893670082 6.138497e-01
#> 30 -1.8434420401 -0.03030303 2.885612 -1.0673630338 8.570960e-01
#> 31 0.5838022344 -0.03030303 2.885612 0.3615129644 3.588580e-01
#> 32 0.0153829551 -0.04040404 3.808170 0.0285874107 4.885968e-01
#> 33 -0.6895735008 -0.04040404 3.808170 -0.3326594994 6.303043e-01
#> 34 5.7725515613 -0.04040404 3.808170 2.9787829201 1.446979e-03 **
#> 35 3.8178763177 -0.04040404 3.808170 1.9771318446 2.401336e-02 *
#> 36 -0.1301774683 -0.04040404 3.808170 -0.0460033711 5.183462e-01
#> 37 0.9035944687 -0.04040404 3.808170 0.4837412890 3.142847e-01
#> 38 0.0004932862 -0.04040404 3.808170 0.0209573694 4.916398e-01
#> 39 0.3611880285 -0.04040404 3.808170 0.2057912838 4.184770e-01
#> 40 0.0913618830 -0.03030303 2.885612 0.0716219938 4.714514e-01
#> 41 0.9804620721 -0.03030303 2.885612 0.5950196318 2.759152e-01
#> 42 0.9703849796 -0.04040404 3.808170 0.5179673259 3.022405e-01
#> 43 -3.0341915102 -0.04040404 3.808170 -1.5341323059 9.375014e-01
#> 44 10.2889380939 -0.04040404 3.808170 5.2931537816 6.011237e-08 ***
#> 45 5.5887852776 -0.04040404 3.808170 2.8846139801 1.959469e-03 **
#> 46 -2.6082392885 -0.04040404 3.808170 -1.3158579392 9.058891e-01
#> 47 0.8829068593 -0.04040404 3.808170 0.4731401590 3.180566e-01
#> 48 -0.2914804624 -0.04040404 3.808170 -0.1286612541 5.511872e-01
#> 49 -0.5338129908 -0.04040404 3.808170 -0.2528417994 5.998048e-01
#> 50 -0.0441577625 -0.03030303 2.885612 -0.0081560371 5.032538e-01
#> 51 0.3489793975 -0.03030303 2.885612 0.2232768920 4.116600e-01
#> 52 0.1387332108 -0.04040404 3.808170 0.0917968450 4.634297e-01
#> 53 0.0120665538 -0.04040404 3.808170 0.0268879586 4.892745e-01
#> 54 3.1787312012 -0.04040404 3.808170 1.6496092061 4.951145e-02 *
#> 55 0.7343081456 -0.04040404 3.808170 0.3969924400 3.456865e-01
#> 56 -2.0088589009 -0.04040404 3.808170 -1.0087122832 8.434437e-01
#> 57 -2.7449247497 -0.04040404 3.808170 -1.3859008477 9.171114e-01
#> 58 -0.5565569290 -0.04040404 3.808170 -0.2644966716 6.043014e-01
#> 59 1.2903456623 -0.04040404 3.808170 0.6819275351 2.476424e-01
#> 60 0.1114650093 -0.03030303 2.885612 0.0834563506 4.667443e-01
#> 61 0.3992296196 -0.03030303 2.885612 0.2528583136 4.001889e-01
#> 62 2.4013985282 -0.04040404 3.808170 1.2512739274 1.054173e-01
#> 63 0.4041417277 -0.04040404 3.808170 0.2278024179 4.098999e-01
#> 64 0.6168416156 -0.04040404 3.808170 0.3367980540 3.681346e-01
#> 65 1.1530539797 -0.04040404 3.808170 0.6115739754 2.704098e-01
#> 66 1.1711181457 -0.04040404 3.808170 0.6208307516 2.673555e-01
#> 67 -0.2568922588 -0.04040404 3.808170 -0.1109369229 5.441668e-01
#> 68 0.3127401812 -0.04040404 3.808170 0.1809647360 4.281976e-01
#> 69 3.7130955098 -0.04040404 3.808170 1.9234381125 2.721253e-02 *
#> 70 2.1468121184 -0.03030303 2.885612 1.2816293828 9.998634e-02 .
#> 71 3.5948586370 -0.03030303 2.885612 2.1340688906 1.641857e-02 *
#> 72 2.5129080971 -0.04040404 3.808170 1.3084157365 9.536617e-02 .
#> 73 -2.7629337000 -0.04040404 3.808170 -1.3951293292 9.185116e-01
#> 74 0.3563326192 -0.04040404 3.808170 0.2033031845 4.194490e-01
#> 75 0.5290021064 -0.04040404 3.808170 0.2917856975 3.852252e-01
#> 76 0.5334557168 -0.04040404 3.808170 0.2940678994 3.843530e-01
#> 77 -0.0447420382 -0.04040404 3.808170 -0.0022229576 5.008868e-01
#> 78 -1.2542515800 -0.04040404 3.808170 -0.6220223525 7.330364e-01
#> 79 -0.0472950458 -0.04040404 3.808170 -0.0035312172 5.014087e-01
#> 80 -0.6302656115 -0.03030303 2.885612 -0.3531874155 6.380260e-01
#> 81 0.3269261797 -0.03030303 2.885612 0.2102945507 4.167189e-01
#> 82 -0.5160072696 -0.04040404 3.808170 -0.2437174602 5.962752e-01
#> 83 -0.2479933805 -0.04040404 3.808170 -0.1063767940 5.423583e-01
#> 84 -1.0131181663 -0.04040404 3.808170 -0.4984562799 6.909188e-01
#> 85 -0.0413517546 -0.04040404 3.808170 -0.0004856454 5.001937e-01
#> 86 1.2864978644 -0.04040404 3.808170 0.6799557749 2.482662e-01
#> 87 5.3442291716 -0.04040404 3.808170 2.7592939878 2.896320e-03 **
#> 88 1.1908375230 -0.04040404 3.808170 0.6309357220 2.640413e-01
#> 89 -0.1637798904 -0.04040404 3.808170 -0.0632225498 5.252054e-01
#> 90 -1.3882380495 -0.03030303 2.885612 -0.7993924536 7.879686e-01
#> 91 -0.0454833627 -0.02020202 1.943397 -0.0181350738 5.072345e-01
#> 92 0.0513870764 -0.03030303 2.885612 0.0480895285 4.808224e-01
#> 93 0.1655430040 -0.03030303 2.885612 0.1152911146 4.541072e-01
#> 94 -1.1189233191 -0.03030303 2.885612 -0.6408516103 7.391905e-01
#> 95 -1.3880973976 -0.03030303 2.885612 -0.7993096543 7.879446e-01
#> 96 -2.2690193864 -0.03030303 2.885612 -1.3178929297 9.062303e-01
#> 97 5.1597552628 -0.03030303 2.885612 3.0552960006 1.124193e-03 **
#> 98 3.1803457100 -0.03030303 2.885612 1.8900524236 2.937547e-02 *
#> 99 0.3915644846 -0.03030303 2.885612 0.2483459835 4.019334e-01
#> 100 0.1000864726 -0.02020202 1.943397 0.0862865845 4.656193e-01
data(fakedata)
X <- cbind(fakedataset$x1, fakedataset$x2, fakedataset$x3)
(MI <- MI.vec(x = X, W = W, alternative = "greater", symmetrize = TRUE))
#> I EI VarI zI pI
#> 1 0.311178214 -0.01010101 0.005344193 4.3948248 5.543107e-06 ***
#> 2 0.168757531 -0.01010101 0.005344193 2.4466317 7.209904e-03 **
#> 3 0.009112739 -0.01010101 0.005344193 0.2628276 3.963417e-01