Introduction to GWR and MGWR
Setup
/opt/conda/lib/python3.9/site-packages/esda/getisord.py:636: SyntaxWarning: "is" with a literal. Did you mean "=="?
if __name__ is "__main__":
/opt/conda/lib/python3.9/site-packages/spglm/utils.py:367: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if resetlist is not ():
Import data
Select variables (y, X)
Define coordinates (u,v)
Estimate GWR model
Select GWR bandwidth
CPU times: user 2.38 s, sys: 313 ms, total: 2.7 s
Wall time: 3.03 s
GWR bandwidth = 117.0
Fit GWR model
===========================================================================
Model type Gaussian
Number of observations: 159
Number of covariates: 4
Global Regression Results
---------------------------------------------------------------------------
Residual sum of squares: 2315.466
Log-likelihood: -438.549
AIC: 885.098
AICc: 887.490
BIC: 1529.786
R2: 0.548
Adj. R2: 0.540
Variable Est. SE t(Est/SE) p-value
------------------------------- ---------- ---------- ---------- ----------
X0 14.835 1.400 10.599 0.000
X1 2.110 0.302 6.988 0.000
X2 -0.027 0.018 -1.525 0.127
X3 -0.079 0.014 -5.734 0.000
Geographically Weighted Regression (GWR) Results
---------------------------------------------------------------------------
Spatial kernel: Adaptive bisquare
Bandwidth used: 117.000
Diagnostic information
---------------------------------------------------------------------------
Residual sum of squares: 1650.860
Effective number of parameters (trace(S)): 11.805
Degree of freedom (n - trace(S)): 147.195
Sigma estimate: 3.349
Log-likelihood: -411.653
AIC: 848.915
AICc: 851.350
BIC: 888.212
R2: 0.678
Adjusted R2: 0.652
Adj. alpha (95%): 0.017
Adj. critical t value (95%): 2.414
Summary Statistics For GWR Parameter Estimates
---------------------------------------------------------------------------
Variable Mean STD Min Median Max
-------------------- ---------- ---------- ---------- ---------- ----------
X0 13.653 0.815 11.947 13.636 15.411
X1 2.200 1.078 0.568 2.564 3.415
X2 -0.014 0.027 -0.056 -0.017 0.033
X3 -0.069 0.013 -0.097 -0.065 -0.051
===========================================================================
Mean R2 = 0.6780742669593465
AIC = 848.9154070534352
AICc = 851.3502927844658
Add coefficients to data frame
Filter/correct t-stats
0
7.575212201
2.043091858
1
7.867274106
0
2
7.721605279
0
3
7.289408655
0
4
6.99319588
8.464019731
5
7.374371638
8.580098061
6
7.520669526
8.684610812
7
6.845622711
8.866210969
8
7.374570257
2.276872322
9
7.877267616
0
0
7.575212201
0
1
7.867274106
0
2
7.721605279
0
3
7.289408655
0
4
6.99319588
8.464019731
5
7.374371638
8.580098061
6
7.520669526
8.684610812
7
6.845622711
8.866210969
8
7.374570257
0
9
7.877267616
0
Map coefficients
Test spatial stationarity
CPU times: user 6min 36s, sys: 8min 13s, total: 14min 49s
Wall time: 14min 57s
Test local multicollinearity
0
1.182403243
1.021370273
1
1.147263524
1.031686252
2
1.167970589
1.024843495
3
1.279951303
1.066151167
4
1.839177319
1.061995601
5
1.903473887
1.056656555
6
1.978994615
1.048208014
7
1.877960094
1.035297416
8
1.173657434
1.038969892
9
1.158581724
1.037341583
count
159
159
mean
1.63
1.05
std
0.36
0.02
min
1.14
1.01
25%
1.26
1.03
50%
1.69
1.05
75%
1.92
1.06
max
2.25
1.1
As the max VIF for each variable is less than 10, there are no signs of local multicollinearity
0
10.78576742
1
11.30261189
2
10.98943303
3
10.65286267
4
11.51778843
5
11.75646986
6
11.68556366
7
10.46958525
8
11.3219659
9
11.17220514
Estimate MGWR model
Standardize variables
Select MGWR bandwidths
IPyWidgets are not supported
Fit MGWR model
IPyWidgets are not supported
===========================================================================
Model type Gaussian
Number of observations: 159
Number of covariates: 4
Global Regression Results
---------------------------------------------------------------------------
Residual sum of squares: 71.793
Log-likelihood: -162.399
AIC: 332.798
AICc: 335.191
BIC: -713.887
R2: 0.548
Adj. R2: 0.540
Variable Est. SE t(Est/SE) p-value
------------------------------- ---------- ---------- ---------- ----------
X0 0.000 0.054 0.000 1.000
X1 0.458 0.066 6.988 0.000
X2 -0.084 0.055 -1.525 0.127
X3 -0.374 0.065 -5.734 0.000
Multi-Scale Geographically Weighted Regression (MGWR) Results
---------------------------------------------------------------------------
Spatial kernel: Adaptive bisquare
Criterion for optimal bandwidth: AICc
Score of Change (SOC) type: Smoothing f
Termination criterion for MGWR: 1e-05
MGWR bandwidths
---------------------------------------------------------------------------
Variable Bandwidth ENP_j Adj t-val(95%) Adj alpha(95%)
X0 101.000 3.397 2.466 0.015
X1 101.000 3.512 2.479 0.014
X2 117.000 2.778 2.391 0.018
X3 157.000 1.786 2.218 0.028
Diagnostic information
---------------------------------------------------------------------------
Residual sum of squares: 50.804
Effective number of parameters (trace(S)): 11.474
Degree of freedom (n - trace(S)): 147.526
Sigma estimate: 0.587
Log-likelihood: -134.907
AIC: 294.761
AICc: 297.070
BIC: 333.041
R2 0.680
Adjusted R2 0.655
Summary Statistics For MGWR Parameter Estimates
---------------------------------------------------------------------------
Variable Mean STD Min Median Max
-------------------- ---------- ---------- ---------- ---------- ----------
X0 0.018 0.162 -0.237 0.061 0.251
X1 0.482 0.217 0.119 0.500 0.726
X2 -0.063 0.051 -0.158 -0.057 0.026
X3 -0.301 0.019 -0.345 -0.299 -0.264
===========================================================================
Show bandwidth intervals
[(87.0, 104.0), (87.0, 104.0), (114.0, 117.0), (114.0, 157.0)]
Add coefficients to data frame
Filter/correct t-stats
Map coefficients
Test spatial stationarity
IPyWidgets are not supported
IPyWidgets are not supported
IPyWidgets are not supported
IPyWidgets are not supported
IPyWidgets are not supported
IPyWidgets are not supported
IPyWidgets are not supported
IPyWidgets are not supported
IPyWidgets are not supported
IPyWidgets are not supported
CPU times: user 3min 17s, sys: 4min 14s, total: 7min 31s
Wall time: 7min 34s