11  Exercises III

\[ \newcommand{\tr}{\mathrm{tr}} \newcommand{\rank}{\mathrm{rank}} \newcommand{\plim}{\operatornamewithlimits{plim}} \newcommand{\diag}{\mathrm{diag}} \newcommand{\bm}[1]{\boldsymbol{\mathbf{#1}}} \newcommand{\Var}{\mathrm{Var}} \newcommand{\Exp}{\mathrm{E}} \newcommand{\Cov}{\mathrm{Cov}} \newcommand\given[1][]{\:#1\vert\:} \newcommand{\irow}[1]{% \begin{pmatrix}#1\end{pmatrix} } \]

Required packages

pkgs <- c("sf", "mapview", "spdep", "spatialreg", "ggplot2", "tmap", "viridis", "viridisLite", 
          "plm", "lfe", "splm", "SDPDmod")
lapply(pkgs, require, character.only = TRUE)

Session info

R version 4.6.0 (2026-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26200)

Matrix products: default
  LAPACK version 3.12.1

locale:
[1] LC_COLLATE=German_Germany.utf8  LC_CTYPE=German_Germany.utf8   
[3] LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.utf8    

time zone: Europe/Berlin
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
 [1] SDPDmod_0.0.7     splm_1.6-5        lfe_3.1.1        
 [4] plm_2.6-7         viridis_0.6.5     viridisLite_0.4.3
 [7] tmap_4.4          ggplot2_4.0.3     spatialreg_1.4-3 
[10] Matrix_1.7-5      spdep_1.4-2       spData_2.3.5     
[13] mapview_2.11.4    sf_1.1-1         

loaded via a namespace (and not attached):
  [1] Rdpack_2.6.6           DBI_1.3.0             
  [3] deldir_2.0-4           gridExtra_2.3         
  [5] tmaptools_3.3          s2_1.1.11             
  [7] logger_0.4.2           sandwich_3.1-1        
  [9] rlang_1.2.0            magrittr_2.0.5        
 [11] dreamerr_1.5.0         multcomp_1.4-30       
 [13] otel_0.2.0             e1071_1.7-17          
 [15] compiler_4.6.0         png_0.1-9             
 [17] vctrs_0.7.3            stringr_1.6.0         
 [19] pkgconfig_2.0.3        wk_0.9.5              
 [21] fastmap_1.2.0          backports_1.5.1       
 [23] lwgeom_0.2-16          leafem_0.2.5          
 [25] rmarkdown_2.31         spacesXYZ_1.6-0       
 [27] miscTools_0.6-30       xfun_0.57             
 [29] satellite_1.0.6        jsonlite_2.0.0        
 [31] stringmagic_1.2.0      collapse_2.1.7        
 [33] terra_1.9-27           parallel_4.6.0        
 [35] LearnBayes_2.15.2      R6_2.6.1              
 [37] stringi_1.8.7          RColorBrewer_1.1-3    
 [39] boot_1.3-32            numDeriv_2016.8-1.1   
 [41] lmtest_0.9-40          stars_0.7-2           
 [43] Rcpp_1.1.1-1.1         knitr_1.51            
 [45] zoo_1.8-15             base64enc_0.1-6       
 [47] splines_4.6.0          tidyselect_1.2.1      
 [49] rstudioapi_0.18.0      abind_1.4-8           
 [51] maptiles_0.11.0        maxLik_1.5-2.2        
 [53] codetools_0.2-20       lattice_0.22-9        
 [55] tibble_3.3.1           leafsync_0.1.0        
 [57] withr_3.0.2            S7_0.2.2              
 [59] coda_0.19-4.1          evaluate_1.0.5        
 [61] marginaleffects_0.32.0 survival_3.8-6        
 [63] fixest_0.14.1          units_1.0-1           
 [65] proxy_0.4-29           pillar_1.11.1         
 [67] KernSmooth_2.23-26     stats4_4.6.0          
 [69] generics_0.1.4         sp_2.2-1              
 [71] scales_1.4.0           xtable_1.8-8          
 [73] class_7.3-23           glue_1.8.1            
 [75] tools_4.6.0            leaflegend_1.2.8      
 [77] data.table_1.18.4      RSpectra_0.16-2       
 [79] dotCall64_1.2          mvtnorm_1.3-7         
 [81] XML_3.99-0.23          grid_4.6.0            
 [83] rbibutils_2.4.1        crosstalk_1.2.2       
 [85] bdsmatrix_1.3-7        colorspace_2.1-2      
 [87] nlme_3.1-169           cols4all_0.10         
 [89] raster_3.6-32          Formula_1.2-5         
 [91] cli_3.6.6              spam_2.11-4           
 [93] dplyr_1.2.1            gtable_0.3.6          
 [95] digest_0.6.39          classInt_0.4-11       
 [97] TH.data_1.1-5          htmlwidgets_1.6.4     
 [99] farver_2.1.2           htmltools_0.5.9       
[101] lifecycle_1.0.5        leaflet_2.2.3         
[103] microbenchmark_1.5.0   MASS_7.3-65           

Reload data from pervious session

load("_data/msoa2_spatial.RData")

11.1 Environmental inequality (continued)

Let’s use the same neighbours weights definition as before:

coords <- st_centroid(msoa.spdf)
Warning: st_centroid assumes attributes are constant over
geometries
# Neighbours within 3km distance
dist_15.nb <- dnearneigh(coords, d1 = 0, d2 = 2500)
Warning in dnearneigh(coords, d1 = 0, d2 = 2500): neighbour object
has 6 sub-graphs
summary(dist_15.nb)
Neighbour list object:
Number of regions: 983 
Number of nonzero links: 15266 
Percentage nonzero weights: 1.579859 
Average number of links: 15.53001 
4 regions with no links:
158, 463, 478, 505
6 disjoint connected subgraphs
Link number distribution:

 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 
 4  5  9 23 19 26 36 31 53 39 61 63 59 48 42 35 24 31 28 30 27 26 
22 23 24 25 26 27 28 29 30 31 32 33 34 
25 19 38 29 32 38 26 16 20 10  8  1  2 
5 least connected regions:
160 469 474 597 959 with 1 link
2 most connected regions:
565 567 with 34 links
# There are some empty neighbour sets. Lets impute those with the nearest neighbour.
k2.nb <- knearneigh(coords, k = 1)

# Replace zero
nolink_ids <- which(card(dist_15.nb) == 0)
dist_15.nb[card(dist_15.nb) == 0] <- k2.nb$nn[nolink_ids, ]

summary(dist_15.nb)
Neighbour list object:
Number of regions: 983 
Number of nonzero links: 15270 
Percentage nonzero weights: 1.580273 
Average number of links: 15.53408 
6 disjoint connected subgraphs
Link number distribution:

 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 
 9  9 23 19 26 36 31 53 39 61 63 59 48 42 35 24 31 28 30 27 26 25 
23 24 25 26 27 28 29 30 31 32 33 34 
19 38 29 32 38 26 16 20 10  8  1  2 
9 least connected regions:
158 160 463 469 474 478 505 597 959 with 1 link
2 most connected regions:
565 567 with 34 links
# listw object with row-normalization
dist_15.lw <- nb2listw(dist_15.nb, style = "W")

and estiamte the spatial SAR model:

mod_1.sar <- lagsarlm(log(no2) ~ per_mixed + per_asian + per_black + per_other
                      + per_nonUK_EU + per_nonEU  + log(POPDEN),  
                      data = msoa.spdf, 
                      listw = dist_15.lw,
                      Durbin = FALSE) # we could here extend to SDM
summary(mod_1.sar)

Call:
lagsarlm(formula = log(no2) ~ per_mixed + per_asian + per_black + 
    per_other + per_nonUK_EU + per_nonEU + log(POPDEN), data = msoa.spdf, 
    listw = dist_15.lw, Durbin = FALSE)

Residuals:
       Min         1Q     Median         3Q        Max 
-0.2140485 -0.0267085 -0.0021421  0.0238337  0.3505513 

Type: lag 
Coefficients: (asymptotic standard errors) 
                Estimate  Std. Error z value  Pr(>|z|)
(Intercept)  -1.7004e-02  1.8122e-02 -0.9383  0.348110
per_mixed     3.4376e-04  1.4758e-03  0.2329  0.815810
per_asian    -8.5205e-05  1.1494e-04 -0.7413  0.458507
per_black    -4.2754e-04  2.3468e-04 -1.8218  0.068484
per_other     1.9693e-03  7.4939e-04  2.6279  0.008591
per_nonUK_EU  8.9027e-04  3.9638e-04  2.2460  0.024703
per_nonEU     1.8460e-03  3.5159e-04  5.2506 1.516e-07
log(POPDEN)   1.8650e-02  2.7852e-03  6.6963 2.138e-11

Rho: 0.9684, LR test value: 2002.5, p-value: < 2.22e-16
Asymptotic standard error: 0.0063124
    z-value: 153.41, p-value: < 2.22e-16
Wald statistic: 23535, p-value: < 2.22e-16

Log likelihood: 1562.401 for lag model
ML residual variance (sigma squared): 0.0020568, (sigma: 0.045352)
Number of observations: 983 
Number of parameters estimated: 10 
AIC: -3104.8, (AIC for lm: -1104.3)
LM test for residual autocorrelation
test value: 108.97, p-value: < 2.22e-16

1) Please calculate the true multiplier matrix of this SAR model.

The multiplier matrix is given by \(({\bm I_N}-\rho {\bm W})^{-1}\). \({\bm W}\) you get via listw2mat(). The diagonal matrix \({\bm I_N}\), you can construct by using diag() (using the right dimension of W). \(\rho\), you get from the model object, and you can use solve() to calculate an inverse.

W <- listw2mat(dist_15.lw)
I <- diag(dim(W)[1])

rho <- unname(mod_1.sar$rho)

M <- solve(I - rho*W)

M[1:10, 1:10]
             1           2           3           4           5
1  1.164650997 0.002433319 0.004089559 0.004034508 0.006545994
2  0.010706605 1.407336301 0.643881932 0.370049927 0.464794934
3  0.011246286 0.402426207 1.474021599 0.429011868 0.641526285
4  0.008875918 0.185024963 0.343209495 1.684533322 0.614086824
5  0.012000989 0.193664556 0.427684190 0.511739020 1.560840834
6  0.010741524 0.192552594 0.452940016 0.631452476 0.672787841
7  0.012779708 0.141953871 0.299247377 0.418234186 0.616895800
8  0.014769006 0.125781189 0.253122442 0.295553039 0.500919513
9  0.011708131 0.147549264 0.309080773 0.568442619 0.629156269
10 0.009937859 0.152900148 0.306652041 0.727001926 0.553973310
             6           7          8           9          10
1  0.004882511 0.005808958 0.00872714 0.005854065 0.003613767
2  0.385105188 0.283907742 0.32703109 0.324608380 0.244640236
3  0.566175019 0.374059222 0.41132397 0.424986063 0.306652041
4  0.631452476 0.418234186 0.38421895 0.625286881 0.581601541
5  0.560656534 0.514079833 0.54266281 0.576726579 0.369315540
6  1.571175245 0.558170218 0.46513922 0.661184961 0.543820047
7  0.558170218 1.475511568 0.58520461 0.614170880 0.463886540
8  0.357799398 0.450157392 1.46638195 0.474994894 0.272339890
9  0.601077237 0.558337164 0.56135760 1.581077095 0.517983092
10 0.679775059 0.579858174 0.44255232 0.712226751 1.560083138

2) Assume we are interested in the effect for non-EU citizens (beta for “per_nonEU”). Please create an N x N effects matrix (using the multiplier above) for the effect of the shar of non-EU citizens on the outcome of each other unit. What is the effect of unit 6 on unit 10? Why is this larger than the effect of unit 5 on unit 8?

# For beta 1

beta <- mod_1.sar$coefficients

effM <- beta["per_nonEU"] * M

effM[1:10, 1:10]
              1            2            3            4            5
1  2.149995e-03 4.492010e-06 7.549498e-06 7.447872e-06 1.208418e-05
2  1.976484e-05 2.598002e-03 1.188633e-03 6.831278e-04 8.580311e-04
3  2.076112e-05 7.428958e-04 2.721106e-03 7.919740e-04 1.184285e-03
4  1.638532e-05 3.415639e-04 6.335792e-04 3.109720e-03 1.133630e-03
5  2.215433e-05 3.575129e-04 7.895231e-04 9.446918e-04 2.881378e-03
6  1.982931e-05 3.554602e-04 8.361464e-04 1.165688e-03 1.241995e-03
7  2.359188e-05 2.620528e-04 5.524233e-04 7.720780e-04 1.138816e-03
8  2.726421e-05 2.321974e-04 4.672747e-04 5.456034e-04 9.247186e-04
9  2.161370e-05 2.723822e-04 5.705762e-04 1.049369e-03 1.161449e-03
10 1.834571e-05 2.822601e-04 5.660926e-04 1.342076e-03 1.022658e-03
              6            7            8            9           10
1  9.013321e-06 1.072358e-05 1.611067e-05 1.080685e-05 6.671166e-06
2  7.109204e-04 5.241057e-04 6.037132e-04 5.992408e-04 4.516162e-04
3  1.045183e-03 6.905291e-04 7.593214e-04 7.845422e-04 5.660926e-04
4  1.165688e-03 7.720780e-04 7.092844e-04 1.154306e-03 1.073661e-03
5  1.034996e-03 9.490131e-04 1.001778e-03 1.064662e-03 6.817721e-04
6  2.900456e-03 1.030406e-03 8.586666e-04 1.220575e-03 1.003915e-03
7  1.030406e-03 2.723857e-03 1.080312e-03 1.133785e-03 8.563541e-04
8  6.605128e-04 8.310095e-04 2.707003e-03 8.768606e-04 5.027509e-04
9  1.109614e-03 1.030714e-03 1.036290e-03 2.918735e-03 9.562187e-04
10 1.254893e-03 1.070443e-03 8.169703e-04 1.314801e-03 2.879979e-03
# "Effect" of unit 6 on unit 10
effM[10, 6]
[1] 0.001254893
# "Effect" of unit 5 on unit 8
effM[8, 5]
[1] 0.0009247186

3) Calculate and interpret the summary impact measures for the SAR model.

mod_1.sar.imp <- impacts(mod_1.sar, listw = dist_15.lw, R = 300)
summary(mod_1.sar.imp)
Impact measures (lag, exact):
                          Direct     Indirect        Total
per_mixed dy/dx     0.0004939013  0.010385844  0.010879745
per_asian dy/dx    -0.0001224192 -0.002574253 -0.002696672
per_black dy/dx    -0.0006142789 -0.012917166 -0.013531445
per_other dy/dx     0.0028294759  0.059498722  0.062328198
per_nonUK_EU dy/dx  0.0012791011  0.026897166  0.028176267
per_nonEU dy/dx     0.0026523198  0.055773451  0.058425770
log(POPDEN) dy/dx   0.0267960076  0.563471199  0.590267206
========================================================
Simulation results ( variance matrix):
Direct:

Iterations = 1:300
Thinning interval = 1 
Number of chains = 1 
Sample size per chain = 300 

1. Empirical mean and standard deviation for each variable,
   plus standard error of the mean:

                         Mean        SD  Naive SE Time-series SE
per_mixed dy/dx     0.0004517 0.0020542 1.186e-04      1.186e-04
per_asian dy/dx    -0.0001178 0.0001607 9.280e-06      9.280e-06
per_black dy/dx    -0.0006048 0.0003269 1.888e-05      2.056e-05
per_other dy/dx     0.0028529 0.0010074 5.816e-05      5.816e-05
per_nonUK_EU dy/dx  0.0012637 0.0005787 3.341e-05      3.341e-05
per_nonEU dy/dx     0.0026625 0.0004423 2.553e-05      2.553e-05
log(POPDEN) dy/dx   0.0267119 0.0038793 2.240e-04      2.240e-04

2. Quantiles for each variable:

                         2.5%        25%        50%        75%
per_mixed dy/dx    -0.0037476 -0.0007716  0.0003728  1.826e-03
per_asian dy/dx    -0.0004024 -0.0002322 -0.0001275 -1.117e-05
per_black dy/dx    -0.0011889 -0.0008643 -0.0006187 -3.758e-04
per_other dy/dx     0.0011247  0.0021310  0.0027917  3.503e-03
per_nonUK_EU dy/dx  0.0001476  0.0008990  0.0012477  1.616e-03
per_nonEU dy/dx     0.0017721  0.0023876  0.0026598  2.960e-03
log(POPDEN) dy/dx   0.0198258  0.0236060  0.0266380  2.938e-02
                       97.5%
per_mixed dy/dx    4.325e-03
per_asian dy/dx    1.967e-04
per_black dy/dx    1.955e-05
per_other dy/dx    4.790e-03
per_nonUK_EU dy/dx 2.531e-03
per_nonEU dy/dx    3.459e-03
log(POPDEN) dy/dx  3.459e-02

========================================================
Indirect:

Iterations = 1:300
Thinning interval = 1 
Number of chains = 1 
Sample size per chain = 300 

1. Empirical mean and standard deviation for each variable,
   plus standard error of the mean:

                        Mean       SD  Naive SE Time-series SE
per_mixed dy/dx     0.008810 0.048179 0.0027816      0.0027816
per_asian dy/dx    -0.002617 0.003819 0.0002205      0.0002205
per_black dy/dx    -0.013267 0.008121 0.0004689      0.0005122
per_other dy/dx     0.062893 0.026819 0.0015484      0.0015484
per_nonUK_EU dy/dx  0.027065 0.012211 0.0007050      0.0007050
per_nonEU dy/dx     0.058749 0.016583 0.0009574      0.0009574
log(POPDEN) dy/dx   0.586973 0.149351 0.0086228      0.0086228

2. Quantiles for each variable:

                        2.5%       25%       50%        75%
per_mixed dy/dx    -0.097259 -0.017613  0.008571  0.0388572
per_asian dy/dx    -0.009696 -0.005022 -0.002475 -0.0002205
per_black dy/dx    -0.029321 -0.018123 -0.013063 -0.0083645
per_other dy/dx     0.021774  0.044679  0.058343  0.0789462
per_nonUK_EU dy/dx  0.003496  0.019280  0.026767  0.0347125
per_nonEU dy/dx     0.033520  0.048078  0.057930  0.0669214
log(POPDEN) dy/dx   0.386684  0.488729  0.566325  0.6498024
                       97.5%
per_mixed dy/dx    0.1044319
per_asian dy/dx    0.0049233
per_black dy/dx    0.0004071
per_other dy/dx    0.1147984
per_nonUK_EU dy/dx 0.0534923
per_nonEU dy/dx    0.0942100
log(POPDEN) dy/dx  0.9583151

========================================================
Total:

Iterations = 1:300
Thinning interval = 1 
Number of chains = 1 
Sample size per chain = 300 

1. Empirical mean and standard deviation for each variable,
   plus standard error of the mean:

                        Mean       SD  Naive SE Time-series SE
per_mixed dy/dx     0.009262 0.050183 0.0028973      0.0028973
per_asian dy/dx    -0.002735 0.003973 0.0002294      0.0002294
per_black dy/dx    -0.013872 0.008414 0.0004858      0.0005311
per_other dy/dx     0.065745 0.027659 0.0015969      0.0015969
per_nonUK_EU dy/dx  0.028328 0.012736 0.0007353      0.0007353
per_nonEU dy/dx     0.061412 0.016868 0.0009739      0.0009739
log(POPDEN) dy/dx   0.613685 0.151457 0.0087444      0.0087444

2. Quantiles for each variable:

                        2.5%       25%       50%        75%
per_mixed dy/dx    -0.101074 -0.018369  0.009006  0.0407207
per_asian dy/dx    -0.010075 -0.005251 -0.002587 -0.0002339
per_black dy/dx    -0.030385 -0.019110 -0.013707 -0.0087500
per_other dy/dx     0.022912  0.046869  0.061246  0.0824820
per_nonUK_EU dy/dx  0.003644  0.020072  0.027897  0.0364017
per_nonEU dy/dx     0.035662  0.050664  0.060696  0.0695733
log(POPDEN) dy/dx   0.409671  0.515044  0.592427  0.6773606
                       97.5%
per_mixed dy/dx    0.1082400
per_asian dy/dx    0.0051375
per_black dy/dx    0.0004262
per_other dy/dx    0.1184796
per_nonUK_EU dy/dx 0.0555344
per_nonEU dy/dx    0.0971066
log(POPDEN) dy/dx  0.9882560

4) Is SAR the right model choice or would you rather estimate a different model? Please run a Durbin model and caculate its impact summary measures

# Spatial Dubrbin model
mod_1.durb <- lagsarlm(log(no2) ~ per_mixed + per_asian + per_black + per_other
                      + per_nonUK_EU + per_nonEU + log(POPDEN),  
                      data = msoa.spdf, 
                      listw = dist_15.lw,
                      Durbin = TRUE)

summary(mod_1.durb)

Call:
lagsarlm(formula = log(no2) ~ per_mixed + per_asian + per_black + 
    per_other + per_nonUK_EU + per_nonEU + log(POPDEN), data = msoa.spdf, 
    listw = dist_15.lw, Durbin = TRUE)

Residuals:
       Min         1Q     Median         3Q        Max 
-0.1854009 -0.0263818 -0.0020816  0.0229647  0.3321974 

Type: mixed 
Coefficients: (asymptotic standard errors) 
                    Estimate  Std. Error z value  Pr(>|z|)
(Intercept)      -0.00409824  0.01983728 -0.2066   0.83633
per_mixed         0.00434535  0.00218712  1.9868   0.04695
per_asian        -0.00028620  0.00023959 -1.1945   0.23227
per_black        -0.00056734  0.00034455 -1.6466   0.09964
per_other         0.00222708  0.00112918  1.9723   0.04857
per_nonUK_EU      0.00085417  0.00059478  1.4361   0.15097
per_nonEU         0.00095220  0.00052681  1.8075   0.07069
log(POPDEN)       0.02649122  0.00320358  8.2693 2.220e-16
lag.per_mixed    -0.00475294  0.00315799 -1.5051   0.13231
lag.per_asian     0.00024092  0.00028983  0.8312   0.40584
lag.per_black     0.00025812  0.00054125  0.4769   0.63344
lag.per_other    -0.00074506  0.00176141 -0.4230   0.67230
lag.per_nonUK_EU  0.00094549  0.00100320  0.9425   0.34595
lag.per_nonEU     0.00130970  0.00078547  1.6674   0.09544
lag.log(POPDEN)  -0.02526415  0.00588517 -4.2928 1.764e-05

Rho: 0.98286, LR test value: 1536.9, p-value: < 2.22e-16
Asymptotic standard error: 0.0051804
    z-value: 189.73, p-value: < 2.22e-16
Wald statistic: 35997, p-value: < 2.22e-16

Log likelihood: 1576.566 for mixed model
ML residual variance (sigma squared): 0.001969, (sigma: 0.044374)
Number of observations: 983 
Number of parameters estimated: 17 
AIC: -3119.1, (AIC for lm: -1584.3)
LM test for residual autocorrelation
test value: 103.97, p-value: < 2.22e-16
# Impact measures of the Durbin Error model
mod_1.durb.imp <- impacts(mod_1.durb, listw = dist_15.lw, R = 300)
summary(mod_1.durb.imp, zstats = TRUE, short = TRUE)
Impact measures (mixed, exact):
                          Direct     Indirect        Total
per_mixed dy/dx     0.0040597904 -0.027843988 -0.023784197
per_asian dy/dx    -0.0003101210 -0.002332322 -0.002642443
per_black dy/dx    -0.0007447486 -0.017299184 -0.018043932
per_other dy/dx     0.0030823781  0.083398408  0.086480787
per_nonUK_EU dy/dx  0.0019115634  0.103104372  0.105015935
per_nonEU dy/dx     0.0022824096  0.129706442  0.131988851
log(POPDEN) dy/dx   0.0269491699  0.044653927  0.071603096
========================================================
Simulation results ( variance matrix):
========================================================
Simulated standard errors
                         Direct   Indirect      Total
per_mixed dy/dx    0.0025286709 0.16959882 0.17081739
per_asian dy/dx    0.0002471124 0.01324621 0.01329233
per_black dy/dx    0.0003792924 0.02724657 0.02737951
per_other dy/dx    0.0012852899 0.09795036 0.09852127
per_nonUK_EU dy/dx 0.0006740466 0.08119923 0.08150104
per_nonEU dy/dx    0.0006368414 0.09916611 0.09945587
log(POPDEN) dy/dx  0.0044540782 0.41173991 0.41468431

Simulated z-values:
                      Direct    Indirect       Total
per_mixed dy/dx     1.566054 -0.13766305 -0.11349814
per_asian dy/dx    -1.342328 -0.28025883 -0.30424129
per_black dy/dx    -2.000899 -0.72203648 -0.74624933
per_other dy/dx     2.373590  0.88701658  0.91284191
per_nonUK_EU dy/dx  2.953143  1.47548381  1.49444356
per_nonEU dy/dx     3.632177  1.52140146  1.54022678
log(POPDEN) dy/dx   6.044093  0.02279423  0.08755131

Simulated p-values:
                   Direct     Indirect Total  
per_mixed dy/dx    0.11733602 0.89051  0.90964
per_asian dy/dx    0.17948959 0.77928  0.76094
per_black dy/dx    0.04540330 0.47027  0.45552
per_other dy/dx    0.01761612 0.37507  0.36133
per_nonUK_EU dy/dx 0.00314556 0.14008  0.13506
per_nonEU dy/dx    0.00028104 0.12816  0.12351
log(POPDEN) dy/dx  1.5025e-09 0.98181  0.93023

5) Please repeat with a Durbin Error model. Why are the impacts here identical to the coefficients?

# Spatial Dubrbin model
mod_1.durbe <- errorsarlm(log(no2) ~ per_mixed + per_asian + per_black + per_other
                      + per_nonUK_EU + per_nonEU + log(POPDEN),  
                      data = msoa.spdf, 
                      listw = dist_15.lw,
                      Durbin = TRUE)

summary(mod_1.durbe)

Call:
errorsarlm(formula = log(no2) ~ per_mixed + per_asian + per_black + 
    per_other + per_nonUK_EU + per_nonEU + log(POPDEN), data = msoa.spdf, 
    listw = dist_15.lw, Durbin = TRUE)

Residuals:
       Min         1Q     Median         3Q        Max 
-0.1839285 -0.0254426 -0.0027042  0.0216084  0.2944840 

Type: error 
Coefficients: (asymptotic standard errors) 
                    Estimate  Std. Error z value  Pr(>|z|)
(Intercept)       2.64939215  0.24748370 10.7053 < 2.2e-16
per_mixed         0.00553333  0.00223688  2.4737  0.013373
per_asian        -0.00017156  0.00024183 -0.7094  0.478062
per_black        -0.00057947  0.00034426 -1.6832  0.092334
per_other         0.00203392  0.00112534  1.8074  0.070701
per_nonUK_EU      0.00086254  0.00058902  1.4644  0.143091
per_nonEU         0.00135822  0.00053480  2.5397  0.011096
log(POPDEN)       0.02716824  0.00354239  7.6695 1.732e-14
lag.per_mixed     0.00107140  0.00819322  0.1308  0.895960
lag.per_asian    -0.00060616  0.00070080 -0.8649  0.387069
lag.per_black    -0.00191733  0.00130997 -1.4636  0.143291
lag.per_other     0.01014125  0.00496979  2.0406  0.041293
lag.per_nonUK_EU  0.00925620  0.00217624  4.2533 2.106e-05
lag.per_nonEU     0.00563564  0.00185541  3.0374  0.002386
lag.log(POPDEN)  -0.01370891  0.01128957 -1.2143  0.224634

Lambda: 0.99424, LR test value: 1527.8, p-value: < 2.22e-16
Asymptotic standard error: 0.0024921
    z-value: 398.96, p-value: < 2.22e-16
Wald statistic: 159170, p-value: < 2.22e-16

Log likelihood: 1572.051 for error model
ML residual variance (sigma squared): 0.0019546, (sigma: 0.044211)
Number of observations: 983 
Number of parameters estimated: 17 
AIC: -3110.1, (AIC for lm: -1584.3)
# Impact measures of the Durbin model
mod_1.durbe.imp <- impacts(mod_1.durbe, listw = dist_15.lw, R = 300)
summary(mod_1.durbe.imp, zstats = TRUE, short = TRUE)
Impact measures (SDEM, glht, n):
                          Direct      Indirect         Total
per_mixed dy/dx     0.0055333298  0.0010713981  0.0066047279
per_asian dy/dx    -0.0001715584 -0.0006061567 -0.0007777151
per_black dy/dx    -0.0005794704 -0.0019173261 -0.0024967965
per_other dy/dx     0.0020339226  0.0101412504  0.0121751729
per_nonUK_EU dy/dx  0.0008625423  0.0092561971  0.0101187394
per_nonEU dy/dx     0.0013582217  0.0056356426  0.0069938643
log(POPDEN) dy/dx   0.0271682392 -0.0137089088  0.0134593305
========================================================
Standard errors:
                         Direct     Indirect        Total
per_mixed dy/dx    0.0022368774 0.0081932151 0.0089412446
per_asian dy/dx    0.0002418282 0.0007008041 0.0007540247
per_black dy/dx    0.0003442649 0.0013099673 0.0013639632
per_other dy/dx    0.0011253352 0.0049697880 0.0051074709
per_nonUK_EU dy/dx 0.0005890159 0.0021762395 0.0022231333
per_nonEU dy/dx    0.0005348024 0.0018554128 0.0020196122
log(POPDEN) dy/dx  0.0035423870 0.0112895670 0.0132006518
========================================================
Z-values:
                       Direct   Indirect     Total
per_mixed dy/dx     2.4736849  0.1307665  0.738681
per_asian dy/dx    -0.7094226 -0.8649446 -1.031419
per_black dy/dx    -1.6832108 -1.4636442 -1.830545
per_other dy/dx     1.8073926  2.0405801  2.383797
per_nonUK_EU dy/dx  1.4643785  4.2532989  4.551567
per_nonEU dy/dx     2.5396703  3.0374063  3.462974
log(POPDEN) dy/dx   7.6694724 -1.2142989  1.019596

p-values:
                   Direct     Indirect   Total     
per_mixed dy/dx    0.013373   0.8959600  0.46010070
per_asian dy/dx    0.478062   0.3870692  0.30234457
per_black dy/dx    0.092334   0.1432912  0.06716843
per_other dy/dx    0.070701   0.0412926  0.01713506
per_nonUK_EU dy/dx 0.143091   2.1064e-05 5.3248e-06
per_nonEU dy/dx    0.011096   0.0023862  0.00053424
log(POPDEN) dy/dx  1.7319e-14 0.2246336  0.30792015