Skip to contents

miexp is the null expectation E(I) = -1/(n - 1); mivar the null variance from the weights constants S0, S1, S2 under normality, or under randomisation when the sample kurtosis b2 is given; mizval the standardised z = (I - E(I)) / sqrt(Var(I)) with its normal p-value; minorm combines the three. miorig and mirand compute Moran's I of y with the normality and randomisation moments (spdep::moran.test), mimc the permutation test (spdep::moran.mc, Philox-driven shuffles identical to the Python arm), miols the exact OLS-residual test (spdep::lm.morantest), miml Moran's I of residuals of a maximum-likelihood spatial model with randomisation moments, and miiv the Anselin-Kelejian (1997) test for 2SLS residuals.

Usage

miexp(n)

mivar(n, S0, S1, S2, b2 = NULL)

mizval(I, E_I, Var_I, alternative = "greater")

minorm(I, n, S0, S1, S2, b2 = NULL, alternative = "greater")

miorig(y, W, alternative = "greater")

mirand(y, W, alternative = "greater")

mimc(y, W, nsim = 99, seed = 0)

miols(resid, W, X = NULL)

miml(resid, W, alternative = "greater")

miiv(resid, W, Z, H)

Arguments

n

Number of observations.

S0

Sum of the weights.

S1

Half the sum of squared symmetrised weights.

S2

Sum of squared row plus column sums.

b2

Sample kurtosis; NULL selects the normality variance.

I

Moran's I.

E_I

Expectation of I.

Var_I

Variance of I.

alternative

One of "greater", "less" or "two.sided".

y

Numeric vector of observations.

W

Spatial weights matrix.

nsim

Number of permutations.

seed

Philox seed.

resid

Residual vector.

X

Design matrix of the OLS fit (default intercept only).

Z

Regressor matrix of the 2SLS fit.

H

Instrument matrix of the 2SLS fit.

Value

A list with statistic, p_value, expected, variance and method-specific components (for miiv, statistic is the AK chi-square and moran_i the residual Moran's I).

References

Moran, P. A. P. (1950). Notes on continuous stochastic phenomena. Biometrika 37, 17-23. Cliff, A. D. and Ord, J. K. (1981). Spatial Processes: Models and Applications. Pion. Anselin, L. and Kelejian, H. H. (1997). Testing for spatial error autocorrelation in the presence of endogenous regressors. International Regional Science Review 20, 153-182.

Examples

W <- rbind(c(0, 1, 0, 0), c(1, 0, 1, 0), c(0, 1, 0, 1), c(0, 0, 1, 0))
minorm(0.2, 4, 6, 12, 40)$statistic
#> [1] 1.385641
mirand(c(1, 2, 3, 4), W)$statistic
#> [1] 0.3333333