1\name{lm.morantest.sad}
2\alias{lm.morantest.sad}
3\alias{print.moransad}
4\alias{summary.moransad}
5\alias{print.summary.moransad}
6%- Also NEED an `\alias' for EACH other topic documented here.
7\title{Saddlepoint approximation of global Moran's I test}
8\description{
9  The function implements Tiefelsdorf's application of the Saddlepoint
10approximation to global Moran's I's reference distribution.
11}
12\usage{
13lm.morantest.sad(model, listw, zero.policy=NULL, alternative="greater",
14  spChk=NULL, resfun=weighted.residuals, tol=.Machine$double.eps^0.5,
15  maxiter=1000, tol.bounds=0.0001, zero.tol = 1e-07, Omega=NULL,
16  save.M=NULL, save.U=NULL)
17\method{print}{moransad}(x, ...)
18\method{summary}{moransad}(object, ...)
19\method{print}{summary.moransad}(x, ...)
20}
21%- maybe also `usage' for other objects documented here.
22\arguments{
23  \item{model}{an object of class \code{lm} returned by \code{lm}; weights
24may be specified in the \code{lm} fit, but offsets should not be used}
25  \item{listw}{a \code{listw} object created for example by \code{nb2listw}}
26  \item{zero.policy}{default NULL, use global option value; if TRUE assign zero to the lagged value of zones without
27neighbours, if FALSE assign NA}
28  \item{alternative}{a character string specifying the alternative hypothesis,
29must be one of greater (default), less or two.sided.}
30  \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()}}
31  \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}}
32  \item{tol}{the desired accuracy (convergence tolerance) for \code{uniroot}}
33  \item{maxiter}{the maximum number of iterations for \code{uniroot}}
34  \item{tol.bounds}{offset from bounds for \code{uniroot}}
35  \item{zero.tol}{tolerance used to find eigenvalues close to absolute zero}
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.M}{return the full M matrix for use in \code{spdep:::exactMoranAlt}}
38  \item{save.U}{return the full U matrix for use in \code{spdep:::exactMoranAlt}}
39  \item{x}{object to be printed}
40  \item{object}{object to be summarised}
41  \item{...}{arguments to be passed through}
42}
43\details{
44  The function involves finding the eigenvalues of an n by n matrix, and
45numerically finding the root for the Saddlepoint approximation, and should
46therefore only be used with care when n is large.
47}
48\value{
49  A list of class \code{moransad} with the following components:
50  \item{statistic}{the value of the saddlepoint approximation of the
51 standard deviate of global Moran's I.}
52  \item{p.value}{the p-value of the test.}
53  \item{estimate}{the value of the observed global Moran's I.}
54  \item{alternative}{a character string describing the alternative hypothesis.}
55  \item{method}{a character string giving the method used.}
56  \item{data.name}{a character string giving the name(s) of the data.}
57  \item{internal1}{Saddlepoint omega, r and u}
58  \item{internal2}{f.root, iter and estim.prec from \code{uniroot}}
59  \item{df}{degrees of freedom}
60  \item{tau}{eigenvalues (excluding zero values)}
61}
62
63\references{Tiefelsdorf, M. 2002 The Saddlepoint approximation of Moran's I
64and local Moran's Ii reference distributions and their numerical evaluation.
65Geographical Analysis, 34, pp. 187--206; 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}}
66\author{Roger Bivand \email{Roger.Bivand@nhh.no}}
67
68\seealso{\code{\link{lm.morantest}}}
69
70\examples{
71eire <- st_read(system.file("shapes/eire.shp", package="spData")[1])
72row.names(eire) <- as.character(eire$names)
73st_crs(eire) <- "+proj=utm +zone=30 +ellps=airy +units=km"
74eire.nb <- poly2nb(eire)
75e.lm <- lm(OWNCONS ~ ROADACC, data=eire)
76lm.morantest(e.lm, nb2listw(eire.nb))
77lm.morantest.sad(e.lm, nb2listw(eire.nb))
78summary(lm.morantest.sad(e.lm, nb2listw(eire.nb)))
79e.wlm <- lm(OWNCONS ~ ROADACC, data=eire, weights=RETSALE)
80lm.morantest(e.wlm, nb2listw(eire.nb), resfun=rstudent)
81lm.morantest.sad(e.wlm, nb2listw(eire.nb), resfun=rstudent)
82}
83\keyword{spatial}
84