localmoran.exact: Exact local Moran's Ii tests

Description Usage Arguments Value Author(s) See Also Examples

View source: R/localmoran.exact.R

Description

localmoran.exact provides exact local Moran's Ii tests under the null hypothesis, while localmoran.exact.alt provides exact local Moran's Ii tests under the alternative hypothesis. In this case, the model may be a fitted model returned by errorsarlm from which the covariance matrix is retrieved, or the covariance matrix can be passed through the Omega= argument.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
localmoran.exact(model, select, nb, glist = NULL, style = "W", 
 zero.policy = NULL, alternative = "greater", spChk = NULL, 
 resfun = weighted.residuals, save.Vi = FALSE, useTP=FALSE, truncErr=1e-6, 
 zeroTreat=0.1)
localmoran.exact.alt(model, select, nb, glist = NULL, style = "W",
 zero.policy = NULL, alternative = "greater", spChk = NULL,
 resfun = weighted.residuals, Omega = NULL, save.Vi = FALSE,
 save.M = FALSE, useTP=FALSE, truncErr=1e-6, zeroTreat=0.1)
## S3 method for class 'localmoranex'
print(x, ...)
## S3 method for class 'localmoranex'
as.data.frame(x, row.names=NULL, optional=FALSE, ...)

Arguments

model

an object of class lm returned by lm (assuming no global spatial autocorrelation), or an object of class sarlm returned by a spatial simultaneous autoregressive model fit (assuming global spatial autocorrelation represented by the model spatial coefficient); weights may be specified in the lm fit, but offsets should not be used

select

an integer vector of the id. numbers of zones to be tested; if missing, all zones

nb

a list of neighbours of class nb

glist

a list of general weights corresponding to neighbours

style

can take values W, B, C, and S

zero.policy

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative

a character string specifying the alternative hypothesis, must be one of greater (default), less or two.sided.

spChk

should the data vector names be checked against the spatial objects for identity integrity, TRUE, or FALSE, default NULL to use get.spChkOption()

resfun

default: weighted.residuals; the function to be used to extract residuals from the lm object, may be residuals, weighted.residuals, rstandard, or rstudent

Omega

A SAR process matrix may be passed in to test an alternative hypothesis, for example Omega <- invIrW(listw, rho=0.1); Omega <- tcrossprod(Omega), chol() is taken internally

save.Vi

if TRUE, return the star-shaped weights lists for each zone tested

save.M

if TRUE, save a list of left and right M products

useTP

default FALSE, if TRUE, use truncation point in integration rather than upper=Inf, see Tiefelsdorf (2000), eq. 6.7, p.69

truncErr

when useTP=TRUE, pass truncation error to truncation point function

zeroTreat

when useTP=TRUE, pass zero adjustment to truncation point function

x

object to be printed

row.names

ignored argument to as.data.frame.localmoranex; row names assigned from localmoranex object

optional

ignored argument to as.data.frame.localmoranex; row names assigned from localmoranex object

...

arguments to be passed through

Value

A list with class localmoranex containing "select" lists, each with class moranex with the following components:

statistic

the value of the saddlepoint approximation of the standard deviate of global Moran's I.

p.value

the p-value of the test.

estimate

the value of the observed global Moran's I.

method

a character string giving the method used.

alternative

a character string describing the alternative hypothesis.

gamma

eigenvalues (two extreme values for null, vector for alternative)

oType

usually set to "E", but set to "N" if the integration leads to an out of domain value for qnorm, when the Normal assumption is substituted. This only occurs when the output p-value would be very close to zero

data.name

a character string giving the name(s) of the data.

df

degrees of freedom

i

zone tested

Vi

zone tested

When the alternative is being tested, a list of left and right M products in attribute M.

Author(s)

Markus Reder and Roger Bivand

See Also

lm.morantest.exact, localmoran.sad

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
require(maptools)
eire <- readShapePoly(system.file("etc/shapes/eire.shp", package="spdep")[1],
  ID="names", proj4string=CRS("+proj=utm +zone=30 +ellps=airy +units=km"))
eire.nb <- poly2nb(eire)
#data(eire)
e.lm <- lm(OWNCONS ~ ROADACC, data=eire)
localmoran.sad(e.lm, nb=eire.nb)
localmoran.exact(e.lm, nb=eire.nb)
localmoran.exact(e.lm, nb=eire.nb, useTP=TRUE)
e.errorsar <- errorsarlm(OWNCONS ~ ROADACC, data=eire,
 listw=nb2listw(eire.nb))
lm.target <- lm(e.errorsar$tary ~ e.errorsar$tarX - 1)
localmoran.exact.alt(lm.target, nb=eire.nb)
Omega <- invIrW(nb2listw(eire.nb), rho=0.6)
Omega1 <- tcrossprod(Omega)
localmoran.exact.alt(lm.target, nb=eire.nb, Omega=Omega1)
localmoran.exact.alt(lm.target, nb=eire.nb, Omega=Omega1, useTP=TRUE)

Example output

Loading required package: sp
Loading required package: Matrix
Loading required package: maptools
Checking rgeos availability: TRUE
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
Warning message:
use rgdal::readOGR or sf::st_read 
             Local Morans I Saddlepoint    Pr. (Sad)
1 Carlow         0.21699668  0.95074844 1.708660e-01
2 Cavan         -0.37257361 -1.00603119 8.427997e-01
3 Clare          0.23197510  0.67166518 2.508984e-01
4 Cork           0.78193548  1.74761575 4.026529e-02
5 Donegal       -1.69064059 -1.72031078 9.573120e-01
6 Dublin        -0.16069692 -0.35212627 6.376282e-01
7 Galway         1.31371473  2.66849536 3.809592e-03
8 Kerry          0.36534866  0.78073279 2.174798e-01
9 Kildare       -0.02557544  0.04167665 4.833782e-01
10 Kilkenny      0.57684331  1.70897697 4.372761e-02
11 Laoghis      -0.05951798 -0.12155465 5.483741e-01
12 Leitrim       0.38484587  1.47227033 7.047395e-02
13 Limerick      0.11817987  0.45727712 3.237359e-01
14 Longford      1.41643200  2.51113769 6.017137e-03
15 Louth         0.56242920  1.07441571 1.413182e-01
16 Mayo          0.87572704  2.05251226 2.005995e-02
17 Meath         0.00367856  0.12813539 4.490209e-01
18 Monaghan      0.55098311  1.23999193 1.074892e-01
19 Offaly        0.15155556  0.80786519 2.095841e-01
20 Roscommon     2.04368839  4.53187292 2.923151e-06
21 Sligo        -0.47579871 -0.94578114 8.278699e-01
22 Tipperary    -0.03454106 -0.06919691 5.275836e-01
23 Waterford     0.85723423  1.91385108 2.781959e-02
24 Westmeath     0.45138572  1.36017204 8.688774e-02
25 Wexford       0.64371834  1.63188492 5.135187e-02
26 Wicklow       0.02441950  0.21197000 4.160652e-01
             Local Morans I    Exact SD  Pr. (exact)
1 Carlow         0.21699668  1.02706083 1.521959e-01
2 Cavan         -0.37257361 -1.04864802 8.528299e-01
3 Clare          0.23197510  0.76362894 2.225442e-01
4 Cork           0.78193548  1.77727656 3.776137e-02
5 Donegal       -1.69064059 -1.74428756 9.594455e-01
6 Dublin        -0.16069692 -0.44236119 6.708861e-01
7 Galway         1.31371473  2.69199974 3.551250e-03
8 Kerry          0.36534866  0.85742696 1.956045e-01
9 Kildare       -0.02557544 -0.03475476 5.138624e-01
10 Kilkenny      0.57684331  1.74146177 4.080133e-02
11 Laoghis      -0.05951798 -0.21824035 5.863791e-01
12 Leitrim       0.38484587  1.51434641 6.496900e-02
13 Limerick      0.11817987  0.56922630 2.846013e-01
14 Longford      1.41643200  2.53491837 5.623677e-03
15 Louth         0.56242920  1.12775107 1.297125e-01
16 Mayo          0.87572704  2.08125803 1.870515e-02
17 Meath         0.00367856  0.16372685 4.349731e-01
18 Monaghan      0.55098311  1.28435459 9.950896e-02
19 Offaly        0.15155556  0.89537870 1.852923e-01
20 Roscommon     2.04368839  4.55244870 2.651255e-06
21 Sligo        -0.47579871 -0.98101752 8.367079e-01
22 Tipperary    -0.03454106 -0.16132608 5.640817e-01
23 Waterford     0.85723423  1.94188723 2.607538e-02
24 Westmeath     0.45138572  1.40091422 8.061986e-02
25 Wexford       0.64371834  1.66488051 4.796830e-02
26 Wicklow       0.02441950  0.29717701 3.831657e-01
             Local Morans I    Exact SD  Pr. (exact)
1 Carlow         0.21699668  1.02706127 1.521958e-01
2 Cavan         -0.37257361 -1.04864834 8.528300e-01
3 Clare          0.23197510  0.76362936 2.225441e-01
4 Cork           0.78193548  1.77727666 3.776137e-02
5 Donegal       -1.69064059 -1.74428741 9.594455e-01
6 Dublin        -0.16069692 -0.44236158 6.708862e-01
7 Galway         1.31371473  2.69199162 3.551337e-03
8 Kerry          0.36534866  0.85742736 1.956044e-01
9 Kildare       -0.02557544 -0.03540278 5.141207e-01
10 Kilkenny      0.57684331  1.74146192 4.080132e-02
11 Laoghis      -0.05951798 -0.21823772 5.863780e-01
12 Leitrim       0.38484587  1.51434680 6.496895e-02
13 Limerick      0.11817987  0.56922674 2.846011e-01
14 Longford      1.41643200  2.53491383 5.623749e-03
15 Louth         0.56242920  1.12775145 1.297125e-01
16 Mayo          0.87572704  2.08125778 1.870516e-02
17 Meath         0.00367856  0.15714487 4.375653e-01
18 Monaghan      0.55098311  1.28435495 9.950889e-02
19 Offaly        0.15155556  0.89537914 1.852922e-01
20 Roscommon     2.04368839  4.53362873 2.898945e-06
21 Sligo        -0.47579871 -0.98101780 8.367080e-01
22 Tipperary    -0.03454106 -0.16116590 5.640186e-01
23 Waterford     0.85723423  1.94188711 2.607538e-02
24 Westmeath     0.45138572  1.40091457 8.061981e-02
25 Wexford       0.64371834  1.66488069 4.796828e-02
26 Wicklow       0.02441950  0.29790569 3.828876e-01
             Local Morans I    Exact SD Pr. (exact)
1 Carlow         0.17958463  0.83313551 0.202384155
2 Cavan         -0.24752629 -0.82861511 0.796338881
3 Clare         -0.27901332 -0.72313216 0.765200653
4 Cork           0.37808657  1.15083941 0.124899154
5 Donegal       -1.01894690 -1.50937609 0.934398650
6 Dublin        -0.18171297 -0.50995180 0.694957387
7 Galway         1.02193392  2.27605552 0.011421344
8 Kerry         -0.94967910 -1.46954729 0.929157797
9 Kildare        0.07005053  0.56174770 0.287143965
10 Kilkenny      0.43022233  1.39078836 0.082144807
11 Laoghis      -0.12239132 -0.45750045 0.676344310
12 Leitrim      -0.24203967 -0.84925551 0.802130435
13 Limerick     -0.03214545 -0.13098229 0.552105340
14 Longford      0.38307457  1.17909766 0.119179646
15 Louth         0.21301553  0.62068304 0.267404096
16 Mayo          0.93971204  1.94079907 0.026141327
17 Meath         0.12484415  0.78747316 0.215502468
18 Monaghan     -0.16109917 -0.48277556 0.685372448
19 Offaly       -0.00632492  0.03008421 0.487999947
20 Roscommon     1.02089434  2.64333479 0.004104691
21 Sligo        -2.01629228 -2.54211785 0.994490849
22 Tipperary    -0.10810708 -0.51063239 0.695195754
23 Waterford     0.44099281  1.28152284 0.100005042
24 Westmeath    -0.06329660 -0.26575201 0.604784897
25 Wexford       0.30764885  1.02115603 0.153590261
26 Wicklow      -0.01696405 -0.04109882 0.516391441
             Local Morans I    Exact SD Pr. (exact)
1 Carlow         0.17958463  0.23106313  0.40863288
2 Cavan         -0.24752629 -1.23468948  0.89152695
3 Clare         -0.27901332 -1.23568136  0.89171149
4 Cork           0.37808657  0.37129166  0.35521016
5 Donegal       -1.01894690 -1.84902974  0.96777324
6 Dublin        -0.18171297 -0.98014854  0.83649360
7 Galway         1.02193392  1.60349638  0.05441255
8 Kerry         -0.94967910 -2.12070802  0.98302681
9 Kildare        0.07005053  0.10764695  0.45713788
10 Kilkenny      0.43022233  0.72290578  0.23486889
11 Laoghis      -0.12239132 -0.87106285  0.80814008
12 Leitrim      -0.24203967 -1.37942745  0.91611850
13 Limerick     -0.03214545 -0.68255484  0.75255591
14 Longford      0.38307457  0.47071575  0.31892187
15 Louth         0.21301553  0.02198179  0.49123124
16 Mayo          0.93971204  1.30000029  0.09680044
17 Meath         0.12484415  0.15994490  0.43646224
18 Monaghan     -0.16109917 -1.05555828  0.85441496
19 Offaly       -0.00632492 -0.29850266  0.61734023
20 Roscommon     1.02089434  1.58863485  0.05607143
21 Sligo        -2.01629228 -3.26456067  0.99945183
22 Tipperary    -0.10810708 -0.98217196  0.83699243
23 Waterford     0.44099281  0.66779681  0.25213165
24 Westmeath    -0.06329660 -0.70911715  0.76087411
25 Wexford       0.30764885  0.37770002  0.35282673
26 Wicklow      -0.01696405 -0.54705599  0.70782987
             Local Morans I    Exact SD Pr. (exact)
1 Carlow         0.17958463  0.23106347  0.40863275
2 Cavan         -0.24752629 -1.23468997  0.89152705
3 Clare         -0.27901332 -1.23568179  0.89171157
4 Cork           0.37808657  0.37129181  0.35521010
5 Donegal       -1.01894690 -1.84902980  0.96777325
6 Dublin        -0.18171297 -0.98014902  0.83649372
7 Galway         1.02193392  1.60349634  0.05441256
8 Kerry         -0.94967910 -2.12070816  0.98302682
9 Kildare        0.07005053  0.10764406  0.45713902
10 Kilkenny      0.43022233  0.72290593  0.23486884
11 Laoghis      -0.12239132 -0.87106427  0.80814047
12 Leitrim      -0.24203967 -1.37942806  0.91611859
13 Limerick     -0.03214545 -0.68260207  0.75257084
14 Longford      0.38307457  0.47071591  0.31892181
15 Louth         0.21301553  0.02198204  0.49123114
16 Mayo          0.93971204  1.30000031  0.09680043
17 Meath         0.12484415  0.15994587  0.43646186
18 Monaghan     -0.16109917 -1.05555890  0.85441511
19 Offaly       -0.00632492 -0.29479749  0.61592571
20 Roscommon     1.02089434  1.58863478  0.05607144
21 Sligo        -2.01629228 -3.26455051  0.99945181
22 Tipperary    -0.10810708 -0.98217468  0.83699310
23 Waterford     0.44099281  0.66779693  0.25213161
24 Westmeath    -0.06329660 -0.70910518  0.76087040
25 Wexford       0.30764885  0.37770022  0.35282665
26 Wicklow      -0.01696405 -0.54778210  0.70807924

spdep documentation built on Aug. 19, 2017, 3:01 a.m.