Computes Moran's I of y for weights W, the null expectation
\(-1/(n-1)\), and, with a design matrix X, the ratio-of-expectations
value for OLS residuals \((n/S_0)\,\mathrm{tr}(WM)/(n-p)\)
(Research.P7.MoranTrend.residual_moran_ratio). A pure trend with no
noise already moves I away from the null (trend_witness).
Usage
morie_moran_trend(W, y, X = NULL)
Arguments
- W
Weight matrix.
- y
Values.
- X
Optional design matrix (with intercept) for the residual form.
Value
A list: I, null_expectation and, with X,
I_residual and residual_expectation.
References
Schabenberger O, Gotway CA (2005). Statistical Methods for Spatial Data
Analysis, section 1.3.2.2. CRC.
Examples
W <- matrix(0, 4, 4); W[cbind(1:3, 2:4)] <- 1; W <- W + t(W)
morie_moran_trend(W, y = 1:4)
#> $I
#> [1] 0.3333333
#>
#> $null_expectation
#> [1] -0.3333333
#>
#> attr(,"theorem")
#> [1] "Research.P7.MoranTrend.residual_moran_ratio"