1\name{localmoran.exact} 2\alias{localmoran.exact} 3\alias{localmoran.exact.alt} 4\alias{print.localmoranex} 5\alias{as.data.frame.localmoranex} 6%- Also NEED an '\alias' for EACH other topic documented here. 7\title{Exact local Moran's Ii tests} 8\description{ 9 \code{localmoran.exact} provides exact local Moran's Ii tests under the null hypothesis, while \code{localmoran.exact.alt} provides exact local Moran's Ii tests under the alternative hypothesis. In this case, the model may be a fitted model derived from a model fitted by \code{spatialreg::errorsarlm}, with the covariance matrix can be passed through the \code{Omega=} argument. 10} 11\usage{ 12localmoran.exact(model, select, nb, glist = NULL, style = "W", 13 zero.policy = NULL, alternative = "greater", spChk = NULL, 14 resfun = weighted.residuals, save.Vi = FALSE, useTP=FALSE, truncErr=1e-6, 15 zeroTreat=0.1) 16localmoran.exact.alt(model, select, nb, glist = NULL, style = "W", 17 zero.policy = NULL, alternative = "greater", spChk = NULL, 18 resfun = weighted.residuals, Omega = NULL, save.Vi = FALSE, 19 save.M = FALSE, useTP=FALSE, truncErr=1e-6, zeroTreat=0.1) 20\method{print}{localmoranex}(x, \dots) 21\method{as.data.frame}{localmoranex}(x, row.names=NULL, optional=FALSE, \dots) 22} 23%- maybe also 'usage' for other objects documented here. 24\arguments{ 25 \item{model}{an object of class \code{lm} returned by \code{lm} (assuming no global spatial autocorrelation), or an object of class \code{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 \code{lm} fit, but offsets should not be used} 26 \item{select}{an integer vector of the id. numbers of zones to be tested; if missing, all zones} 27 \item{nb}{a list of neighbours of class \code{nb}} 28 \item{glist}{a list of general weights corresponding to neighbours} 29 \item{style}{can take values W, B, C, and S} 30 \item{zero.policy}{default NULL, use global option value; if TRUE assign zero to the lagged value of zones without 31neighbours, if FALSE assign NA} 32 \item{alternative}{a character string specifying the alternative hypothesis, 33must be one of greater (default), less or two.sided.} 34 \item{spChk}{should the data vector names be checked against the spatial objects for identity integrity, TRUE, or FALSE, default NULL to use \code{get.spChkOption()}} 35 \item{resfun}{default: weighted.residuals; the function to be used to extract residuals from the \code{lm} object, may be \code{residuals}, \code{weighted.residuals}, \code{rstandard}, or \code{rstudent}} 36 \item{Omega}{A SAR process matrix may be passed in to test an alternative hypothesis, for example \code{Omega <- invIrW(listw, rho=0.1); Omega <- tcrossprod(Omega)}, \code{chol()} is taken internally} 37 \item{save.Vi}{if TRUE, return the star-shaped weights lists for each zone 38tested} 39 \item{save.M}{if TRUE, save a list of left and right M products} 40 \item{useTP}{default FALSE, if TRUE, use truncation point in integration rather than upper=Inf, see Tiefelsdorf (2000), eq. 6.7, p.69} 41 \item{truncErr}{when useTP=TRUE, pass truncation error to truncation point function} 42 \item{zeroTreat}{when useTP=TRUE, pass zero adjustment to truncation point function} 43 \item{x}{object to be printed} 44 \item{row.names}{ignored argument to \code{as.data.frame.localmoranex}; 45row names assigned from localmoranex object} 46 \item{optional}{ignored argument to \code{as.data.frame.localmoranex}; 47row names assigned from localmoranex object} 48 \item{\dots}{arguments to be passed through} 49} 50 51\value{ 52A list with class \code{localmoranex} containing "select" lists, each with 53 class \code{moranex} with the following components: 54 \item{statistic}{the value of the exact standard deviate of global Moran's I.} 55 \item{p.value}{the p-value of the test.} 56 \item{estimate}{the value of the observed local Moran's Ii.} 57 \item{method}{a character string giving the method used.} 58 \item{alternative}{a character string describing the alternative hypothesis.} 59 \item{gamma}{eigenvalues (two extreme values for null, vector for alternative)} 60 \item{oType}{usually set to "E", but set to "N" if the integration leads to an out of domain value for \code{qnorm}, when the Normal assumption is substituted. This only occurs when the output p-value would be very close to zero} 61 \item{data.name}{a character string giving the name(s) of the data.} 62 \item{df}{degrees of freedom} 63 \item{i}{zone tested} 64 \item{Vi}{zone tested} 65 66When the alternative is being tested, a list of left and right M products in attribute M. 67} 68 69\references{Bivand RS, Müller W, Reder M (2009) Power calculations for global and local Moran’s I. Comput Stat Data Anal 53:2859–2872; Bivand RS, Wong DWS 2018 Comparing implementations of global and local indicators of spatial association. TEST, 27(3), 716--748 \doi{10.1007/s11749-018-0599-x}} 70 71\author{Markus Reder and Roger Bivand} 72 73\seealso{\code{\link{lm.morantest.exact}}, \code{\link{localmoran.sad}}} 74\examples{ 75eire <- st_read(system.file("shapes/eire.shp", package="spData")[1]) 76row.names(eire) <- as.character(eire$names) 77st_crs(eire) <- "+proj=utm +zone=30 +ellps=airy +units=km" 78eire.nb <- poly2nb(eire) 79e.lm <- lm(OWNCONS ~ ROADACC, data=eire) 80localmoran.sad(e.lm, nb=eire.nb) 81localmoran.exact(e.lm, nb=eire.nb) 82localmoran.exact(e.lm, nb=eire.nb, useTP=TRUE) 83run <- FALSE 84if (requireNamespace("spatialreg", quietly=TRUE)) run <- TRUE 85if (run) { 86e.errorsar <- spatialreg::errorsarlm(OWNCONS ~ ROADACC, data=eire, 87 listw=nb2listw(eire.nb)) 88lm.target <- lm(e.errorsar$tary ~ e.errorsar$tarX - 1) 89localmoran.exact.alt(lm.target, nb=eire.nb) 90} 91if (run) { 92Omega <- invIrW(nb2listw(eire.nb), rho=e.errorsar$lambda) 93Omega1 <- tcrossprod(Omega) 94localmoran.exact.alt(lm.target, nb=eire.nb, Omega=Omega1) 95} 96if (run) { 97localmoran.exact.alt(lm.target, nb=eire.nb, Omega=Omega1, useTP=TRUE) 98} 99} 100% Add one or more standard keywords, see file 'KEYWORDS' in the 101% R documentation directory. 102\keyword{spatial} 103 104