SpatialFiltering: Semi-parametric spatial filtering

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/SpatialFiltering.R

Description

The function selects eigenvectors in a semi-parametric spatial filtering approach to removing spatial dependence from linear models. Selection is by brute force by finding the single eigenvector reducing the standard variate of Moran's I for regression residuals most, and continuing until no candidate eigenvector reduces the value by more than tol. It returns a summary table from the selection process and a matrix of selected eigenvectors for the specified model.

Usage

1
2
3
SpatialFiltering(formula, lagformula, data = list(), nb, glist = NULL, style = "C",
 zero.policy = NULL, tol = 0.1, zerovalue = 1e-04, ExactEV = FALSE,
 symmetric = TRUE, alpha=NULL, alternative="two.sided", verbose=NULL)

Arguments

formula

a symbolic description of the model to be fit, assuming a spatial error representation; when lagformula is given, it should include only the response and the intercept term

lagformula

An extra one-sided formula to be used when a spatial lag representation is desired; the intercept is excluded within the function if present because it is part of the formula argument, but excluding it explicitly in the lagformula argument in the presence of factors generates a collinear model matrix

data

an optional data frame containing the variables in the model

nb

an object of class nb

glist

list of general weights corresponding to neighbours

style

style can take values W, B, C, U, and S

zero.policy

default NULL, use global option value; if FALSE stop with error for any empty neighbour sets, if TRUE permit the weights list to be formed with zero-length weights vectors

tol

tolerance value for convergence of spatial filtering

zerovalue

eigenvectors with eigenvalues of an absolute value smaller than zerovalue will be excluded in eigenvector search

ExactEV

Set ExactEV=TRUE to use exact expectations and variances rather than the expectation and variance of Moran's I from the previous iteration, default FALSE

symmetric

Should the spatial weights matrix be forced to symmetry, default TRUE

alpha

if not NULL, used instead of the tol= argument as a stopping rule to choose all eigenvectors up to and including the one with a probability value exceeding alpha.

alternative

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

verbose

default NULL, use global option value; if TRUE report eigenvectors selected

Value

An SFResult object, with:

selection

a matrix summarising the selection of eigenvectors for inclusion, with columns:

Step

Step counter of the selection procedure

SelEvec

number of selected eigenvector (sorted descending)

Eval

its associated eigenvalue

MinMi

value Moran's I for residual autocorrelation

ZMinMi

standardized value of Moran's I assuming a normal approximation

pr(ZI)

probability value of the permutation-based standardized deviate for the given value of the alternative argument

R2

R\^2 of the model including exogenous variables and eigenvectors

gamma

regression coefficient of selected eigenvector in fit

The first row is the value at the start of the search

dataset

a matrix of the selected eigenvectors in order of selection

Author(s)

Yongwan Chun, Michael Tiefelsdorf, Roger Bivand

References

Tiefelsdorf M, Griffith DA. (2007) Semiparametric Filtering of Spatial Autocorrelation: The Eigenvector Approach. Environment and Planning A, 39 (5) 1193 - 1221. http://www.spatialfiltering.com

See Also

lm, eigen, nb2listw, listw2U

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
example(columbus)
lmbase <- lm(CRIME ~ INC + HOVAL, data=columbus)
sarcol <- SpatialFiltering(CRIME ~ INC + HOVAL, data=columbus,
 nb=col.gal.nb, style="W", ExactEV=TRUE)
sarcol
lmsar <- lm(CRIME ~ INC + HOVAL + fitted(sarcol), data=columbus)
lmsar
anova(lmbase, lmsar)
lm.morantest(lmsar, nb2listw(col.gal.nb))
lagcol <- SpatialFiltering(CRIME ~ 1, ~ INC + HOVAL - 1, data=columbus,
 nb=col.gal.nb, style="W")
lagcol
lmlag <- lm(CRIME ~ INC + HOVAL + fitted(lagcol), data=columbus)
lmlag
anova(lmbase, lmlag)
lm.morantest(lmlag, nb2listw(col.gal.nb))

Example output

Loading required package: sp
Loading required package: spData
To access larger datasets in this package, install the spDataLarge
package with: `install.packages('spDataLarge',
repos='https://nowosad.github.io/drat/', type='source')`
Loading required package: sf
Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1

colmbs> columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)

colmbs> col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
Registered S3 methods overwritten by 'spatialreg':
  method                   from 
  residuals.stsls          spdep
  deviance.stsls           spdep
  coef.stsls               spdep
  print.stsls              spdep
  summary.stsls            spdep
  print.summary.stsls      spdep
  residuals.gmsar          spdep
  deviance.gmsar           spdep
  coef.gmsar               spdep
  fitted.gmsar             spdep
  print.gmsar              spdep
  summary.gmsar            spdep
  print.summary.gmsar      spdep
  print.lagmess            spdep
  summary.lagmess          spdep
  print.summary.lagmess    spdep
  residuals.lagmess        spdep
  deviance.lagmess         spdep
  coef.lagmess             spdep
  fitted.lagmess           spdep
  logLik.lagmess           spdep
  fitted.SFResult          spdep
  print.SFResult           spdep
  fitted.ME_res            spdep
  print.ME_res             spdep
  print.lagImpact          spdep
  plot.lagImpact           spdep
  summary.lagImpact        spdep
  HPDinterval.lagImpact    spdep
  print.summary.lagImpact  spdep
  print.sarlm              spdep
  summary.sarlm            spdep
  residuals.sarlm          spdep
  deviance.sarlm           spdep
  coef.sarlm               spdep
  vcov.sarlm               spdep
  fitted.sarlm             spdep
  logLik.sarlm             spdep
  anova.sarlm              spdep
  predict.sarlm            spdep
  print.summary.sarlm      spdep
  print.sarlm.pred         spdep
  as.data.frame.sarlm.pred spdep
  residuals.spautolm       spdep
  deviance.spautolm        spdep
  coef.spautolm            spdep
  fitted.spautolm          spdep
  print.spautolm           spdep
  summary.spautolm         spdep
  logLik.spautolm          spdep
  print.summary.spautolm   spdep
  print.WXImpact           spdep
  summary.WXImpact         spdep
  print.summary.WXImpact   spdep
  predict.SLX              spdep
Warning message:
Function SpatialFiltering moved to the spatialreg package 
  Step SelEvec      Eval        MinMi      ZMinMi      Pr(ZI)        R2
0    0       0 0.0000000  0.212374153  2.68100025 0.007340246 0.5524040
1    1       5 0.7148326  0.121528166  1.89037770 0.058707464 0.6209393
2    2       3 0.8408661  0.065848648  1.54064108 0.123404165 0.6481722
3    3       1 1.0206316 -0.005424824  1.08514557 0.277857187 0.6726114
4    4      10 0.3658588 -0.039356232  0.80357070 0.421644951 0.7000258
5    5      14 0.1831325 -0.072949543  0.47790213 0.632719864 0.7393770
6    6      11 0.3144120 -0.108332631  0.18566599 0.852706701 0.7611907
7    7       2 0.9157325 -0.153675621 -0.03464097 0.972366030 0.7713163
      gamma
0   0.00000
1  30.34786
2  19.13010
3 -18.12234
4  19.19379
5  22.99586
6  17.12127
7  11.66487

Call:
lm(formula = CRIME ~ INC + HOVAL + fitted(sarcol), data = columbus)

Coefficients:
        (Intercept)                  INC                HOVAL  
            68.6190              -1.5973              -0.2739  
 fitted(sarcol)vec5   fitted(sarcol)vec3   fitted(sarcol)vec1  
            30.3479              19.1301             -18.1223  
fitted(sarcol)vec10  fitted(sarcol)vec14  fitted(sarcol)vec11  
            19.1938              22.9959              17.1213  
 fitted(sarcol)vec2  
            11.6649  

Analysis of Variance Table

Model 1: CRIME ~ INC + HOVAL
Model 2: CRIME ~ INC + HOVAL + fitted(sarcol)
  Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
1     46 6014.9                                  
2     39 3073.1  7    2941.8 5.3334 0.0002445 ***
---
Signif. codes:  0***0.001**0.01*0.05.’ 0.1 ‘ ’ 1

	Global Moran I for regression residuals

data:  
model: lm(formula = CRIME ~ INC + HOVAL + fitted(sarcol), data =
columbus)
weights: nb2listw(col.gal.nb)

Moran I statistic standard deviate = -0.034641, p-value = 0.5138
alternative hypothesis: greater
sample estimates:
Observed Moran I      Expectation         Variance 
    -0.153675621     -0.150918131      0.006336477 

Warning message:
Function SpatialFiltering moved to the spatialreg package 
   Step SelEvec      Eval       MinMi      ZMinMi      Pr(ZI)        R2
0     0       0 0.0000000  0.21237415  2.68100025 0.007340246 0.5524040
1     1       6 0.7161123  0.11782248  1.84511963 0.065020139 0.6038801
2     2       4 0.8682938  0.06242664  1.49482111 0.134961136 0.6531288
3     3       1 1.0310063 -0.02066604  0.88134183 0.378132834 0.6924845
4     4       5 0.7905397 -0.04619973  0.84746904 0.396733736 0.7136578
5     5      15 0.1753342 -0.07609524  0.55233191 0.580720971 0.7558543
6     6       9 0.5501433 -0.10190889  0.43919419 0.660520837 0.7626784
7     7       8 0.5721041 -0.12232942  0.41846803 0.675604953 0.7757314
8     8       3 0.9026222 -0.14991822  0.38315383 0.701605709 0.7908693
9     9       2 0.9649166 -0.21756342 -0.28556733 0.775209527 0.8078727
10   10       7 0.6219404 -0.22017920 -0.04856547 0.961265592 0.8082842
        gamma
0    0.000000
1   19.848854
2   35.542595
3  -30.697851
4  -24.540372
5   25.227798
6    7.590082
7  -16.933168
8  -20.556931
9  -18.434534
10  -2.597572

Call:
lm(formula = CRIME ~ INC + HOVAL + fitted(lagcol), data = columbus)

Coefficients:
        (Intercept)                  INC                HOVAL  
            56.7977              -0.4857              -0.3821  
 fitted(lagcol)vec6   fitted(lagcol)vec4   fitted(lagcol)vec1  
            19.8489              35.5426             -30.6979  
 fitted(lagcol)vec5  fitted(lagcol)vec15   fitted(lagcol)vec9  
           -24.5404              25.2278               7.5901  
 fitted(lagcol)vec8   fitted(lagcol)vec3   fitted(lagcol)vec2  
           -16.9332             -20.5569             -18.4345  
 fitted(lagcol)vec7  
            -2.5976  

Analysis of Variance Table

Model 1: CRIME ~ INC + HOVAL
Model 2: CRIME ~ INC + HOVAL + fitted(lagcol)
  Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
1     46 6014.9                                  
2     36 2576.3 10    3438.6 4.8049 0.0002165 ***
---
Signif. codes:  0***0.001**0.01*0.05.’ 0.1 ‘ ’ 1

	Global Moran I for regression residuals

data:  
model: lm(formula = CRIME ~ INC + HOVAL + fitted(lagcol), data =
columbus)
weights: nb2listw(col.gal.nb)

Moran I statistic standard deviate = -0.048565, p-value = 0.5194
alternative hypothesis: greater
sample estimates:
Observed Moran I      Expectation         Variance 
    -0.220179195     -0.217083975      0.004061888 

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