# MLSpawResidMoran: Testing the (residual) spatial dependency In spacom: Spatially Weighted Context Data for Multilevel Modelling

## Description

This step-4 function uses the contextual residuals of (spatially weighted) multilevel models to estimate the spatial dependency left unexplained by the model. The spatial dependency is operationalised by Moran's I coefficient for spatial auto-correlation, which can be recalculated for a range of different bandwidth values (which, in a similar way to spatial weights used for the creation of the context data, allow to parametrise the scale at which spatial dependency is being estimated). The part of explained spatial dependency can be obtained by comparison with the spatial dependency of the intercept-only, or with any other reference model, at the same bandwidth value.

## Usage

 ```1 2 3 4 5 6``` ```MLSpawResidMoran(ml.spaw.obj, distance.matrix, bandwidths, kernel = NULL, confidence.intervals = c(0.95), verbose = TRUE) ```

## Arguments

 `ml.spaw.obj` `ResampleMLSpawOutput`, `MLSpawExactOutput`, or matrix of residuals `distance.matrix` square matrix of dimension n by n, where n is the number of contextual units. `bandwidths` `vector` of bandwidths for which to compute Moran's I. `kernel` function applied to the distance matrix. By default `NULL`, in which case the kernel function w_ij = f(d, h) = (1/2)^((d_ij/h)^2) is used, where w_ij, d_ij, h are elements of the weight matrix W, of the distance matrix W and the bandwidth h. User-supplied kernel functions have to take 2 arguments and return a matrix of the same dimension as the first argument. `confidence.intervals` `vector` of conficence intervals. Defaults to `c(.95)` which corresponds to 95 %. `verbose` if `TRUE`, progress information and an estimate of the remaining computing time is shown at the screen. Defaults to `TRUE`

## Value

A `matrix` containing Moran's I's

## Author(s)

Till Junge, Sandra Penic, Guy Elcheroth

## References

Elcheroth, G., Penic, S., Fasel, R., Giudici, F., Glaeser, S., Joye, D., Le Goff, J.-M., Morselli, D., & Spini, D. (2012). Spatially weighted context data: a new approach for modelling the impact of collective experiences. LIVES Working Papers, 19.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67``` ```# Residual spatial autocorrelation ## It is step-4 function ## for residuals from ResampleAggregateSpawML ## Data preparation ## load individual level data, remove collective guilt assignment for the ## data frame, and remove NA's data(traces_ind) traces_ind <- traces_ind[,-7] traces_ind <- na.exclude(traces_ind) ## load contextual indicator for aggregation data(traces_event) ## load precise contextual indicator data(homog_census) ## load distance matrix data(d_geo) ## Step 1: Create spatial weights geow.100 <- WeightMatrix(d_geo, bandwidth=100) ## Step 2: Compute spatially weighted aggregated contextual indicator wv.agg.100 <- SpawAggregate( contextual.data = traces_event, context.id="area.name", contextual.names = "w_all", contextual.weight.matrices=geow.100, nb.resamples=5, aggregation.functions="weighted.mean", design.weight.names="weight", sample.seed=1) ## rename weighted variable name so it reflects the used weighting ## matrix names(wv.agg.100) <- "w_all.100" ## Step 3: Perform ResampleMLSpawAggregate acc_w_100 <- ResampleMLSpawAggregate( individual.level.data=traces_ind, context.id="area.name", formula=cg_acc ~ victim_d + comb_d + male + age_1990 + high_school + higher_edu + (1|area.name) + w_all.100, aggregates=wv.agg.100, precise.data=NULL) ## Step 4: Perform MLSpawResidMoran for bandwidths 25, 50, 100, 200 ## Not run: MI_acc <- MLSpawResidMoran(ml.spaw.obj=acc_w_100, distance.matrix=d_geo, bandwidths=c(25,50,100,200)) ## End(Not run) ## The results can be used for plotting spatial variogram ## See plot() and par() for details ## Not run: plot(MI_acc[,1], xaxt="n", xlab="Bandwidth values", ylab="Moran's I", type="b") axis(side=1, at=1:nrow(MI_acc), labels=rownames(MI_acc)) ## End(Not run) ```

spacom documentation built on May 1, 2019, 7:35 p.m.