├── .ipynb_checkpoints ├── GWR-experiments-checkpoint.ipynb └── Preprocessing for GE-checkpoint.ipynb ├── MGWR Software ChangeLog.docx ├── README.md ├── georgia ├── GData_utm.csv ├── G_utm.cpg ├── G_utm.dbf ├── G_utm.sbn ├── G_utm.sbx ├── G_utm.shp └── G_utm.shx ├── img ├── Group.png ├── MGWR128.png ├── MGWR16.png ├── MGWR24.png ├── MGWR32.png ├── MGWR48.png ├── MGWR64.png ├── loader-50.gif ├── loader.gif └── loading MGWR.sketch ├── main-mac.spec ├── main.py ├── main.spec ├── mgwrlib ├── __init__.py └── mgwr │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-35.pyc │ ├── __init__.cpython-36.pyc │ ├── diagnostics.cpython-35.pyc │ ├── diagnostics.cpython-36.pyc │ ├── gwr.cpython-35.pyc │ ├── gwr.cpython-36.pyc │ ├── kernels.cpython-35.pyc │ ├── kernels.cpython-36.pyc │ ├── search.cpython-35.pyc │ ├── search.cpython-36.pyc │ ├── sel_bw.cpython-35.pyc │ ├── sel_bw.cpython-36.pyc │ ├── summary.cpython-35.pyc │ └── summary.cpython-36.pyc │ ├── diagnostics.py │ ├── gwr.py │ ├── kernels.py │ ├── search.py │ ├── sel_bw.py │ ├── summary.py │ ├── tests │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-35.pyc │ │ ├── test_gwr.cpython-35.pyc │ │ ├── test_kernels.cpython-35.pyc │ │ ├── test_parallel.cpython-35.pyc │ │ └── test_sel_bw.cpython-35.pyc │ ├── clearwater │ │ ├── clearwater_BS_F.ctl │ │ ├── clearwater_BS_F_listwise.csv │ │ ├── clearwater_BS_F_summary.txt │ │ ├── clearwater_BS_NN.ctl │ │ ├── clearwater_BS_NN_listwise.csv │ │ ├── clearwater_BS_NN_summary.txt │ │ ├── clearwater_GS_F.ctl │ │ ├── clearwater_GS_F_listwise.csv │ │ ├── clearwater_GS_F_summary.txt │ │ ├── clearwater_GS_NN.ctl │ │ ├── clearwater_GS_NN_listwise.csv │ │ ├── clearwater_GS_NN_summary.txt │ │ ├── landslides.csv │ │ ├── quads.dbf │ │ ├── quads.shp │ │ ├── quads.shx │ │ ├── streams.dbf │ │ ├── streams.shp │ │ └── streams.shx │ ├── ga_bs_nn_longlat_listwise.csv │ ├── georgia_mgwr_results.csv │ ├── local_cn.csv │ ├── local_corr.csv │ ├── local_vdp.csv │ ├── local_vif.csv │ ├── mgwr_example.p │ ├── test_gwr.py │ ├── test_kernels.py │ ├── test_parallel.py │ ├── test_sel_bw.py │ └── tokyo │ │ ├── Readme_tokyomortality.txt │ │ ├── SampleTokyoMortalityGWPR.ctl │ │ ├── Tokyomortality.csv │ │ ├── Tokyomortality.txt │ │ ├── tokyo_BS_F.ctl │ │ ├── tokyo_BS_F_listwise.csv │ │ ├── tokyo_BS_F_summary.txt │ │ ├── tokyo_BS_NN.ctl │ │ ├── tokyo_BS_NN_OFF.ctl │ │ ├── tokyo_BS_NN_OFF_listwise.csv │ │ ├── tokyo_BS_NN_OFF_summary.txt │ │ ├── tokyo_BS_NN_listwise.csv │ │ ├── tokyo_BS_NN_summary.txt │ │ ├── tokyo_GS_F.ctl │ │ ├── tokyo_GS_F_listwise.csv │ │ ├── tokyo_GS_F_summary.txt │ │ ├── tokyo_GS_NN.ctl │ │ ├── tokyo_GS_NN_listwise.csv │ │ ├── tokyo_GS_NN_summary.txt │ │ ├── tokyomet262.dbf │ │ ├── tokyomet262.prj │ │ ├── tokyomet262.shp │ │ ├── tokyomet262.shp.xml │ │ └── tokyomet262.shx │ └── utils.py ├── requirements.txt ├── resources ├── img │ ├── MGWR-pc.ico │ ├── MGWR.icns │ └── MGWR.png ├── screenshots │ ├── gui-advGWR.png │ ├── gui-advMGWR.png │ ├── gui-export.png │ ├── gui-logging.png │ ├── gui-main.png │ └── gui-summary.png └── ui │ ├── advOptGWR.ui │ ├── advOptGWR_mul.ui │ ├── advOptMGWR.ui │ ├── advOptMGWR_mul.ui │ ├── gui-no-prediction.ui │ ├── gui.ui │ ├── loader.ui │ └── running_now.ui ├── src ├── advancedGWR.py ├── advancedGWR_withmcc.py ├── advancedMGWR.py ├── advancedMGWR_withmcc.py ├── gui.py ├── loader.py ├── outputs.py └── summaryGUI.py └── test0131_sub_1000_10.csv /.ipynb_checkpoints/Preprocessing for GE-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [], 3 | "metadata": {}, 4 | "nbformat": 4, 5 | "nbformat_minor": 1 6 | } 7 | -------------------------------------------------------------------------------- /MGWR Software ChangeLog.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/MGWR Software ChangeLog.docx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Multi-scale Geographically Weighted Regression 2 | 3 | ![MGWR Logo](https://github.com/Ziqi-Li/MGWR-GUI/blob/mgwr-pc/img/MGWR64.png) 4 | 5 | MGWR 2.0 is a free GUI software built upon [mgwr](https://github.com/pysal/mgwr) python package. 6 | 7 | Current version: v2.2 8 | 9 | Please download from: [https://cosspp.fsu.edu/sdsc/mgwr/](https://cosspp.fsu.edu/sdsc/mgwr/) 10 | 11 | Main Interface: 12 | 13 | 14 | 15 | Summary Page: 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /georgia/G_utm.cpg: -------------------------------------------------------------------------------- 1 | ISO-8859-1 -------------------------------------------------------------------------------- /georgia/G_utm.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/georgia/G_utm.dbf -------------------------------------------------------------------------------- /georgia/G_utm.sbn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/georgia/G_utm.sbn -------------------------------------------------------------------------------- /georgia/G_utm.sbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/georgia/G_utm.sbx -------------------------------------------------------------------------------- /georgia/G_utm.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/georgia/G_utm.shp -------------------------------------------------------------------------------- /georgia/G_utm.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/georgia/G_utm.shx -------------------------------------------------------------------------------- /img/Group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/img/Group.png -------------------------------------------------------------------------------- /img/MGWR128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/img/MGWR128.png -------------------------------------------------------------------------------- /img/MGWR16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/img/MGWR16.png -------------------------------------------------------------------------------- /img/MGWR24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/img/MGWR24.png -------------------------------------------------------------------------------- /img/MGWR32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/img/MGWR32.png -------------------------------------------------------------------------------- /img/MGWR48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/img/MGWR48.png -------------------------------------------------------------------------------- /img/MGWR64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/img/MGWR64.png -------------------------------------------------------------------------------- /img/loader-50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/img/loader-50.gif -------------------------------------------------------------------------------- /img/loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/img/loader.gif -------------------------------------------------------------------------------- /img/loading MGWR.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/img/loading MGWR.sketch -------------------------------------------------------------------------------- /main-mac.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher = None 4 | 5 | 6 | a = Analysis(['main.py'], 7 | pathex=['/Users/Ziqi/Desktop/mgwr-gui/'], 8 | binaries=[], 9 | datas=[('/Users/Ziqi/Desktop/mgwr-gui/img','img')], 10 | hiddenimports=[], 11 | hookspath=[], 12 | runtime_hooks=[], 13 | excludes=['FixTk', 'tcl', 'tk', '_tkinter', 'tkinter', 'Tkinter'], 14 | win_no_prefer_redirects=False, 15 | win_private_assemblies=False, 16 | cipher=block_cipher) 17 | pyz = PYZ(a.pure, a.zipped_data, 18 | cipher=block_cipher) 19 | exe = EXE(pyz, 20 | a.scripts, 21 | exclude_binaries=True, 22 | name='main', 23 | debug=True, 24 | strip=False, 25 | upx=True, 26 | console=False ) 27 | coll = COLLECT(exe, 28 | a.binaries, 29 | a.zipfiles, 30 | a.datas, 31 | strip=False, 32 | upx=True, 33 | name='main') 34 | app = BUNDLE(coll, 35 | name='MGWR.app', 36 | icon='resources/img/MGWR.icns', 37 | bundle_identifier=None, 38 | info_plist={ 39 | 'NSHighResolutionCapable': 'True' 40 | } 41 | ) 42 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'gui.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.9 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt5 import QtCore, QtGui, QtWidgets 10 | from src.gui import Ui_Dialog 11 | import sys,os,time 12 | import multiprocessing as mp 13 | import psutil 14 | 15 | if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'): 16 | QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True) 17 | 18 | if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'): 19 | QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True) 20 | 21 | def resource_path(relative_path): 22 | if hasattr(sys, '_MEIPASS'): 23 | return os.path.join(sys._MEIPASS, relative_path) 24 | return os.path.join(os.path.abspath("."), relative_path) 25 | 26 | 27 | if __name__ == "__main__": 28 | #mp.set_start_method('spawn',force=True) 29 | 30 | #os.environ["OMP_NUM_THREADS"] = "1" 31 | mp.freeze_support() 32 | #os.environ["OPENBLAS_NUM_THREADS"] = "1" 33 | 34 | app = QtWidgets.QApplication(sys.argv) 35 | app.setStyle('mac') 36 | 37 | app_icon = QtGui.QIcon() 38 | app_icon.addFile(resource_path('img/MGWR16.png'), QtCore.QSize(16,16)) 39 | app_icon.addFile(resource_path('img/MGWR24.png'), QtCore.QSize(24,24)) 40 | app_icon.addFile(resource_path('img/MGWR32.png'), QtCore.QSize(32,32)) 41 | app_icon.addFile(resource_path('img/MGWR48.png'), QtCore.QSize(48,48)) 42 | app_icon.addFile(resource_path('img/MGWR64.png'), QtCore.QSize(64,64)) 43 | app_icon.addFile(resource_path('img/MGWR128.png'), QtCore.QSize(128,128)) 44 | app.setWindowIcon(app_icon) 45 | 46 | 47 | # Create and display the splash screen 48 | splash_pix = QtGui.QPixmap(resource_path('img/Group.png')) 49 | #splash_pix = img.scaled(QtCore.QSize(634/2,468/2),QtCore.Qt.KeepAspectRatio) 50 | 51 | splash = QtWidgets.QSplashScreen(splash_pix, QtCore.Qt.WindowStaysOnTopHint) 52 | # adding progress bar 53 | progressBar = QtWidgets.QProgressBar(splash) 54 | progressBar.setGeometry(splash.width()/10, 9*splash.height()/10, 55 | 8*splash.width()/10, splash.height()/10) 56 | splash.setMask(splash_pix.mask()) 57 | 58 | splash.show() 59 | for i in range(0, 100): 60 | progressBar.setValue(i) 61 | t = time.time() 62 | while time.time() < t + 0.01: 63 | app.processEvents() 64 | 65 | #Initiate Main Dialog 66 | Dialog = QtWidgets.QDialog() 67 | Dialog.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowCloseButtonHint) 68 | ui = Ui_Dialog() 69 | pool = mp.Pool(psutil.cpu_count()) 70 | ui.setupUi(Dialog, pool) 71 | Dialog.setFixedSize(Dialog.size()) 72 | ui.addActionsToUI() 73 | Dialog.show() 74 | splash.finish(Dialog) 75 | sys.exit(app.exec_()) 76 | 77 | -------------------------------------------------------------------------------- /main.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher = None 4 | 5 | 6 | a = Analysis(['main.py'], 7 | pathex=['/Users/Ziqi/Desktop/mgwr-gui'], 8 | binaries=[], 9 | datas=[], 10 | hiddenimports=[], 11 | hookspath=[], 12 | runtime_hooks=[], 13 | excludes=[], 14 | win_no_prefer_redirects=False, 15 | win_private_assemblies=False, 16 | cipher=block_cipher, 17 | noarchive=False) 18 | pyz = PYZ(a.pure, a.zipped_data, 19 | cipher=block_cipher) 20 | exe = EXE(pyz, 21 | a.scripts, 22 | [], 23 | exclude_binaries=True, 24 | name='main', 25 | debug=False, 26 | bootloader_ignore_signals=False, 27 | strip=False, 28 | upx=True, 29 | console=True ) 30 | coll = COLLECT(exe, 31 | a.binaries, 32 | a.zipfiles, 33 | a.datas, 34 | strip=False, 35 | upx=True, 36 | name='main') 37 | -------------------------------------------------------------------------------- /mgwrlib/__init__.py: -------------------------------------------------------------------------------- 1 | import mgwrlib.mgwr 2 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "2.1.1" 2 | 3 | from . import gwr 4 | from . import sel_bw 5 | from . import diagnostics 6 | from . import kernels 7 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/__pycache__/diagnostics.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/__pycache__/diagnostics.cpython-35.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/__pycache__/diagnostics.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/__pycache__/diagnostics.cpython-36.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/__pycache__/gwr.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/__pycache__/gwr.cpython-35.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/__pycache__/gwr.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/__pycache__/gwr.cpython-36.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/__pycache__/kernels.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/__pycache__/kernels.cpython-35.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/__pycache__/kernels.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/__pycache__/kernels.cpython-36.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/__pycache__/search.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/__pycache__/search.cpython-35.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/__pycache__/search.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/__pycache__/search.cpython-36.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/__pycache__/sel_bw.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/__pycache__/sel_bw.cpython-35.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/__pycache__/sel_bw.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/__pycache__/sel_bw.cpython-36.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/__pycache__/summary.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/__pycache__/summary.cpython-35.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/__pycache__/summary.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/__pycache__/summary.cpython-36.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/diagnostics.py: -------------------------------------------------------------------------------- 1 | """ 2 | Diagnostics for estimated gwr models 3 | """ 4 | __author__ = "Taylor Oshan tayoshan@gmail.com" 5 | 6 | import numpy as np 7 | from scipy import linalg 8 | from spglm.family import Gaussian, Poisson, Binomial 9 | 10 | 11 | def get_AICc(gwr): 12 | """ 13 | Get AICc value 14 | 15 | Gaussian: p61, (2.33), Fotheringham, Brunsdon and Charlton (2002) 16 | 17 | GWGLM: AICc=AIC+2k(k+1)/(n-k-1), Nakaya et al. (2005): p2704, (36) 18 | 19 | """ 20 | n = gwr.n 21 | k = gwr.tr_S 22 | #sigma2 = gwr.sigma2 23 | if isinstance(gwr.family, Gaussian): 24 | aicc = -2.0 * gwr.llf + 2.0 * n * (k + 1.0) / ( 25 | n - k - 2.0) #equivalent to below but 26 | #can't control denominator of sigma without altering GLM familt code 27 | #aicc = n*np.log(sigma2) + n*np.log(2.0*np.pi) + n*(n+k)/(n-k-2.0) 28 | elif isinstance(gwr.family, (Poisson, Binomial)): 29 | aicc = get_AIC(gwr) + 2.0 * k * (k + 1.0) / (n - k - 1.0) 30 | return aicc 31 | 32 | 33 | def get_AIC(gwr): 34 | """ 35 | Get AIC calue 36 | 37 | Gaussian: p96, (4.22), Fotheringham, Brunsdon and Charlton (2002) 38 | 39 | GWGLM: AIC(G)=D(G) + 2K(G), where D and K denote the deviance and the effective 40 | number of parameters in the model with bandwidth G, respectively. 41 | 42 | """ 43 | k = gwr.tr_S 44 | #deviance = -2*log-likelihood 45 | y = gwr.y 46 | mu = gwr.mu 47 | if isinstance(gwr.family, Gaussian): 48 | aic = -2.0 * gwr.llf + 2.0 * (k + 1) 49 | elif isinstance(gwr.family, (Poisson, Binomial)): 50 | aic = np.sum(gwr.family.resid_dev(y, mu)**2) + 2.0 * k 51 | return aic 52 | 53 | 54 | def get_BIC(gwr): 55 | """ 56 | Get BIC value 57 | 58 | Gaussian: p61 (2.34), Fotheringham, Brunsdon and Charlton (2002) 59 | BIC = -2log(L)+klog(n) 60 | 61 | GWGLM: BIC = dev + tr_S * log(n) 62 | 63 | """ 64 | n = gwr.n # (scalar) number of observations 65 | k = gwr.tr_S 66 | y = gwr.y 67 | mu = gwr.mu 68 | if isinstance(gwr.family, Gaussian): 69 | bic = -2.0 * gwr.llf + (k + 1) * np.log(n) 70 | elif isinstance(gwr.family, (Poisson, Binomial)): 71 | bic = np.sum(gwr.family.resid_dev(y, mu)**2) + k * np.log(n) 72 | return bic 73 | 74 | 75 | def get_CV(gwr): 76 | """ 77 | Get CV value 78 | 79 | Gaussian only 80 | 81 | Methods: p60, (2.31) or p212 (9.4) 82 | Fotheringham, A. S., Brunsdon, C., & Charlton, M. (2002). 83 | Geographically weighted regression: the analysis of spatially varying relationships. 84 | Modification: sum of residual squared is divided by n according to GWR4 results 85 | 86 | """ 87 | aa = gwr.resid_response.reshape((-1, 1)) / (1.0 - gwr.influ) 88 | cv = np.sum(aa**2) / gwr.n 89 | return cv 90 | 91 | 92 | def corr(cov): 93 | invsd = np.diag(1 / np.sqrt(np.diag(cov))) 94 | cors = np.dot(np.dot(invsd, cov), invsd) 95 | return cors 96 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/kernels.py: -------------------------------------------------------------------------------- 1 | # GWR kernel function specifications 2 | 3 | __author__ = "Taylor Oshan tayoshan@gmail.com" 4 | 5 | import numpy as np 6 | #adaptive specifications should be parameterized with nn-1 to match original gwr 7 | #implementation. That is, pysal counts self neighbors with knn automatically. 8 | 9 | #Soft dependency of numba's njit 10 | try: 11 | from numba import njit 12 | except ImportError: 13 | 14 | def njit(func): 15 | return func 16 | 17 | 18 | @njit 19 | def local_cdist(coords_i, coords, spherical): 20 | """ 21 | Compute Haversine (spherical=True) or Euclidean (spherical=False) distance for a local kernel. 22 | """ 23 | if spherical: 24 | dLat = np.radians(coords[:, 1] - coords_i[1]) 25 | dLon = np.radians(coords[:, 0] - coords_i[0]) 26 | lat1 = np.radians(coords[:, 1]) 27 | lat2 = np.radians(coords_i[1]) 28 | a = np.sin( 29 | dLat / 2)**2 + np.cos(lat1) * np.cos(lat2) * np.sin(dLon / 2)**2 30 | c = 2 * np.arcsin(np.sqrt(a)) 31 | R = 6371.0 32 | return R * c 33 | else: 34 | return np.sqrt(np.sum((coords_i - coords)**2, axis=1)) 35 | 36 | 37 | class Kernel(object): 38 | """ 39 | GWR kernel function specifications. 40 | 41 | """ 42 | 43 | def __init__(self, i, data, bw=None, fixed=True, function='triangular', 44 | eps=1.0000001, ids=None, points=None, spherical=False): 45 | 46 | if points is None: 47 | self.dvec = local_cdist(data[i], data, spherical).reshape(-1) 48 | else: 49 | self.dvec = local_cdist(points[i], data, spherical).reshape(-1) 50 | 51 | self.function = function.lower() 52 | 53 | if fixed: 54 | self.bandwidth = float(bw) 55 | else: 56 | self.bandwidth = np.partition( 57 | self.dvec, 58 | int(bw) - 1)[int(bw) - 1] * eps #partial sort in O(n) Time 59 | 60 | self.kernel = self._kernel_funcs(self.dvec / self.bandwidth) 61 | 62 | if self.function == "bisquare": #Truncate for bisquare 63 | self.kernel[(self.dvec >= self.bandwidth)] = 0 64 | 65 | def _kernel_funcs(self, zs): 66 | # functions follow Anselin and Rey (2010) table 5.4 67 | if self.function == 'triangular': 68 | return 1 - zs 69 | elif self.function == 'uniform': 70 | return np.ones(zi.shape) * 0.5 71 | elif self.function == 'quadratic': 72 | return (3. / 4) * (1 - zs**2) 73 | elif self.function == 'quartic': 74 | return (15. / 16) * (1 - zs**2)**2 75 | elif self.function == 'gaussian': 76 | return np.exp(-0.5 * (zs)**2) 77 | elif self.function == 'gui-gaussian': 78 | return np.exp(-0.5 * (2.45*zs)**2) 79 | elif self.function == 'bisquare': 80 | return (1 - (zs)**2)**2 81 | elif self.function == 'exponential': 82 | return np.exp(-zs) 83 | else: 84 | print('Unsupported kernel function', self.function) 85 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/search.py: -------------------------------------------------------------------------------- 1 | #Bandwidth optimization methods 2 | 3 | __author__ = "Taylor Oshan" 4 | 5 | import numpy as np 6 | from copy import deepcopy 7 | 8 | 9 | def golden_section(a, c, delta, function, tol, max_iter, int_score=False, 10 | verbose=False): 11 | """ 12 | Golden section search routine 13 | Method: p212, 9.6.4 14 | Fotheringham, A. S., Brunsdon, C., & Charlton, M. (2002). 15 | Geographically weighted regression: the analysis of spatially varying relationships. 16 | 17 | Parameters 18 | ---------- 19 | a : float 20 | initial max search section value 21 | b : float 22 | initial min search section value 23 | delta : float 24 | constant used to determine width of search sections 25 | function : function 26 | obejective function to be evaluated at different section 27 | values 28 | int_score : boolean 29 | False for float score, True for integer score 30 | tol : float 31 | tolerance used to determine convergence 32 | max_iter : integer 33 | maximum iterations if no convergence to tolerance 34 | 35 | Returns 36 | ------- 37 | opt_val : float 38 | optimal value 39 | opt_score : kernel 40 | optimal score 41 | output : list of tuples 42 | searching history 43 | """ 44 | b = a + delta * np.abs(c - a) 45 | d = c - delta * np.abs(c - a) 46 | score = 0.0 47 | diff = 1.0e9 48 | iters = 0 49 | output = [] 50 | dict = {} 51 | while np.abs(diff) > tol and iters < max_iter: 52 | iters += 1 53 | if int_score: 54 | b = np.round(b) 55 | d = np.round(d) 56 | 57 | if b in dict: 58 | score_b = dict[b] 59 | else: 60 | score_b = function(b) 61 | dict[b] = score_b 62 | if verbose: 63 | print("Bandwidth: ", np.round(b, 2), ", score: ", 64 | "{0:.2f}".format(score_b)) 65 | 66 | if d in dict: 67 | score_d = dict[d] 68 | else: 69 | score_d = function(d) 70 | dict[d] = score_d 71 | if verbose: 72 | print("Bandwidth: ", np.round(d, 2), ", score: ", 73 | "{0:.2f}".format(score_d)) 74 | 75 | if score_b <= score_d: 76 | opt_val = b 77 | opt_score = score_b 78 | c = d 79 | d = b 80 | b = a + delta * np.abs(c - a) 81 | 82 | else: 83 | opt_val = d 84 | opt_score = score_d 85 | a = b 86 | b = d 87 | d = c - delta * np.abs(c - a) 88 | 89 | diff = score_b - score_d 90 | score = opt_score 91 | output = list(dict.items()) 92 | return np.round(opt_val, 2), opt_score, output 93 | 94 | 95 | def equal_interval(l_bound, u_bound, interval, function, int_score=False, 96 | verbose=False): 97 | """ 98 | Interval search, using interval as stepsize 99 | 100 | Parameters 101 | ---------- 102 | l_bound : float 103 | initial min search section value 104 | u_bound : float 105 | initial max search section value 106 | interval : float 107 | constant used to determine width of search sections 108 | function : function 109 | obejective function to be evaluated at different section 110 | values 111 | int_score : boolean 112 | False for float score, True for integer score 113 | 114 | Returns 115 | ------- 116 | opt_val : float 117 | optimal value 118 | opt_score : kernel 119 | optimal score 120 | output : list of tuples 121 | searching history 122 | """ 123 | a = l_bound 124 | c = u_bound 125 | b = a + interval 126 | if int_score: 127 | a = np.round(a, 0) 128 | c = np.round(c, 0) 129 | b = np.round(b, 0) 130 | 131 | output = [] 132 | 133 | score_a = function(a) 134 | if verbose: 135 | print("Bandwidth:", a, ", score:", "{0:.2f}".format(score_a)) 136 | 137 | output.append((a, score_a)) 138 | 139 | opt_val = a 140 | opt_score = score_a 141 | 142 | while b < c: 143 | score_b = function(b) 144 | if verbose: 145 | print("Bandwidth:", b, ", score:", "{0:.2f}".format(score_b)) 146 | output.append((b, score_b)) 147 | 148 | if score_b < opt_score: 149 | opt_val = b 150 | opt_score = score_b 151 | b = b + interval 152 | 153 | score_c = function(c) 154 | if verbose: 155 | print("Bandwidth:", c, ", score:", "{0:.2f}".format(score_c)) 156 | 157 | output.append((c, score_c)) 158 | 159 | if score_c < opt_score: 160 | opt_val = c 161 | opt_score = score_c 162 | 163 | return opt_val, opt_score, output 164 | 165 | 166 | def multi_bw(init, y, X, n, k, family, tol, max_iter, rss_score, gwr_func, 167 | bw_func, sel_func, multi_bw_min, multi_bw_max, bws_same_times, 168 | verbose=False): 169 | """ 170 | Multiscale GWR bandwidth search procedure using iterative GAM backfitting 171 | """ 172 | if init is None: 173 | bw = sel_func(bw_func(y, X)) 174 | optim_model = gwr_func(y, X, bw) 175 | else: 176 | bw = init 177 | optim_model = gwr_func(y, X, init) 178 | bw_gwr = bw 179 | err = optim_model.resid_response.reshape((-1, 1)) 180 | param = optim_model.params 181 | 182 | XB = np.multiply(param, X) 183 | if rss_score: 184 | rss = np.sum((err)**2) 185 | iters = 0 186 | scores = [] 187 | delta = 1e6 188 | BWs = [] 189 | bw_stable_counter = 0 190 | bws = np.empty(k) 191 | 192 | gwr_sel_hist = [] 193 | 194 | try: 195 | from tqdm.auto import tqdm #if they have it, let users have a progress bar 196 | except ImportError: 197 | 198 | def tqdm(x, desc=''): #otherwise, just passthrough the range 199 | return x 200 | 201 | for iters in tqdm(range(1, max_iter + 1), desc='Backfitting'): 202 | new_XB = np.zeros_like(X) 203 | params = np.zeros_like(X) 204 | 205 | for j in range(k): 206 | temp_y = XB[:, j].reshape((-1, 1)) 207 | temp_y = temp_y + err 208 | temp_X = X[:, j].reshape((-1, 1)) 209 | bw_class = bw_func(temp_y, temp_X) 210 | 211 | if bw_stable_counter >= bws_same_times: 212 | #If in backfitting, all bws not changing in bws_same_times (default 5) iterations 213 | bw = bws[j] 214 | else: 215 | bw = sel_func(bw_class, multi_bw_min[j], multi_bw_max[j]) 216 | gwr_sel_hist.append(deepcopy(bw_class.sel_hist)) 217 | 218 | optim_model = gwr_func(temp_y, temp_X, bw) 219 | err = optim_model.resid_response.reshape((-1, 1)) 220 | param = optim_model.params.reshape((-1, )) 221 | new_XB[:, j] = optim_model.predy.reshape(-1) 222 | params[:, j] = param 223 | bws[j] = bw 224 | 225 | if (iters > 1) and np.all(BWs[-1] == bws): 226 | bw_stable_counter += 1 227 | else: 228 | bw_stable_counter = 0 229 | 230 | 231 | num = np.sum((new_XB - XB)**2) / n 232 | den = np.sum(np.sum(new_XB, axis=1)**2) 233 | score = (num / den)**0.5 234 | XB = new_XB 235 | 236 | if rss_score: 237 | predy = np.sum(np.multiply(params, X), axis=1).reshape((-1, 1)) 238 | new_rss = np.sum((y - predy)**2) 239 | score = np.abs((new_rss - rss) / new_rss) 240 | rss = new_rss 241 | scores.append(deepcopy(score)) 242 | delta = score 243 | BWs.append(deepcopy(bws)) 244 | 245 | if verbose: 246 | print("Current iteration:", iters, ",SOC:", np.round(score, 7)) 247 | print("Bandwidths:", ', '.join([str(bw) for bw in bws])) 248 | 249 | if delta < tol: 250 | break 251 | 252 | opt_bws = BWs[-1] 253 | return (opt_bws, np.array(BWs), np.array(scores), params, err, gwr_sel_hist, bw_gwr) 254 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/__init__.py -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/__pycache__/test_gwr.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/__pycache__/test_gwr.cpython-35.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/__pycache__/test_kernels.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/__pycache__/test_kernels.cpython-35.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/__pycache__/test_parallel.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/__pycache__/test_parallel.cpython-35.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/__pycache__/test_sel_bw.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/__pycache__/test_sel_bw.cpython-35.pyc -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/clearwater/clearwater_BS_F.ctl: -------------------------------------------------------------------------------- 1 | 2 | C:\Users\IEUser\Desktop\clearwater\clearwater\landslides.csv 3 | FORMAT/DELIMITER: 1 4 | Number_of_fields: 10 5 | Number_of_areas: 239 6 | Fields 7 | AreaKey 001 UserID 8 | X 002 X 9 | Y 003 Y 10 | Gmetric 0 11 | Dependent 009 Landslid 12 | Offset 13 | Independent_geo 7 14 | 000 Intercept 15 | 004 Elev 16 | 005 Slope 17 | 006 SinAspct 18 | 007 CosAspct 19 | 008 AbsSouth 20 | 010 DistStrm 21 | Independent_fix 0 22 | Unused_fields 0 23 | MODELTYPE: 2 24 | STANDARDISATION: 0 25 | GTEST: 0 26 | VSL2G: 0 27 | VSG2L: 0 28 | KERNELTYPE: 1 29 | BANDSELECTIONMETHOD: 1 30 | Goldrangeflag: 0 31 | Goldenmax: 32 | Goldenmin: 33 | Fixedbandsize: 34 | IntervalMax: 35 | IntervalMin: 36 | IntervalStep: 37 | Criteria: 38 | summary_output: C:\Users\IEUser\Desktop\clearwater_BS_F_summary.txt 39 | listwise_output: C:\Users\IEUser\Desktop\clearwater_BS_F_listwise.csv 40 | predictflag: 0 41 | prediction_def: 42 | prediction_output: 43 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/clearwater/clearwater_BS_F_summary.txt: -------------------------------------------------------------------------------- 1 | ***************************************************************************** 2 | * Semiparametric Geographically Weighted Regression * 3 | * Release 1.0.90 (GWR 4.0.90) * 4 | * 12 May 2015 * 5 | * (Originally coded by T. Nakaya: 1 Nov 2009) * 6 | * * 7 | * Tomoki Nakaya(1), Martin Charlton(2), Chris Brunsdon (2) * 8 | * Paul Lewis (2), Jing Yao (3), A Stewart Fotheringham (4) * 9 | * (c) GWR4 development team * 10 | * (1) Ritsumeikan University, (2) National University of Ireland, Maynooth, * 11 | * (3) University of Glasgow, (4) Arizona State University * 12 | ***************************************************************************** 13 | 14 | Program began at 7/25/2016 2:12:16 AM 15 | 16 | ***************************************************************************** 17 | Session: 18 | Session control file: C:\Users\IEUser\Desktop\clearwater_BS_F.ctl 19 | ***************************************************************************** 20 | Data filename: C:\Users\IEUser\Desktop\clearwater\clearwater\landslides.csv 21 | Number of areas/points: 239 22 | 23 | Model settings--------------------------------- 24 | Model type: Logistic 25 | Geographic kernel: fixed bi-square 26 | Method for optimal bandwidth search: Golden section search 27 | Criterion for optimal bandwidth: AICc 28 | Number of varying coefficients: 7 29 | Number of fixed coefficients: 0 30 | 31 | Modelling options--------------------------------- 32 | Standardisation of independent variables: OFF 33 | Testing geographical variability of local coefficients: OFF 34 | Local to Global Variable selection: OFF 35 | Global to Local Variable selection: OFF 36 | Prediction at non-regression points: OFF 37 | 38 | Variable settings--------------------------------- 39 | Area key: field1: UserID 40 | Easting (x-coord): field2 : X 41 | Northing (y-coord): field3: Y 42 | Cartesian coordinates: Euclidean distance 43 | Dependent variable: field9: Landslid 44 | Offset variable is not specified 45 | Intercept: varying (Local) intercept 46 | Independent variable with varying (Local) coefficient: field4: Elev 47 | Independent variable with varying (Local) coefficient: field5: Slope 48 | Independent variable with varying (Local) coefficient: field6: SinAspct 49 | Independent variable with varying (Local) coefficient: field7: CosAspct 50 | Independent variable with varying (Local) coefficient: field8: AbsSouth 51 | Independent variable with varying (Local) coefficient: field10: DistStrm 52 | ***************************************************************************** 53 | 54 | ***************************************************************************** 55 | Global regression result 56 | ***************************************************************************** 57 | < Diagnostic information > 58 | Number of parameters: 7 59 | Deviance: 264.959861 60 | Classic AIC: 278.959861 61 | AICc: 279.444709 62 | BIC/MDL: 303.295106 63 | Percent deviance explained 0.186174 64 | 65 | Variable Estimate Standard Error z(Est/SE) Exp(Est) 66 | -------------------- --------------- --------------- --------------- --------------- 67 | Intercept 0.491477 2.249648 0.218469 1.634730 68 | Elev -0.002408 0.000548 -4.394976 0.997595 69 | Slope 0.076097 0.019801 3.842994 1.079067 70 | SinAspct 0.083827 0.213948 0.391807 1.087440 71 | CosAspct -1.191339 1.747013 -0.681929 0.303814 72 | AbsSouth 0.008819 0.023743 0.371420 1.008858 73 | DistStrm -0.001732 0.001605 -1.078779 0.998270 74 | 75 | ***************************************************************************** 76 | GWR (Geographically weighted regression) bandwidth selection 77 | ***************************************************************************** 78 | 79 | Bandwidth search 80 | Limits: 7414.12203822248, 39427.5660570219 81 | Golden section search begins... 82 | Initial values 83 | pL Bandwidth: 7414.122 Criterion: 286.000 84 | p1 Bandwidth: 19642.170 Criterion: 275.989 85 | p2 Bandwidth: 27199.519 Criterion: 277.538 86 | pU Bandwidth: 39427.566 Criterion: 278.558 87 | iter 1 (p1) Bandwidth: 19642.170 Criterion: 275.989 Diff: 7557.349 88 | iter 2 (p2) Bandwidth: 19642.170 Criterion: 275.989 Diff: 4670.699 89 | iter 3 (p1) Bandwidth: 19642.170 Criterion: 275.989 Diff: 2886.650 90 | iter 4 (p2) Bandwidth: 19642.170 Criterion: 275.989 Diff: 1784.048 91 | Best bandwidth size 19642.170 92 | Minimum AICc 275.989 93 | 94 | ***************************************************************************** 95 | GWR (Geographically weighted regression) result 96 | ***************************************************************************** 97 | Bandwidth and geographic ranges 98 | Bandwidth size: 19642.169556 99 | Coordinate Min Max Range 100 | --------------- --------------- --------------- --------------- 101 | X-coord 599444.687500 632987.750000 33543.062500 102 | Y-coord 5172366.500000 5201169.128000 28802.628000 103 | 104 | Diagnostic information 105 | Effective number of parameters (model: trace(S)): 22.450210 106 | Effective number of parameters (variance: trace(S'WSW^-1)): 0.276740 107 | Degree of freedom (model: n - trace(S)): 216.549790 108 | Degree of freedom (residual: n - 2trace(S) + trace(S'WSW^-1)): 194.376319 109 | Deviance: 226.203496 110 | Classic AIC: 271.103916 111 | AICc: 275.988747 112 | BIC/MDL: 349.151253 113 | Percent deviance explained 0.305215 114 | 115 | *********************************************************** 116 | << Geographically varying (Local) coefficients >> 117 | *********************************************************** 118 | Estimates of varying coefficients have been saved in the following file. 119 | Listwise output file: C:\Users\IEUser\Desktop\clearwater_BS_F_listwise.csv 120 | 121 | Summary statistics for varying (Local) coefficients 122 | Variable Mean STD 123 | -------------------- --------------- --------------- 124 | Intercept 1.419798 1.209409 125 | Elev -0.002684 0.001269 126 | Slope 0.067124 0.033621 127 | SinAspct 0.126945 0.320483 128 | CosAspct -0.850236 1.475146 129 | AbsSouth 0.004802 0.017283 130 | DistStrm -0.000926 0.001670 131 | 132 | Variable Min Max Range 133 | -------------------- --------------- --------------- --------------- 134 | Intercept -1.875538 5.601441 7.476978 135 | Elev -0.010165 -0.000721 0.009444 136 | Slope 0.003541 0.140436 0.136895 137 | SinAspct -1.401238 1.019611 2.420849 138 | CosAspct -5.802768 2.280865 8.083634 139 | AbsSouth -0.040024 0.053497 0.093521 140 | DistStrm -0.005188 0.008572 0.013760 141 | 142 | Variable Lwr Quartile Median Upr Quartile 143 | -------------------- --------------- --------------- --------------- 144 | Intercept 0.518742 1.413040 2.277932 145 | Elev -0.003166 -0.002238 -0.001852 146 | Slope 0.035822 0.070416 0.087936 147 | SinAspct 0.019086 0.149218 0.343557 148 | CosAspct -1.602258 -0.745542 0.254795 149 | AbsSouth -0.007011 0.003997 0.015836 150 | DistStrm -0.001969 -0.000893 -0.000285 151 | 152 | Variable Interquartile R Robust STD 153 | -------------------- --------------- --------------- 154 | Intercept 1.759190 1.304070 155 | Elev 0.001314 0.000974 156 | Slope 0.052114 0.038632 157 | SinAspct 0.324471 0.240527 158 | CosAspct 1.857054 1.376615 159 | AbsSouth 0.022847 0.016936 160 | DistStrm 0.001683 0.001248 161 | (Note: Robust STD is given by (interquartile range / 1.349) ) 162 | 163 | ***************************************************************************** 164 | GWR Analysis of Deviance Table 165 | ***************************************************************************** 166 | Source Deviance DOF Deviance/DOF 167 | ------------ ------------------- ---------- ---------------- 168 | Global model 264.960 232.000 1.142 169 | GWR model 226.203 194.376 1.164 170 | Difference 38.756 37.624 1.030 171 | 172 | ***************************************************************************** 173 | Program terminated at 7/25/2016 2:12:25 AM 174 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/clearwater/clearwater_BS_NN.ctl: -------------------------------------------------------------------------------- 1 | 2 | C:\Users\IEUser\Desktop\clearwater\clearwater\landslides.csv 3 | FORMAT/DELIMITER: 1 4 | Number_of_fields: 10 5 | Number_of_areas: 239 6 | Fields 7 | AreaKey 001 UserID 8 | X 002 X 9 | Y 003 Y 10 | Gmetric 0 11 | Dependent 009 Landslid 12 | Offset 13 | Independent_geo 7 14 | 000 Intercept 15 | 004 Elev 16 | 005 Slope 17 | 006 SinAspct 18 | 007 CosAspct 19 | 008 AbsSouth 20 | 010 DistStrm 21 | Independent_fix 0 22 | Unused_fields 0 23 | MODELTYPE: 2 24 | STANDARDISATION: 0 25 | GTEST: 0 26 | VSL2G: 0 27 | VSG2L: 0 28 | KERNELTYPE: 2 29 | BANDSELECTIONMETHOD: 1 30 | Goldrangeflag: 0 31 | Goldenmax: 32 | Goldenmin: 33 | Fixedbandsize: 34 | IntervalMax: 35 | IntervalMin: 36 | IntervalStep: 37 | Criteria: 38 | summary_output: C:\Users\IEUser\Desktop\clearwater_BS_NN_summary.txt 39 | listwise_output: C:\Users\IEUser\Desktop\clearwater_BS_NN_listwise.csv 40 | predictflag: 0 41 | prediction_def: 42 | prediction_output: 43 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/clearwater/clearwater_BS_NN_summary.txt: -------------------------------------------------------------------------------- 1 | ***************************************************************************** 2 | * Semiparametric Geographically Weighted Regression * 3 | * Release 1.0.90 (GWR 4.0.90) * 4 | * 12 May 2015 * 5 | * (Originally coded by T. Nakaya: 1 Nov 2009) * 6 | * * 7 | * Tomoki Nakaya(1), Martin Charlton(2), Chris Brunsdon (2) * 8 | * Paul Lewis (2), Jing Yao (3), A Stewart Fotheringham (4) * 9 | * (c) GWR4 development team * 10 | * (1) Ritsumeikan University, (2) National University of Ireland, Maynooth, * 11 | * (3) University of Glasgow, (4) Arizona State University * 12 | ***************************************************************************** 13 | 14 | Program began at 7/25/2016 2:10:09 AM 15 | 16 | ***************************************************************************** 17 | Session: 18 | Session control file: C:\Users\IEUser\Desktop\clearwater_BS_NN.ctl 19 | ***************************************************************************** 20 | Data filename: C:\Users\IEUser\Desktop\clearwater\clearwater\landslides.csv 21 | Number of areas/points: 239 22 | 23 | Model settings--------------------------------- 24 | Model type: Logistic 25 | Geographic kernel: adaptive bi-square 26 | Method for optimal bandwidth search: Golden section search 27 | Criterion for optimal bandwidth: AICc 28 | Number of varying coefficients: 7 29 | Number of fixed coefficients: 0 30 | 31 | Modelling options--------------------------------- 32 | Standardisation of independent variables: OFF 33 | Testing geographical variability of local coefficients: OFF 34 | Local to Global Variable selection: OFF 35 | Global to Local Variable selection: OFF 36 | Prediction at non-regression points: OFF 37 | 38 | Variable settings--------------------------------- 39 | Area key: field1: UserID 40 | Easting (x-coord): field2 : X 41 | Northing (y-coord): field3: Y 42 | Cartesian coordinates: Euclidean distance 43 | Dependent variable: field9: Landslid 44 | Offset variable is not specified 45 | Intercept: varying (Local) intercept 46 | Independent variable with varying (Local) coefficient: field4: Elev 47 | Independent variable with varying (Local) coefficient: field5: Slope 48 | Independent variable with varying (Local) coefficient: field6: SinAspct 49 | Independent variable with varying (Local) coefficient: field7: CosAspct 50 | Independent variable with varying (Local) coefficient: field8: AbsSouth 51 | Independent variable with varying (Local) coefficient: field10: DistStrm 52 | ***************************************************************************** 53 | 54 | ***************************************************************************** 55 | Global regression result 56 | ***************************************************************************** 57 | < Diagnostic information > 58 | Number of parameters: 7 59 | Deviance: 264.959861 60 | Classic AIC: 278.959861 61 | AICc: 279.444709 62 | BIC/MDL: 303.295106 63 | Percent deviance explained 0.186174 64 | 65 | Variable Estimate Standard Error z(Est/SE) Exp(Est) 66 | -------------------- --------------- --------------- --------------- --------------- 67 | Intercept 0.491477 2.249648 0.218469 1.634730 68 | Elev -0.002408 0.000548 -4.394976 0.997595 69 | Slope 0.076097 0.019801 3.842994 1.079067 70 | SinAspct 0.083827 0.213948 0.391807 1.087440 71 | CosAspct -1.191339 1.747013 -0.681929 0.303814 72 | AbsSouth 0.008819 0.023743 0.371420 1.008858 73 | DistStrm -0.001732 0.001605 -1.078779 0.998270 74 | 75 | ***************************************************************************** 76 | GWR (Geographically weighted regression) bandwidth selection 77 | ***************************************************************************** 78 | 79 | Bandwidth search 80 | Limits: 64, 239 81 | Golden section search begins... 82 | Initial values 83 | pL Bandwidth: 64.000 Criterion: 307.217 84 | p1 Bandwidth: 130.844 Criterion: 278.396 85 | p2 Bandwidth: 172.156 Criterion: 277.767 86 | pU Bandwidth: 239.000 Criterion: 277.888 87 | iter 1 (p2) Bandwidth: 172.156 Criterion: 277.767 Diff: 41.312 88 | iter 2 (p1) Bandwidth: 172.156 Criterion: 277.767 Diff: 25.532 89 | iter 3 (p1) Bandwidth: 156.376 Criterion: 277.695 Diff: 15.780 90 | iter 4 (p2) Bandwidth: 156.376 Criterion: 277.695 Diff: 9.752 91 | iter 5 (p1) Bandwidth: 156.376 Criterion: 277.695 Diff: 6.027 92 | iter 6 (p2) Bandwidth: 156.376 Criterion: 277.695 Diff: 3.725 93 | iter 7 (p2) Bandwidth: 158.678 Criterion: 277.627 Diff: 2.302 94 | iter 8 (p1) Bandwidth: 158.678 Criterion: 277.627 Diff: 1.423 95 | iter 9 (p2) Bandwidth: 158.678 Criterion: 277.627 Diff: 0.879 96 | iter 10 (p1) Bandwidth: 158.678 Criterion: 277.627 Diff: 0.543 97 | Best bandwidth size 158.000 98 | Minimum AICc 277.627 99 | 100 | ***************************************************************************** 101 | GWR (Geographically weighted regression) result 102 | ***************************************************************************** 103 | Bandwidth and geographic ranges 104 | Bandwidth size: 158.678441 105 | Coordinate Min Max Range 106 | --------------- --------------- --------------- --------------- 107 | X-coord 599444.687500 632987.750000 33543.062500 108 | Y-coord 5172366.500000 5201169.128000 28802.628000 109 | 110 | Diagnostic information 111 | Effective number of parameters (model: trace(S)): 24.971219 112 | Effective number of parameters (variance: trace(S'WSW^-1)): 0.187579 113 | Degree of freedom (model: n - trace(S)): 214.028781 114 | Degree of freedom (residual: n - 2trace(S) + trace(S'WSW^-1)): 189.245141 115 | Deviance: 221.595520 116 | Classic AIC: 271.537957 117 | AICc: 277.626646 118 | BIC/MDL: 358.349489 119 | Percent deviance explained 0.319368 120 | 121 | *********************************************************** 122 | << Geographically varying (Local) coefficients >> 123 | *********************************************************** 124 | Estimates of varying coefficients have been saved in the following file. 125 | Listwise output file: C:\Users\IEUser\Desktop\clearwater_BS_NN_listwise.csv 126 | 127 | Summary statistics for varying (Local) coefficients 128 | Variable Mean STD 129 | -------------------- --------------- --------------- 130 | Intercept 1.466570 1.376473 131 | Elev -0.002510 0.001063 132 | Slope 0.066079 0.035704 133 | SinAspct 0.131517 0.281864 134 | CosAspct -0.593534 1.417622 135 | AbsSouth 0.002294 0.017082 136 | DistStrm -0.000804 0.001563 137 | 138 | Variable Min Max Range 139 | -------------------- --------------- --------------- --------------- 140 | Intercept -1.493018 4.863537 6.356555 141 | Elev -0.004867 -0.001109 0.003758 142 | Slope 0.014891 0.130219 0.115328 143 | SinAspct -0.507034 0.619998 1.127033 144 | CosAspct -4.300951 2.327529 6.628479 145 | AbsSouth -0.034552 0.043573 0.078125 146 | DistStrm -0.003933 0.002501 0.006434 147 | 148 | Variable Lwr Quartile Median Upr Quartile 149 | -------------------- --------------- --------------- --------------- 150 | Intercept 0.354199 1.472082 2.646517 151 | Elev -0.003376 -0.002206 -0.001471 152 | Slope 0.027758 0.068542 0.092665 153 | SinAspct -0.081267 0.197064 0.343674 154 | CosAspct -1.539245 -0.367067 0.421195 155 | AbsSouth -0.009257 0.001069 0.014802 156 | DistStrm -0.002113 -0.000712 0.000331 157 | 158 | Variable Interquartile R Robust STD 159 | -------------------- --------------- --------------- 160 | Intercept 2.292318 1.699272 161 | Elev 0.001905 0.001412 162 | Slope 0.064907 0.048115 163 | SinAspct 0.424941 0.315004 164 | CosAspct 1.960439 1.453254 165 | AbsSouth 0.024059 0.017835 166 | DistStrm 0.002444 0.001812 167 | (Note: Robust STD is given by (interquartile range / 1.349) ) 168 | 169 | ***************************************************************************** 170 | GWR Analysis of Deviance Table 171 | ***************************************************************************** 172 | Source Deviance DOF Deviance/DOF 173 | ------------ ------------------- ---------- ---------------- 174 | Global model 264.960 232.000 1.142 175 | GWR model 221.596 189.245 1.171 176 | Difference 43.364 42.755 1.014 177 | 178 | ***************************************************************************** 179 | Program terminated at 7/25/2016 2:10:14 AM 180 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/clearwater/clearwater_GS_F.ctl: -------------------------------------------------------------------------------- 1 | 2 | C:\Users\IEUser\Desktop\clearwater\clearwater\landslides.csv 3 | FORMAT/DELIMITER: 1 4 | Number_of_fields: 10 5 | Number_of_areas: 239 6 | Fields 7 | AreaKey 001 UserID 8 | X 002 X 9 | Y 003 Y 10 | Gmetric 0 11 | Dependent 009 Landslid 12 | Offset 13 | Independent_geo 7 14 | 000 Intercept 15 | 004 Elev 16 | 005 Slope 17 | 006 SinAspct 18 | 007 CosAspct 19 | 008 AbsSouth 20 | 010 DistStrm 21 | Independent_fix 0 22 | Unused_fields 0 23 | MODELTYPE: 2 24 | STANDARDISATION: 0 25 | GTEST: 0 26 | VSL2G: 0 27 | VSG2L: 0 28 | KERNELTYPE: 0 29 | BANDSELECTIONMETHOD: 1 30 | Goldrangeflag: 0 31 | Goldenmax: 32 | Goldenmin: 33 | Fixedbandsize: 34 | IntervalMax: 35 | IntervalMin: 36 | IntervalStep: 37 | Criteria: 38 | summary_output: C:\Users\IEUser\Desktop\clearwater_GS_F_summary.txt 39 | listwise_output: C:\Users\IEUser\Desktop\clearwater_GS_F_listwise.csv 40 | predictflag: 0 41 | prediction_def: 42 | prediction_output: 43 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/clearwater/clearwater_GS_F_summary.txt: -------------------------------------------------------------------------------- 1 | ***************************************************************************** 2 | * Semiparametric Geographically Weighted Regression * 3 | * Release 1.0.90 (GWR 4.0.90) * 4 | * 12 May 2015 * 5 | * (Originally coded by T. Nakaya: 1 Nov 2009) * 6 | * * 7 | * Tomoki Nakaya(1), Martin Charlton(2), Chris Brunsdon (2) * 8 | * Paul Lewis (2), Jing Yao (3), A Stewart Fotheringham (4) * 9 | * (c) GWR4 development team * 10 | * (1) Ritsumeikan University, (2) National University of Ireland, Maynooth, * 11 | * (3) University of Glasgow, (4) Arizona State University * 12 | ***************************************************************************** 13 | 14 | Program began at 7/25/2016 2:13:55 AM 15 | 16 | ***************************************************************************** 17 | Session: 18 | Session control file: C:\Users\IEUser\Desktop\clearwater_GS_F.ctl 19 | ***************************************************************************** 20 | Data filename: C:\Users\IEUser\Desktop\clearwater\clearwater\landslides.csv 21 | Number of areas/points: 239 22 | 23 | Model settings--------------------------------- 24 | Model type: Logistic 25 | Geographic kernel: fixed Gaussian 26 | Method for optimal bandwidth search: Golden section search 27 | Criterion for optimal bandwidth: AICc 28 | Number of varying coefficients: 7 29 | Number of fixed coefficients: 0 30 | 31 | Modelling options--------------------------------- 32 | Standardisation of independent variables: OFF 33 | Testing geographical variability of local coefficients: OFF 34 | Local to Global Variable selection: OFF 35 | Global to Local Variable selection: OFF 36 | Prediction at non-regression points: OFF 37 | 38 | Variable settings--------------------------------- 39 | Area key: field1: UserID 40 | Easting (x-coord): field2 : X 41 | Northing (y-coord): field3: Y 42 | Cartesian coordinates: Euclidean distance 43 | Dependent variable: field9: Landslid 44 | Offset variable is not specified 45 | Intercept: varying (Local) intercept 46 | Independent variable with varying (Local) coefficient: field4: Elev 47 | Independent variable with varying (Local) coefficient: field5: Slope 48 | Independent variable with varying (Local) coefficient: field6: SinAspct 49 | Independent variable with varying (Local) coefficient: field7: CosAspct 50 | Independent variable with varying (Local) coefficient: field8: AbsSouth 51 | Independent variable with varying (Local) coefficient: field10: DistStrm 52 | ***************************************************************************** 53 | 54 | ***************************************************************************** 55 | Global regression result 56 | ***************************************************************************** 57 | < Diagnostic information > 58 | Number of parameters: 7 59 | Deviance: 264.959861 60 | Classic AIC: 278.959861 61 | AICc: 279.444709 62 | BIC/MDL: 303.295106 63 | Percent deviance explained 0.186174 64 | 65 | Variable Estimate Standard Error z(Est/SE) Exp(Est) 66 | -------------------- --------------- --------------- --------------- --------------- 67 | Intercept 0.491477 2.249648 0.218469 1.634730 68 | Elev -0.002408 0.000548 -4.394976 0.997595 69 | Slope 0.076097 0.019801 3.842994 1.079067 70 | SinAspct 0.083827 0.213948 0.391807 1.087440 71 | CosAspct -1.191339 1.747013 -0.681929 0.303814 72 | AbsSouth 0.008819 0.023743 0.371420 1.008858 73 | DistStrm -0.001732 0.001605 -1.078779 0.998270 74 | 75 | ***************************************************************************** 76 | GWR (Geographically weighted regression) bandwidth selection 77 | ***************************************************************************** 78 | 79 | Bandwidth search 80 | Limits: 3707.06101911124, 19713.7830285109 81 | Golden section search begins... 82 | Initial values 83 | pL Bandwidth: 3707.061 Criterion: 291.565 84 | p1 Bandwidth: 9821.085 Criterion: 276.073 85 | p2 Bandwidth: 13599.759 Criterion: 277.212 86 | pU Bandwidth: 19713.783 Criterion: 278.277 87 | iter 1 (p1) Bandwidth: 9821.085 Criterion: 276.073 Diff: 3778.674 88 | iter 2 (p2) Bandwidth: 9821.085 Criterion: 276.073 Diff: 2335.349 89 | iter 3 (p1) Bandwidth: 9821.085 Criterion: 276.073 Diff: 1443.325 90 | iter 4 (p1) Bandwidth: 8929.061 Criterion: 275.951 Diff: 892.024 91 | iter 5 (p2) Bandwidth: 8929.061 Criterion: 275.951 Diff: 551.301 92 | iter 6 (p1) Bandwidth: 8929.061 Criterion: 275.951 Diff: 340.723 93 | Best bandwidth size 8929.061 94 | Minimum AICc 275.951 95 | 96 | ***************************************************************************** 97 | GWR (Geographically weighted regression) result 98 | ***************************************************************************** 99 | Bandwidth and geographic ranges 100 | Bandwidth size: 8929.060733 101 | Coordinate Min Max Range 102 | --------------- --------------- --------------- --------------- 103 | X-coord 599444.687500 632987.750000 33543.062500 104 | Y-coord 5172366.500000 5201169.128000 28802.628000 105 | 106 | Diagnostic information 107 | Effective number of parameters (model: trace(S)): 20.030117 108 | Effective number of parameters (variance: trace(S'WSW^-1)): 0.241124 109 | Degree of freedom (model: n - trace(S)): 218.969883 110 | Degree of freedom (residual: n - 2trace(S) + trace(S'WSW^-1)): 199.180889 111 | Deviance: 232.025375 112 | Classic AIC: 272.085609 113 | AICc: 275.950691 114 | BIC/MDL: 341.719582 115 | Percent deviance explained 0.287333 116 | 117 | *********************************************************** 118 | << Geographically varying (Local) coefficients >> 119 | *********************************************************** 120 | Estimates of varying coefficients have been saved in the following file. 121 | Listwise output file: C:\Users\IEUser\Desktop\clearwater_GS_F_listwise.csv 122 | 123 | Summary statistics for varying (Local) coefficients 124 | Variable Mean STD 125 | -------------------- --------------- --------------- 126 | Intercept 1.105642 0.866015 127 | Elev -0.002520 0.000755 128 | Slope 0.068707 0.025901 129 | SinAspct 0.127146 0.224751 130 | CosAspct -0.888401 1.170416 131 | AbsSouth 0.005735 0.014309 132 | DistStrm -0.001137 0.001074 133 | 134 | Variable Min Max Range 135 | -------------------- --------------- --------------- --------------- 136 | Intercept -1.043824 2.973450 4.017274 137 | Elev -0.004937 -0.001391 0.003546 138 | Slope 0.023690 0.122655 0.098965 139 | SinAspct -0.631698 0.638137 1.269835 140 | CosAspct -4.018434 2.081159 6.099593 141 | AbsSouth -0.035317 0.035965 0.071281 142 | DistStrm -0.004315 0.002921 0.007236 143 | 144 | Variable Lwr Quartile Median Upr Quartile 145 | -------------------- --------------- --------------- --------------- 146 | Intercept 0.459690 0.989106 1.824027 147 | Elev -0.002936 -0.002250 -0.001951 148 | Slope 0.044754 0.071742 0.088308 149 | SinAspct 0.034669 0.118862 0.289318 150 | CosAspct -1.597051 -0.815072 -0.035431 151 | AbsSouth -0.004537 0.005944 0.015533 152 | DistStrm -0.001841 -0.000951 -0.000644 153 | 154 | Variable Interquartile R Robust STD 155 | -------------------- --------------- --------------- 156 | Intercept 1.364337 1.011369 157 | Elev 0.000985 0.000731 158 | Slope 0.043553 0.032286 159 | SinAspct 0.254650 0.188769 160 | CosAspct 1.561620 1.157613 161 | AbsSouth 0.020070 0.014877 162 | DistStrm 0.001196 0.000887 163 | (Note: Robust STD is given by (interquartile range / 1.349) ) 164 | 165 | ***************************************************************************** 166 | GWR Analysis of Deviance Table 167 | ***************************************************************************** 168 | Source Deviance DOF Deviance/DOF 169 | ------------ ------------------- ---------- ---------------- 170 | Global model 264.960 232.000 1.142 171 | GWR model 232.025 199.181 1.165 172 | Difference 32.934 32.819 1.004 173 | 174 | ***************************************************************************** 175 | Program terminated at 7/25/2016 2:14:00 AM 176 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/clearwater/clearwater_GS_NN.ctl: -------------------------------------------------------------------------------- 1 | 2 | C:\Users\IEUser\Desktop\clearwater\clearwater\landslides.csv 3 | FORMAT/DELIMITER: 1 4 | Number_of_fields: 10 5 | Number_of_areas: 239 6 | Fields 7 | AreaKey 001 UserID 8 | X 002 X 9 | Y 003 Y 10 | Gmetric 0 11 | Dependent 009 Landslid 12 | Offset 13 | Independent_geo 7 14 | 000 Intercept 15 | 004 Elev 16 | 005 Slope 17 | 006 SinAspct 18 | 007 CosAspct 19 | 008 AbsSouth 20 | 010 DistStrm 21 | Independent_fix 0 22 | Unused_fields 0 23 | MODELTYPE: 2 24 | STANDARDISATION: 0 25 | GTEST: 0 26 | VSL2G: 0 27 | VSG2L: 0 28 | KERNELTYPE: 3 29 | BANDSELECTIONMETHOD: 1 30 | Goldrangeflag: 0 31 | Goldenmax: 32 | Goldenmin: 33 | Fixedbandsize: 34 | IntervalMax: 35 | IntervalMin: 36 | IntervalStep: 37 | Criteria: 38 | summary_output: C:\Users\IEUser\Desktop\clearwater_GS_NN_summary.txt 39 | listwise_output: C:\Users\IEUser\Desktop\clearwater_GS_NN_listwise.csv 40 | predictflag: 0 41 | prediction_def: 42 | prediction_output: 43 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/clearwater/clearwater_GS_NN_summary.txt: -------------------------------------------------------------------------------- 1 | ***************************************************************************** 2 | * Semiparametric Geographically Weighted Regression * 3 | * Release 1.0.90 (GWR 4.0.90) * 4 | * 12 May 2015 * 5 | * (Originally coded by T. Nakaya: 1 Nov 2009) * 6 | * * 7 | * Tomoki Nakaya(1), Martin Charlton(2), Chris Brunsdon (2) * 8 | * Paul Lewis (2), Jing Yao (3), A Stewart Fotheringham (4) * 9 | * (c) GWR4 development team * 10 | * (1) Ritsumeikan University, (2) National University of Ireland, Maynooth, * 11 | * (3) University of Glasgow, (4) Arizona State University * 12 | ***************************************************************************** 13 | 14 | Program began at 7/25/2016 2:13:25 AM 15 | 16 | ***************************************************************************** 17 | Session: 18 | Session control file: C:\Users\IEUser\Desktop\clearwater_GS_NN.ctl 19 | ***************************************************************************** 20 | Data filename: C:\Users\IEUser\Desktop\clearwater\clearwater\landslides.csv 21 | Number of areas/points: 239 22 | 23 | Model settings--------------------------------- 24 | Model type: Logistic 25 | Geographic kernel: adaptive Gaussian 26 | Method for optimal bandwidth search: Golden section search 27 | Criterion for optimal bandwidth: AICc 28 | Number of varying coefficients: 7 29 | Number of fixed coefficients: 0 30 | 31 | Modelling options--------------------------------- 32 | Standardisation of independent variables: OFF 33 | Testing geographical variability of local coefficients: OFF 34 | Local to Global Variable selection: OFF 35 | Global to Local Variable selection: OFF 36 | Prediction at non-regression points: OFF 37 | 38 | Variable settings--------------------------------- 39 | Area key: field1: UserID 40 | Easting (x-coord): field2 : X 41 | Northing (y-coord): field3: Y 42 | Cartesian coordinates: Euclidean distance 43 | Dependent variable: field9: Landslid 44 | Offset variable is not specified 45 | Intercept: varying (Local) intercept 46 | Independent variable with varying (Local) coefficient: field4: Elev 47 | Independent variable with varying (Local) coefficient: field5: Slope 48 | Independent variable with varying (Local) coefficient: field6: SinAspct 49 | Independent variable with varying (Local) coefficient: field7: CosAspct 50 | Independent variable with varying (Local) coefficient: field8: AbsSouth 51 | Independent variable with varying (Local) coefficient: field10: DistStrm 52 | ***************************************************************************** 53 | 54 | ***************************************************************************** 55 | Global regression result 56 | ***************************************************************************** 57 | < Diagnostic information > 58 | Number of parameters: 7 59 | Deviance: 264.959861 60 | Classic AIC: 278.959861 61 | AICc: 279.444709 62 | BIC/MDL: 303.295106 63 | Percent deviance explained 0.186174 64 | 65 | Variable Estimate Standard Error z(Est/SE) Exp(Est) 66 | -------------------- --------------- --------------- --------------- --------------- 67 | Intercept 0.491477 2.249648 0.218469 1.634730 68 | Elev -0.002408 0.000548 -4.394976 0.997595 69 | Slope 0.076097 0.019801 3.842994 1.079067 70 | SinAspct 0.083827 0.213948 0.391807 1.087440 71 | CosAspct -1.191339 1.747013 -0.681929 0.303814 72 | AbsSouth 0.008819 0.023743 0.371420 1.008858 73 | DistStrm -0.001732 0.001605 -1.078779 0.998270 74 | 75 | ***************************************************************************** 76 | GWR (Geographically weighted regression) bandwidth selection 77 | ***************************************************************************** 78 | 79 | Bandwidth search 80 | Limits: 64, 239 81 | Golden section search begins... 82 | Initial values 83 | pL Bandwidth: 64.000 Criterion: 276.386 84 | p1 Bandwidth: 67.725 Criterion: 276.407 85 | p2 Bandwidth: 70.027 Criterion: 276.568 86 | pU Bandwidth: 73.752 Criterion: 276.533 87 | iter 1 (p1) Bandwidth: 67.725 Criterion: 276.407 Diff: 2.302 88 | iter 2 (p2) Bandwidth: 67.725 Criterion: 276.407 Diff: 1.423 89 | iter 3 (p1) Bandwidth: 67.725 Criterion: 276.407 Diff: 0.879 90 | The lower limit in your search has been selected as the optimal bandwidth size. 91 | A new sesssion is recommended to try with a smaller lowest limit of the bandwidth search. 92 | Best bandwidth size 64.000 93 | Minimum AICc 276.386 94 | 95 | ***************************************************************************** 96 | GWR (Geographically weighted regression) result 97 | ***************************************************************************** 98 | Bandwidth and geographic ranges 99 | Bandwidth size: 64.000000 100 | Coordinate Min Max Range 101 | --------------- --------------- --------------- --------------- 102 | X-coord 599444.687500 632987.750000 33543.062500 103 | Y-coord 5172366.500000 5201169.128000 28802.628000 104 | 105 | Diagnostic information 106 | Effective number of parameters (model: trace(S)): 16.605439 107 | Effective number of parameters (variance: trace(S'WSW^-1)): 0.186461 108 | Degree of freedom (model: n - trace(S)): 222.394561 109 | Degree of freedom (residual: n - 2trace(S) + trace(S'WSW^-1)): 205.975584 110 | Deviance: 240.533728 111 | Classic AIC: 273.744605 112 | AICc: 276.385556 113 | BIC/MDL: 331.472808 114 | Percent deviance explained 0.261199 115 | 116 | *********************************************************** 117 | << Geographically varying (Local) coefficients >> 118 | *********************************************************** 119 | Estimates of varying coefficients have been saved in the following file. 120 | Listwise output file: C:\Users\IEUser\Desktop\clearwater_GS_NN_listwise.csv 121 | 122 | Summary statistics for varying (Local) coefficients 123 | Variable Mean STD 124 | -------------------- --------------- --------------- 125 | Intercept 0.939810 0.667065 126 | Elev -0.002323 0.000389 127 | Slope 0.069215 0.021083 128 | SinAspct 0.130582 0.146202 129 | CosAspct -0.779778 0.852770 130 | AbsSouth 0.004892 0.010695 131 | DistStrm -0.001187 0.000715 132 | 133 | Variable Min Max Range 134 | -------------------- --------------- --------------- --------------- 135 | Intercept -0.441478 1.976117 2.417595 136 | Elev -0.003157 -0.001675 0.001482 137 | Slope 0.035256 0.104522 0.069266 138 | SinAspct -0.147649 0.380231 0.527880 139 | CosAspct -2.541313 0.774141 3.315454 140 | AbsSouth -0.016221 0.024797 0.041018 141 | DistStrm -0.002797 0.000078 0.002875 142 | 143 | Variable Lwr Quartile Median Upr Quartile 144 | -------------------- --------------- --------------- --------------- 145 | Intercept 0.415644 1.050445 1.556356 146 | Elev -0.002640 -0.002280 -0.002005 147 | Slope 0.048848 0.071095 0.085036 148 | SinAspct 0.016837 0.116498 0.261812 149 | CosAspct -1.453046 -0.747009 0.010831 150 | AbsSouth -0.004595 0.005464 0.013481 151 | DistStrm -0.001758 -0.000978 -0.000639 152 | 153 | Variable Interquartile R Robust STD 154 | -------------------- --------------- --------------- 155 | Intercept 1.140712 0.845599 156 | Elev 0.000636 0.000471 157 | Slope 0.036188 0.026825 158 | SinAspct 0.244975 0.181597 159 | CosAspct 1.463877 1.085157 160 | AbsSouth 0.018077 0.013400 161 | DistStrm 0.001119 0.000830 162 | (Note: Robust STD is given by (interquartile range / 1.349) ) 163 | 164 | ***************************************************************************** 165 | GWR Analysis of Deviance Table 166 | ***************************************************************************** 167 | Source Deviance DOF Deviance/DOF 168 | ------------ ------------------- ---------- ---------------- 169 | Global model 264.960 232.000 1.142 170 | GWR model 240.534 205.976 1.168 171 | Difference 24.426 26.024 0.939 172 | 173 | ***************************************************************************** 174 | Program terminated at 7/25/2016 2:13:29 AM 175 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/clearwater/quads.dbf: -------------------------------------------------------------------------------- 1 | k!kWAREAF PERIMETERF QUADS_N QUADS_IDN QUADNAMEC(ABBRCGPS1CGPS_IDN 5.05341243931e+007 2.95176869652e+004 2 0BUZZARD ROOST buro40 40 8.78342592342e+007 3.74941591227e+004 3 0MALLARD PEAK mapk41 41 8.61071223428e+007 3.71316332562e+004 4 0POLE MTN pomt42 42 8.42356175232e+007 3.67388373243e+004 5 0BACON PEAK bapk43 43 2.88543152422e+006 1.81437418009e+004 6 0CHAMBERLAIN MTN chmt44 44 1.21391819636e+006 2.11143955817e+004 7 0MOOSE MTN momt66 66 1.32388270904e+008 4.67873330465e+004 8 0ELIZABETH LAKE ellk65 65 1.32513490580e+008 4.68621241957e+004 9 0THE NUB thnu64 64 1.32506356676e+008 4.68608608809e+004 10 0SHEEP MTN shmt63 63 7.78457724226e+007 3.89932935277e+004 11 0THOMPSON POINT thpt62 62 5.89737365297e+007 3.13543264001e+004 12 0JUNCTION MTN jumt87 87 5.80250585277e+007 3.12568019655e+004 13 0POT MTN potm86 86 5.62808686586e+007 3.08910959896e+004 14 0CLARKE MTN clmt85 85 3.32374224875e+007 2.30616398096e+004 15 0BROWNS ROCK brro84 84 -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/clearwater/quads.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/clearwater/quads.shp -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/clearwater/quads.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/clearwater/quads.shx -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/clearwater/streams.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/clearwater/streams.dbf -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/clearwater/streams.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/clearwater/streams.shp -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/clearwater/streams.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/clearwater/streams.shx -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/local_cn.csv: -------------------------------------------------------------------------------- 1 | 0 2 | 14.917944540554776 3 | 17.202174013986127 4 | 15.314380034815976 5 | 15.124457297204389 6 | 12.137935858749644 7 | 8.550494172586605 8 | 8.167571317669704 9 | 8.497635049625734 10 | 16.72745024875315 11 | 17.795481262405488 12 | 12.390088597116089 13 | 10.655146147852333 14 | 13.40740559199105 15 | 17.70693372380939 16 | 12.55601727607334 17 | 12.827931388644462 18 | 12.405378922480578 19 | 11.999216927451837 20 | 14.560436409922469 21 | 12.857554679449049 22 | 13.51945053560574 23 | 9.531609093830273 24 | 8.96380871325999 25 | 13.752802672154422 26 | 12.149143351072636 27 | 14.597577579624897 28 | 8.876345975952137 29 | 8.34824128637838 30 | 8.947305830260074 31 | 14.547684069657947 32 | 9.88742755323822 33 | 15.812649116805213 34 | 8.312020835449172 35 | 17.569289147729464 36 | 17.07476449915754 37 | 12.909557853455425 38 | 17.651611344614448 39 | 10.367191083603284 40 | 13.313394945220917 41 | 13.222022555810259 42 | 9.107236665362246 43 | 8.497079678780517 44 | 16.34705076152099 45 | 8.481755852721882 46 | 12.600200859673947 47 | 12.142161522508323 48 | 14.77756280938454 49 | 8.924356186291345 50 | 14.95891646541822 51 | 16.082885232855915 52 | 12.322512202887504 53 | 10.570189387812642 54 | 13.43694237102368 55 | 13.347992468571867 56 | 8.95291041200043 57 | 10.388255892999098 58 | 8.760581873541506 59 | 8.229699252604032 60 | 9.304342029124872 61 | 8.753874532175574 62 | 8.813505758593367 63 | 12.378609109351988 64 | 12.678829080678975 65 | 8.660714365244964 66 | 16.913839701468557 67 | 10.991909111770813 68 | 7.980102437472144 69 | 8.984995202482256 70 | 8.421330372071004 71 | 12.227511653693382 72 | 8.97236767653874 73 | 13.194254083736977 74 | 10.176662043008676 75 | 10.40303920420578 76 | 10.75295063651246 77 | 11.36114948956172 78 | 17.064682862976532 79 | 8.387535226390096 80 | 11.068545588709929 81 | 16.342047727679166 82 | 12.159300336505735 83 | 12.589505128610686 84 | 12.441434434506045 85 | 12.794153052230795 86 | 12.896945870643098 87 | 17.32609020244753 88 | 12.558593398822937 89 | 13.807493575426957 90 | 12.732144196349324 91 | 12.310344564513434 92 | 12.940469566688035 93 | 17.34857960143701 94 | 8.731099558924276 95 | 12.691157314593143 96 | 12.568653960869653 97 | 13.114682109861763 98 | 9.416264158942019 99 | 14.381697212592268 100 | 11.993749477341883 101 | 15.369969887591774 102 | 16.29080768651488 103 | 13.361917831214077 104 | 15.537549666723546 105 | 9.989124508422952 106 | 8.867994631427045 107 | 14.27465399850002 108 | 9.167967870859556 109 | 9.062146102200717 110 | 10.400989950634196 111 | 8.553025738905802 112 | 12.446046265743158 113 | 8.522939294754849 114 | 14.183023899018517 115 | 12.437638252442397 116 | 8.741008838919848 117 | 11.727254510425508 118 | 11.631647937009093 119 | 14.576581576669609 120 | 9.384596478833483 121 | 14.316830129822092 122 | 12.605868808170273 123 | 8.56719421057057 124 | 13.793372685012113 125 | 12.380392492581217 126 | 15.817397736099089 127 | 11.756367154779104 128 | 9.2043778299211 129 | 14.665189987044254 130 | 13.31319313465098 131 | 13.833627650438698 132 | 12.122543569270649 133 | 13.938460917949747 134 | 13.81916091265934 135 | 16.54111423008214 136 | 14.067179846754659 137 | 17.5151606026457 138 | 16.914193899061793 139 | 14.83335028196861 140 | 9.162451565668002 141 | 14.320647863733587 142 | 11.444225689366094 143 | 14.869724514854312 144 | 10.928026279697667 145 | 8.999398233839923 146 | 13.70132326373081 147 | 8.936449352204429 148 | 8.32112332324215 149 | 14.566142594773757 150 | 12.440793051678462 151 | 11.630112963895415 152 | 13.296394748178901 153 | 14.124018100507596 154 | 15.618452762413167 155 | 8.865669155301248 156 | 8.88789504809066 157 | 14.044283073383438 158 | 11.652731620853876 159 | 10.905398901007771 160 | 15.76376488899454 161 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/local_corr.csv: -------------------------------------------------------------------------------- 1 | 0,1,2 2 | 0.197356682,-0.081281934,0.495730029 3 | 0.102400513,-0.170909903,0.5681805679999999 4 | 0.16761995400000002,-0.120834679,0.504011794 5 | 0.214130874,0.101481219,0.6764352020000001 6 | 0.279940504,0.19155454,0.758693105 7 | 0.20391845,-0.201492588,0.6717680290000001 8 | 0.221658949,-0.168599312,0.6834239670000001 9 | 0.25346874,-0.299580687,0.5348449820000001 10 | 0.128305799,-0.07500773,0.541770072 11 | 0.097781916,-0.107553712,0.622806897 12 | 0.270298562,0.166815352,0.754372755 13 | 0.181352975,0.14683426900000002,0.5366056260000001 14 | 0.190453017,-0.162914787,0.4905382820000001 15 | 0.120485523,-0.056024425,0.6642131689999999 16 | 0.2771416,-0.021408737,0.5179776 17 | 0.291452084,0.057495466,0.548197688 18 | 0.254191273,0.154055,0.664941816 19 | 0.302476093,0.082717406,0.8037318259999999 20 | 0.230487531,0.130044087,0.69888747 21 | 0.198191964,-0.177897437,0.4843274970000001 22 | 0.282850256,0.082605652,0.538847524 23 | 0.302046757,-0.13015876099999998,0.685051317 24 | 0.254047762,-0.329073024,0.495965717 25 | 0.158005123,-0.184227114,0.517382935 26 | 0.286692014,-0.027075028,0.522959627 27 | 0.285824666,0.152900925,0.805469702 28 | 0.264836416,-0.321676333,0.501437259 29 | 0.242079604,-0.269338369,0.574750776 30 | 0.213222333,-0.104208308,0.732612122 31 | 0.243822829,0.145135704,0.7238260059999999 32 | 0.27423054,-0.093338151,0.723504402 33 | 0.106216538,-0.17610529100000002,0.584708641 34 | 0.25112841,-0.255138067,0.5867616729999999 35 | 0.113948455,-0.151747553,0.5475997810000001 36 | 0.147459724,-0.007120099,0.658358639 37 | 0.208614018,0.125516143,0.767903212 38 | 0.115327055,-0.06771577299999999,0.6473366 39 | 0.312072225,-0.045231365,0.7469481259999999 40 | 0.263495548,0.140647508,0.778115698 41 | 0.19119342600000006,0.08458334199999999,0.612941243 42 | 0.262953012,-0.33330449300000003,0.486038532 43 | 0.230099223,-0.258385989,0.595288193 44 | 0.198172529,0.072929302,0.682452085 45 | 0.248949572,-0.160149119,0.675742903 46 | 0.186466839,0.092499752,0.460035288 47 | 0.183498434,0.107269268,0.6395461020000001 48 | 0.212717341,0.101466437,0.666455117 49 | 0.272208781,-0.190312987,0.641172701 50 | 0.231241019,0.126152621,0.7009008090000001 51 | 0.099252238,-0.159786246,0.615864692 52 | 0.29753412,0.02684871,0.548352528 53 | 0.17825423699999998,-0.091502648,0.763622444 54 | 0.279560097,0.144487946,0.556987962 55 | 0.27484387600000004,0.016733401000000002,0.518928553 56 | 0.235397253,-0.29481332,0.550398921 57 | 0.296066473,-0.055429599,0.7434787840000001 58 | 0.266827914,-0.305921314,0.5204908429999999 59 | 0.230786293,-0.250019929,0.603434049 60 | 0.185226165,-0.179276725,0.704371483 61 | 0.257228894,-0.196214178,0.64349547 62 | 0.238575947,-0.304030283,0.537841904 63 | 0.24750839,0.184365084,0.734841458 64 | 0.225088461,-0.13535575,0.488376963 65 | 0.250864618,-0.310747678,0.521825919 66 | 0.173069799,0.035496029,0.6781827909999999 67 | 0.247809644,0.060932247,0.7893188040000001 68 | 0.230660322,-0.217624602,0.634792174 69 | 0.201840779,-0.225841459,0.653090022 70 | 0.217247013,-0.227023613,0.637224616 71 | 0.262145867,0.161805175,0.76931197 72 | 0.28334718600000003,-0.209403853,0.61902537 73 | 0.341224658,0.140166072,0.83494908 74 | 0.169111261,-0.14716196199999998,0.738354854 75 | 0.326378642,-0.017695843,0.7633903459999999 76 | 0.286379406,-0.007165702,0.7709996290000001 77 | 0.17951000399999995,0.122014087,0.63331365 78 | 0.117817513,-0.078286114,0.579871509 79 | 0.2130438,-0.172784651,0.687858565 80 | 0.293043788,0.093333931,0.800386348 81 | 0.174909746,-0.064687758,0.492747283 82 | 0.249510697,0.195707606,0.6850101129999999 83 | 0.274202992,0.135066616,0.603593245 84 | 0.259634585,0.201892304,0.572064633 85 | 0.296911855,0.18312306,0.7858110640000001 86 | 0.315841451,0.109973743,0.8109435159999999 87 | 0.093925268,-0.132568905,0.624517255 88 | 0.240179617,0.185974771,0.497498079 89 | 0.213207296,0.114095936,0.666719333 90 | 0.264142741,-0.048160224,0.5067571270000001 91 | 0.182914112,0.029055685,0.788753569 92 | 0.245506135,-0.077935575,0.498613163 93 | 0.097588382,-0.116902087,0.642913352 94 | 0.225151556,-0.263036227,0.594791501 95 | 0.219056913,0.124583772,0.771531251 96 | 0.246591802,-0.096780474,0.496180715 97 | 0.212470835,0.12929245,0.73572252 98 | 0.193736761,-0.131203296,0.731248589 99 | 0.26896253800000003,0.147148253,0.7956631909999999 100 | 0.333858221,0.07877583099999999,0.8118681640000001 101 | 0.218661163,0.106205574,0.688172826 102 | 0.192156397,0.062170725,0.671569729 103 | 0.311475915,0.150981241,0.810461708 104 | 0.231007648,0.054247173,0.487622653 105 | 0.26564729600000003,0.045964098,0.785207542 106 | 0.245598994,-0.321712697,0.511300755 107 | 0.312310463,0.152164197,0.8255269940000001 108 | 0.261211427,-0.027493056,0.756645445 109 | 0.225655966,-0.069792406,0.745625137 110 | 0.208252617,-0.039404427,0.77085561 111 | 0.263199029,-0.263953737,0.571065677 112 | 0.217024747,0.129238697,0.723622612 113 | 0.239951023,-0.293883204,0.5493495039999999 114 | 0.17739844300000002,-0.14317091699999998,0.50192844 115 | 0.321559892,0.083130215,0.808336837 116 | 0.271343137,-0.261717278,0.569019308 117 | 0.164822881,0.080460213,0.528624809 118 | 0.284576297,0.13496559,0.796696766 119 | 0.258346492,0.156661415,0.758217003 120 | 0.196334123,-0.237380343,0.647090988 121 | 0.243789274,0.148527157,0.7327957740000001 122 | 0.231476537,0.157972224,0.725654591 123 | 0.245378154,-0.112802501,0.711589088 124 | 0.23333344600000006,0.13968355,0.75437305 125 | 0.281717991,0.101306557,0.603065405 126 | 0.211669445,0.094159007,0.6888328990000001 127 | 0.308301518,0.037933147,0.7908632059999999 128 | 0.188500766,-0.194181387,0.69165032 129 | 0.263911608,0.154250699,0.780052442 130 | 0.217311085,0.133633047,0.709943179 131 | 0.313943346,0.140520318,0.825145699 132 | 0.234325617,0.099837152,0.7859640240000001 133 | 0.255694643,0.004236435,0.50847512 134 | 0.270031294,0.140369905,0.794937511 135 | 0.149161873,-0.051832609,0.496253686 136 | 0.229980445,0.139477806,0.705251038 137 | 0.144746816,-0.008844277,0.676279822 138 | 0.134337277,-0.034972931,0.628682848 139 | 0.248819006,0.033576443,0.50173728 140 | 0.212835056,-0.252750219,0.617545782 141 | 0.259521652,0.135789713,0.508580884 142 | 0.349137195,0.07198415,0.81096494 143 | 0.17403938600000002,0.034320306,0.606167338 144 | 0.227429686,0.17661189300000002,0.669879336 145 | 0.221852863,-0.268787445,0.591798672 146 | 0.313834617,0.132150063,0.820191268 147 | 0.259156142,-0.33152049,0.491045377 148 | 0.237150645,-0.105959792,0.7175928140000001 149 | 0.14141768300000002,-0.17643932699999998,0.533279535 150 | 0.239179795,0.151110345,0.759585512 151 | 0.256194117,0.220549746,0.654525084 152 | 0.216511822,-0.117539125,0.492501708 153 | 0.239731848,0.146530731,0.744209803 154 | 0.204176352,0.05877884,0.462714401 155 | 0.214688372,-0.241821969,0.626412371 156 | 0.25091498,-0.328738519,0.498909014 157 | 0.17019715800000002,0.022916041,0.541893441 158 | 0.199244606,0.012719162,0.7877866579999999 159 | 0.248484876,0.207467427,0.668306185 160 | 0.17584274,0.037949361,0.642420136 161 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/local_vif.csv: -------------------------------------------------------------------------------- 1 | 0,1,2 2 | 1.0887150248153694,1.4339007770606174,1.3872158210480035 3 | 1.0964784079867413,1.5719076975893878,1.6022262259512663 4 | 1.0924266833876255,1.4430514536655203,1.423288292100115 5 | 1.0518772798598857,1.9192046718002929,1.8502600272152898 6 | 1.086235723711835,2.4656358825770694,2.358970198356252 7 | 1.3339924878778668,2.332365108651737,2.329974226321877 8 | 1.3181849372024477,2.4031496275809583,2.351931796607029 9 | 1.491354780063629,1.9014289527098946,1.9547006024196736 10 | 1.0482462264475214,1.4754005338263232,1.459322312772623 11 | 1.0592317304717622,1.7104377735366545,1.7139099285146517 12 | 1.0825484162009162,2.442262336109119,2.3286269896254908 13 | 1.0377025101129989,1.4259153882418723,1.4094058130352571 14 | 1.139996249703876,1.461390551299472,1.4467818462508193 15 | 1.0500237411273667,1.8731011266201267,1.8517218314215087 16 | 1.1286658625610524,1.5418201191045582,1.4240495124337074 17 | 1.1109869213413324,1.5830551512661475,1.4533881191084441 18 | 1.0695356287363864,1.871736028989823,1.7933588522217123 19 | 1.1964013352399934,3.3563968928728856,3.0703218060894186 20 | 1.058210045943328,2.0336259296281654,1.958715309916204 21 | 1.159128905900098,1.4664305791373933,1.4548721705651753 22 | 1.0951357828145918,1.5326895084377163,1.4197557860581889 23 | 1.4395236192704477,2.666522896054462,2.4650105196902725 24 | 1.5132933294179474,1.7896392534214094,1.8774418665434587 25 | 1.1383920668020118,1.5017521346302585,1.5157023391411222 26 | 1.1432705026984693,1.5724867413949377,1.444299176192975 27 | 1.1095312992431736,3.085235328429906,2.9010064860170486 28 | 1.5292034470417,1.8314722522120301,1.8995757077770883 29 | 1.4445846937129971,2.0006971713621167,2.0307696898969048 30 | 1.2373926383974256,2.641937296954118,2.5495109723329294 31 | 1.0655459323319427,2.1910389670309307,2.1051257916472808 32 | 1.3401462161020103,2.7877345065941777,2.6007479552802293 33 | 1.1080388935566523,1.6314381046645736,1.6646584722656375 34 | 1.4495350614716347,2.066729835588781,2.0712173183685842 35 | 1.0851679306412676,1.514251122677053,1.5298172991447458 36 | 1.0426538557421996,1.8402178328355603,1.800294722290197 37 | 1.0487135611668748,2.515549070860523,2.444585596634424 38 | 1.0506302661286437,1.8001602388481424,1.7843997471277144 39 | 1.3748197003728466,3.1036072439097544,2.8070927738474314 40 | 1.086881138156,2.70033878597113,2.563566278251303 41 | 1.0397798681089603,1.6535894792452077,1.6046226566831394 42 | 1.5326391883308352,1.7837589511685579,1.8679345856473992 43 | 1.4185412039485017,2.050447857642913,2.0808071501681713 44 | 1.0488121511956945,1.9526738071574152,1.8860188522184411 45 | 1.352123069326351,2.424573425002068,2.334174634720617 46 | 1.036083832726471,1.3029695468836189,1.2685191582591215 47 | 1.0350293507793316,1.7312230970983105,1.6924038918784803 48 | 1.0506083989306885,1.8706758398921113,1.804609496298241 49 | 1.4288456534175074,2.338427464490205,2.24652242333432 50 | 1.0593323580980818,2.049136324218823,1.970930408673963 51 | 1.0970615393646477,1.7223028153161712,1.750017215976022 52 | 1.1300638080307759,1.6148060197730914,1.4729145646935569 53 | 1.184916278430948,2.8185404396235505,2.752024491233705 54 | 1.0849946585077885,1.5401540911218836,1.4500576371214946 55 | 1.1076997393095152,1.5154914971274829,1.4014049506508874 56 | 1.4572476075184588,1.9088588146120036,1.9747177696623859 57 | 1.3466630974984306,3.0018058789069113,2.747121882673675 58 | 1.5210569822772853,1.8909954687009243,1.9377079275535651 59 | 1.411603839465429,2.0811959218858385,2.1017253936773783 60 | 1.2898599885038353,2.477675713509432,2.472124229931935 61 | 1.407465203119527,2.3096883789708396,2.2432282054150283 62 | 1.4704194797898504,1.8776602473713624,1.9511390700455318 63 | 1.0652733847192477,2.2370570845879474,2.173906190678953 64 | 1.1489940270059185,1.4812356695259625,1.4324329991112046 65 | 1.494730656511212,1.8557064119751177,1.9247864426798842 66 | 1.0442403853561018,1.9310984504202817,1.8756191787894263 67 | 1.1229870782188758,2.967876574303439,2.7960012251624766 68 | 1.3796569329286967,2.2013904685054526,2.1878866169025275 69 | 1.35833525259293,2.2478011629579915,2.2721141567618464 70 | 1.3737505855236516,2.193718823504244,2.2037649178401173 71 | 1.0783001475300906,2.5726959992199876,2.4603123874736665 72 | 1.471344785736923,2.2808188074947155,2.193904491506629 73 | 1.227907212862342,3.9747175746035706,3.58230408394256 74 | 1.2365403118011022,2.6597968198603805,2.6409238499873062 75 | 1.3834927974615094,3.3148201175668612,2.9626432044982507 76 | 1.2660652272690973,3.1216134627796652,2.865747214187682 77 | 1.0334204477214557,1.699802928023562,1.6698891179122486 78 | 1.048506290761363,1.5699914309319194,1.5577454113741847 79 | 1.3139490641241667,2.4195127422654306,2.38077360847333 80 | 1.164636472928886,3.2124370450653696,2.962376018807711 81 | 1.0645721132811983,1.4000491855337098,1.3629200407977717 82 | 1.0677070017605572,1.9346032881428123,1.8864159199251544 83 | 1.08300705062612,1.6726305705123372,1.5756139368918063 84 | 1.0771720559195925,1.535902167160445,1.4932316949302002 85 | 1.1046590217174779,2.791144087568425,2.633394575380721 86 | 1.1935293758996433,3.443912876930809,3.1383180381552425 87 | 1.0738499088004743,1.7295331563068832,1.7449417959890694 88 | 1.0678746804991224,1.3700285099399292,1.3372475727620596 89 | 1.049179367304024,1.8641739331909648,1.8029035100378141 90 | 1.129112981395773,1.5157404884650436,1.413263104202426 91 | 1.0736406829810659,2.838914189458415,2.746249486289099 92 | 1.1282782425467444,1.4924775726753325,1.4110919880456019 93 | 1.0689839824344813,1.7972433599767774,1.8047917880504416 94 | 1.4174943862602043,2.041741877096976,2.08231041128771 95 | 1.0558125886146852,2.568133640422185,2.483445197898565 96 | 1.1422187629775384,1.5010787541262975,1.4231315878945627 97 | 1.0490276523276907,2.2486673627756932,2.1836570324131817 98 | 1.2462107117432122,2.6323287089484233,2.5779038841764526 99 | 1.092325950983386,2.9125531286969233,2.7616535714480226 100 | 1.2819130342464258,3.7373709558016346,3.341535020892877 101 | 1.054336103968315,1.9802576434346923,1.9070873994640292 102 | 1.0471977701065842,1.9001117567153494,1.8370524497311536 103 | 1.145494878881129,3.2620632487591963,3.014298809136777 104 | 1.061389289229539,1.3883919614106008,1.3181801545409242 105 | 1.1621674940446238,3.024422627123659,2.8169450565595837 106 | 1.4952187766959735,1.8149427236492888,1.9023598971520423 107 | 1.1528531882455522,3.535766936519191,3.266528943876643 108 | 1.2297107785805588,2.874425072111521,2.680324969266314 109 | 1.2173378495133897,2.7281317285954994,2.6018873247248053 110 | 1.165341400109661,2.8673845251815733,2.7472942369534463 111 | 1.4791388252054531,2.042020450230849,2.04289370186839 112 | 1.0512182026978028,2.1698666957202235,2.1027886601123327 113 | 1.464396699662687,1.9162011987092942,1.9765854790083266 114 | 1.1155144266366488,1.4606278335175509,1.4442660094554145 115 | 1.2400590120097335,3.5531431532114577,3.207914153116636 116 | 1.4918439802921897,2.0550484203478687,2.0437282431907517 117 | 1.0279904430777878,1.4174271790643784,1.3879056145057447 118 | 1.1161116165926557,2.9998851799523276,2.808094916197376 119 | 1.0756870058567722,2.4682884420536704,2.3615056471733755 120 | 1.364298177403659,2.2148288269357135,2.256612444249136 121 | 1.0654082571366827,2.2502844808854032,2.1642877227333797 122 | 1.0568507551950619,2.1766402398700913,2.112736651269025 123 | 1.2945800421473257,2.5891434455854863,2.464610685418602 124 | 1.0610175972052687,2.414166007236928,2.328153710723496 125 | 1.0950001049021418,1.7031926127144597,1.5842781623710935 126 | 1.0524981824637827,1.9850589577197555,1.9130816941150237 127 | 1.2629981407168622,3.367320742013409,3.051648581507944 128 | 1.3114347308043668,2.4193582170464305,2.42482367540401 129 | 1.0827827269015418,2.699797376127968,2.57297785743778 130 | 1.050512294552838,2.080227118135716,2.0180277673649316 131 | 1.1662933184244124,3.582387579269868,3.2943561632574188 132 | 1.079347528371695,2.7954471609640543,2.668552041977487 133 | 1.0949500750808776,1.4767360129189702,1.3802121519258346 134 | 1.096383509484503,2.920009714708035,2.7615035243710584 135 | 1.0452203155920823,1.3830006157480128,1.3558725827495761 136 | 1.0569904624025688,2.0620462782337348,1.9917298059367978 137 | 1.0437816388406762,1.923354743905095,1.8832046129667848 138 | 1.043439877868182,1.7232741923079817,1.6942473615745401 139 | 1.0787981585577764,1.4401175726200177,1.3524833604530224 140 | 1.3964245738257541,2.113059518885653,2.1550082268492115 141 | 1.0722377119176596,1.4196712703384828,1.3489269544821927 142 | 1.3371436146378946,3.885701283184591,3.4298191611370568 143 | 1.0398238064796606,1.6418950205470204,1.5940400936123484 144 | 1.055734356196008,1.8553877186568297,1.8160654369571128 145 | 1.4195595272705548,2.026859149726283,2.0771683293917245 146 | 1.171546960713951,3.5170660853704887,3.2270181061483747 147 | 1.5255909979444093,1.7893864628158216,1.8753160326230132 148 | 1.271360651840921,2.5916073178858947,2.473626801880368 149 | 1.1218776640238008,1.5189114350361834,1.5363630502457581 150 | 1.0631689114085572,2.455836525074661,2.3694503746322106 151 | 1.0758756914460306,1.7906722653263203,1.7586871232251844 152 | 1.1276790897706053,1.4682307036607285,1.4190081415605171 153 | 1.0635462156456463,2.3326379362189615,2.2468201112729207 154 | 1.0452699832799366,1.325441844094442,1.2745904965759371 155 | 1.387242999082051,2.149611223317456,2.1778917414920516 156 | 1.5089486839461215,1.791900375693886,1.8825283024882566 157 | 1.0370954202243237,1.467471644008007,1.425711991776879 158 | 1.104409721780664,2.9105266420794647,2.795435590445057 159 | 1.069338678851787,1.8492459991171368,1.8131058274382852 160 | 1.0422121240733064,1.7720374809644384,1.7197215601459452 161 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/mgwr_example.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/mgwr_example.p -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/test_kernels.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests for the custom GWR kernel class 3 | """ 4 | 5 | import unittest 6 | import numpy as np 7 | import libpysal 8 | from ..kernels import * 9 | 10 | PEGP = libpysal.examples.get_path 11 | 12 | 13 | class TestKernels(unittest.TestCase): 14 | def setUp(self): 15 | np.random.seed(1234) 16 | x = np.arange(1, 6) 17 | y = np.arange(5, 0, -1) 18 | np.random.shuffle(x) 19 | np.random.shuffle(y) 20 | self.coords = np.array(list(zip(x, y))) 21 | self.n = 5 22 | self.fix_gauss_kern = np.array( 23 | [[1., 0.38889556, 0.48567179, 0.48567179, 0.89483932], 24 | [0.38889556, 1., 0.89483932, 0.64118039, 0.48567179], 25 | [0.48567179, 0.89483932, 1., 0.89483932, 0.48567179], 26 | [0.48567179, 0.64118039, 0.89483932, 1., 0.38889556], 27 | [0.89483932, 0.48567179, 0.48567179, 0.38889556, 1.]]) 28 | self.adapt_gauss_kern = np.array( 29 | [[1., 0.52004183, 0.60653072, 0.60653072, 0.92596109], 30 | [0.34559083, 1., 0.88249692, 0.60653072, 0.44374738], 31 | [0.03877423, 0.60653072, 1., 0.60653072, 0.03877423], 32 | [0.44374738, 0.60653072, 0.88249692, 1., 0.34559083], 33 | [0.92596109, 0.60653072, 0.60653072, 0.52004183, 1.]]) 34 | self.fix_bisquare_kern = np.array( 35 | [[1., 0., 0., 0., 36 | 0.60493827], [0., 1., 0.60493827, 0.01234568, 0.], 37 | [0., 0.60493827, 1., 0.60493827, 0.], 38 | [0., 0.01234568, 0.60493827, 1., 0.], 39 | [0.60493827, 0., 0., 0., 1.]]) 40 | self.adapt_bisquare_kern = np.array( 41 | [[ 42 | 1.00000000e+00, 0.00000000e+00, 0.00000000e+00, 3.99999881e-14, 43 | 7.15976383e-01 44 | ], 45 | [ 46 | 0.00000000e+00, 1.00000000e+00, 5.62500075e-01, 47 | 3.99999881e-14, 0.00000000e+00 48 | ], 49 | [ 50 | 0.00000000e+00, 3.99999881e-14, 1.00000000e+00, 51 | 3.99999881e-14, 0.00000000e+00 52 | ], 53 | [ 54 | 0.00000000e+00, 3.99999881e-14, 5.62500075e-01, 55 | 1.00000000e+00, 0.00000000e+00 56 | ], 57 | [ 58 | 7.15976383e-01, 0.00000000e+00, 3.99999881e-14, 59 | 0.00000000e+00, 1.00000000e+00 60 | ]]) 61 | self.fix_exp_kern = np.array( 62 | [[1., 0.2529993, 0.30063739, 0.30063739, 0.62412506], 63 | [0.2529993, 1., 0.62412506, 0.38953209, 0.30063739], 64 | [0.30063739, 0.62412506, 1., 0.62412506, 0.30063739], 65 | [0.30063739, 0.38953209, 0.62412506, 1., 0.2529993], 66 | [0.62412506, 0.30063739, 0.30063739, 0.2529993, 1.]]) 67 | self.adapt_exp_kern = np.array( 68 | [[1., 0.31868771, 0.36787948, 0.36787948, 0.67554721], 69 | [0.23276223, 1., 0.60653069, 0.36787948, 0.27949951], 70 | [0.07811997, 0.36787948, 1., 0.36787948, 0.07811997], 71 | [0.27949951, 0.36787948, 0.60653069, 1., 0.23276223], 72 | [0.67554721, 0.36787948, 0.36787948, 0.31868771, 1.]]) 73 | 74 | def test_fix_gauss(self): 75 | kern = np.array([ 76 | Kernel(i, self.coords, 3, function="gaussian", fixed=True).kernel 77 | for i in range(self.n) 78 | ]) 79 | np.testing.assert_allclose(kern, self.fix_gauss_kern) 80 | 81 | def test_adapt_gauss(self): 82 | kern = np.array([ 83 | Kernel(i, self.coords, 3, function="gaussian", fixed=False).kernel 84 | for i in range(self.n) 85 | ]) 86 | np.testing.assert_allclose(kern, self.adapt_gauss_kern) 87 | 88 | def test_fix_biqsquare(self): 89 | kern = np.array([ 90 | Kernel(i, self.coords, 3, function="bisquare", fixed=True).kernel 91 | for i in range(self.n) 92 | ]) 93 | np.testing.assert_allclose(kern, self.fix_bisquare_kern, atol=1e-01) 94 | 95 | def test_adapt_bisqaure(self): 96 | kern = np.array([ 97 | Kernel(i, self.coords, 3, function="bisquare", fixed=False).kernel 98 | for i in range(self.n) 99 | ]) 100 | np.testing.assert_allclose(kern, self.adapt_bisquare_kern, atol=1e-012) 101 | 102 | def test_fix_exp(self): 103 | kern = np.array([ 104 | Kernel(i, self.coords, 3, function="exponential", 105 | fixed=True).kernel for i in range(self.n) 106 | ]) 107 | np.testing.assert_allclose(kern, self.fix_exp_kern) 108 | 109 | def test_adapt_exp(self): 110 | kern = np.array([ 111 | Kernel(i, self.coords, 3, function="exponential", 112 | fixed=False).kernel for i in range(self.n) 113 | ]) 114 | np.testing.assert_allclose(kern, self.adapt_exp_kern) 115 | 116 | 117 | if __name__ == '__main__': 118 | unittest.main() 119 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/test_sel_bw.py: -------------------------------------------------------------------------------- 1 | """ 2 | GWR is tested against results from GWR4 3 | """ 4 | 5 | import os 6 | import numpy as np 7 | from libpysal import io 8 | import libpysal as ps 9 | import unittest 10 | from spglm.family import Gaussian, Poisson, Binomial 11 | from ..sel_bw import Sel_BW 12 | from numpy.testing import assert_allclose 13 | 14 | 15 | class TestSelBWGaussian(unittest.TestCase): 16 | def setUp(self): 17 | data_path = ps.examples.get_path("GData_utm.csv") 18 | data = io.open(data_path) 19 | self.coords = list(zip(data.by_col('X'), data.by_col('Y'))) 20 | self.coords_longlat = list( 21 | zip(data.by_col('Longitud'), data.by_col('Latitude'))) 22 | self.y = np.array(data.by_col('PctBach')).reshape((-1, 1)) 23 | rural = np.array(data.by_col('PctRural')).reshape((-1, 1)) 24 | pov = np.array(data.by_col('PctPov')).reshape((-1, 1)) 25 | black = np.array(data.by_col('PctBlack')).reshape((-1, 1)) 26 | fb = np.array(data.by_col('PctFB')).reshape((-1, 1)) 27 | self.X = np.hstack([rural, pov, black]) 28 | self.mgwr_X = np.hstack([fb, black, rural]) 29 | 30 | def test_golden_fixed_AICc(self): 31 | bw1 = 211020.83 32 | bw2 = Sel_BW(self.coords, self.y, self.X, kernel='bisquare', 33 | fixed=True).search(criterion='AICc') 34 | assert_allclose(bw1, bw2) 35 | scipy_known = 211025.26298 36 | scipy = Sel_BW(self.coords, self.y, self.X, 37 | kernel='bisquare', fixed=True).search( 38 | criterion='AICc', search_method='scipy') 39 | assert_allclose(scipy_known, scipy, atol=1) 40 | 41 | def test_golden_adapt_AICc(self): 42 | bw1 = 93.0 43 | bw2 = Sel_BW(self.coords, self.y, self.X, kernel='bisquare', 44 | fixed=False).search(criterion='AICc') 45 | assert_allclose(bw1, bw2) 46 | 47 | def test_golden_adapt_AICc_Longlat(self): 48 | bw1 = 92.0 49 | bw2 = Sel_BW(self.coords_longlat, self.y, self.X, kernel='bisquare', 50 | fixed=False, spherical=True).search(criterion='AICc') 51 | assert_allclose(bw1, bw2) 52 | 53 | def test_golden_fixed_AIC(self): 54 | bw1 = 76201.66 55 | bw2 = Sel_BW(self.coords, self.y, self.X, kernel='gaussian', 56 | fixed=True).search(criterion='AIC') 57 | assert_allclose(bw1, bw2) 58 | scipy_known = 76199.81 59 | scipy = Sel_BW(self.coords, self.y, self.X, 60 | kernel='gaussian', fixed=True).search( 61 | criterion='AIC', search_method='scipy') 62 | assert_allclose(scipy_known, scipy, atol=1) 63 | 64 | def test_golden_adapt_AIC(self): 65 | bw1 = 50.0 66 | bw2 = Sel_BW(self.coords, self.y, self.X, kernel='gaussian', 67 | fixed=False).search(criterion='AIC') 68 | assert_allclose(bw1, bw2) 69 | 70 | def test_golden_fixed_BIC(self): 71 | bw1 = 1117795.47 72 | bw2 = Sel_BW(self.coords, self.y, self.X, kernel='gaussian', 73 | fixed=True).search(criterion='BIC') 74 | assert_allclose(bw1, bw2) 75 | scipy_known = 1117806.16 76 | scipy = Sel_BW(self.coords, self.y, self.X, 77 | kernel='gaussian', fixed=True).search( 78 | criterion='BIC', search_method='scipy') 79 | assert_allclose(scipy_known, scipy, atol=1) 80 | 81 | def test_golden_adapt_BIC(self): 82 | bw1 = 62.0 83 | bw2 = Sel_BW(self.coords, self.y, self.X, kernel='gaussian', 84 | fixed=False).search(criterion='BIC') 85 | assert_allclose(bw1, bw2) 86 | 87 | def test_golden_fixed_CV(self): 88 | bw1 = 130289.26 89 | bw2 = Sel_BW(self.coords, self.y, self.X, kernel='gaussian', 90 | fixed=True).search(criterion='CV') 91 | assert_allclose(bw1, bw2) 92 | scipy_known = 130363.55 93 | scipy = Sel_BW(self.coords, self.y, self.X, 94 | kernel='gaussian', fixed=True).search( 95 | criterion='CV', search_method='scipy') 96 | assert_allclose(scipy_known, scipy, atol=1) 97 | 98 | def test_golden_adapt_CV(self): 99 | bw1 = 68.0 100 | bw2 = Sel_BW(self.coords, self.y, self.X, kernel='gaussian', 101 | fixed=False).search(criterion='CV') 102 | assert_allclose(bw1, bw2) 103 | 104 | def test_interval_fixed_AICc(self): 105 | bw1 = 211025.0 106 | bw2 = Sel_BW(self.coords, self.y, self.X, 107 | kernel='bisquare', fixed=True).search( 108 | criterion='AICc', search_method='interval', 109 | bw_min=211001.0, bw_max=211035.0, interval=2) 110 | assert_allclose(bw1, bw2) 111 | 112 | def test_interval_adapt_AICc(self): 113 | bw1 = 93.0 114 | bw2 = Sel_BW(self.coords, self.y, self.X, 115 | kernel='bisquare', fixed=False).search( 116 | criterion='AICc', search_method='interval', 117 | bw_min=90.0, bw_max=95.0, interval=1) 118 | assert_allclose(bw1, bw2) 119 | 120 | def test_interval_fixed_AIC(self): 121 | bw1 = 76175.0 #76169.00 122 | bw2 = Sel_BW(self.coords, self.y, self.X, 123 | kernel='gaussian', fixed=True).search( 124 | criterion='AIC', search_method='interval', 125 | bw_min=76161.0, bw_max=76175.0, interval=1) 126 | assert_allclose(bw1, bw2) 127 | 128 | def test_interval_adapt_AIC(self): 129 | bw1 = 40.0 #50.0 130 | bw2 = Sel_BW(self.coords, self.y, self.X, 131 | kernel='gaussian', fixed=False).search( 132 | criterion='AIC', search_method='interval', 133 | bw_min=40.0, bw_max=60.0, interval=2) 134 | assert_allclose(bw1, bw2) 135 | 136 | def test_interval_fixed_BIC(self): 137 | bw1 = 279461.0 #279451.00 138 | bw2 = Sel_BW(self.coords, self.y, self.X, 139 | kernel='gaussian', fixed=True).search( 140 | criterion='BIC', search_method='interval', 141 | bw_min=279441.0, bw_max=279461.0, interval=2) 142 | assert_allclose(bw1, bw2) 143 | 144 | def test_interval_adapt_BIC(self): 145 | bw1 = 62.0 146 | bw2 = Sel_BW(self.coords, self.y, self.X, 147 | kernel='gaussian', fixed=False).search( 148 | criterion='BIC', search_method='interval', 149 | bw_min=52.0, bw_max=72.0, interval=2) 150 | assert_allclose(bw1, bw2) 151 | 152 | def test_interval_fixed_CV(self): 153 | bw1 = 130400.0 #130406.00 154 | bw2 = Sel_BW(self.coords, self.y, self.X, 155 | kernel='gaussian', fixed=True).search( 156 | criterion='CV', search_method='interval', 157 | bw_min=130400.0, bw_max=130410.0, interval=1) 158 | assert_allclose(bw1, bw2) 159 | 160 | def test_interval_adapt_CV(self): 161 | bw1 = 62.0 #68.0 162 | bw2 = Sel_BW(self.coords, self.y, self.X, 163 | kernel='gaussian', fixed=False).search( 164 | criterion='CV', search_method='interval', bw_min=60.0, 165 | bw_max=76.0, interval=2) 166 | assert_allclose(bw1, bw2) 167 | 168 | def test_MGWR_AICc(self): 169 | bw1 = [101.0, 101.0, 117.0, 157.0] 170 | std_y = (self.y - self.y.mean()) / self.y.std() 171 | std_X = (self.mgwr_X - self.mgwr_X.mean(axis=0)) / self.mgwr_X.std( 172 | axis=0) 173 | selector = Sel_BW(self.coords, std_y, std_X, multi=True, constant=True) 174 | bw2 = selector.search() 175 | np.testing.assert_allclose(bw1, bw2) 176 | 177 | def test_MGWR_AICc_Longlat(self): 178 | bw1 = [104.0, 104.0, 103.0, 157.0] 179 | std_y = (self.y - self.y.mean()) / self.y.std() 180 | std_X = (self.mgwr_X - self.mgwr_X.mean(axis=0)) / self.mgwr_X.std( 181 | axis=0) 182 | selector = Sel_BW(self.coords_longlat, std_y, std_X, multi=True, 183 | constant=True, spherical=True) 184 | bw2 = selector.search() 185 | assert_allclose(bw1, bw2) 186 | 187 | 188 | class TestGWRSelBWPoisson(unittest.TestCase): 189 | def setUp(self): 190 | data_path = os.path.join( 191 | os.path.dirname(__file__), 'tokyo/Tokyomortality.csv') 192 | data = io.open(data_path, mode='Ur') 193 | self.coords = list( 194 | zip(data.by_col('X_CENTROID'), data.by_col('Y_CENTROID'))) 195 | self.y = np.array(data.by_col('db2564')).reshape((-1, 1)) 196 | self.off = np.array(data.by_col('eb2564')).reshape((-1, 1)) 197 | OCC = np.array(data.by_col('OCC_TEC')).reshape((-1, 1)) 198 | OWN = np.array(data.by_col('OWNH')).reshape((-1, 1)) 199 | POP = np.array(data.by_col('POP65')).reshape((-1, 1)) 200 | UNEMP = np.array(data.by_col('UNEMP')).reshape((-1, 1)) 201 | self.X = np.hstack([OCC, OWN, POP, UNEMP]) 202 | 203 | def test_golden_adapt_AICc_Poisson_w_offset(self): 204 | bw1 = 95.0 205 | bw2 = Sel_BW(self.coords, self.y, self.X, kernel='bisquare', 206 | family=Poisson(), fixed=False, 207 | offset=self.off).search(criterion='AICc') 208 | assert_allclose(bw1, bw2) 209 | 210 | def test_golden_adapt_AICc_Poisson_wo_offset(self): 211 | bw1 = 51.0 212 | bw2 = Sel_BW(self.coords, self.y, self.X, kernel='bisquare', 213 | family=Poisson(), fixed=False).search(criterion='AICc') 214 | assert_allclose(bw1, bw2) 215 | 216 | 217 | if __name__ == '__main__': 218 | unittest.main() 219 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/Readme_tokyomortality.txt: -------------------------------------------------------------------------------- 1 | Dataset name: 2 | Tokyo Mortality Data 3 | 4 | File name 5 | tokyomortality.txt 6 | 7 | File type 8 | text file (space delimited data matrix) 9 | 10 | Fields 11 | IDnum0: sequential areal id 12 | X_CENTROID: x coordinate of areal centroid 13 | Y_CENTROID: y coordinate of areal centroid 14 | db2564: observed number of working age (25-64 yrs) deaths 15 | eb2564: expected number of working age (25-64 yrs) deaths 16 | OCC_TEC: proportion of professional workers 17 | OWNH: proportion of owned houses 18 | POP65: proportion of elderly people (equal to or older than 65) 19 | UNEMP: unemployment rate 20 | 21 | Areal unit 22 | 262 municipality 23 | 24 | Areal extent 25 | The Tokyo metropolitan area is enclosed by an approximate 70 km radius 26 | from the centroid of the Chiyoda ward of Tokyo where the Imperial Palace is located. 27 | 28 | Year 29 | 1990 30 | 31 | Source 32 | Vital Statistics and Population Census of Japan 33 | 34 | Sample session control file 35 | SampleTokyoMortalityGWPR.ctl 36 | 37 | Note 1: This sample fit a semiparametric geographically weighted Poisson regression model 38 | used in Nakaya et al. (2005). 39 | Note 2: Since all of the explanatory variables are standardised in the paper, the standardisation 40 | option is turned on in this sample. 41 | 42 | Additional file: 43 | tokyomet262.shp, shx, dbf, prj: ESRI shape file of the Tokyo metropolitan area 44 | 45 | Note 1: IDnum0 in tokyomortality.txt can be matched with AreaID in this shapefile dbf. 46 | Note 2: Coordinates are projected using UTM54 (Tokyo datum). 47 | Note 3: distance unit is metre. 48 | 49 | Reference 50 | Nakaya, T., Fotheringham, S., Brunsdon, C. and Charlton, M. (2005): 51 | Geographically weighted Poisson regression for disease associative mapping, 52 | Statistics in Medicine 24, 2695-2717. 53 | 54 | History 55 | 15 May 2012 The dataset is prepared for GWR4 sample dataset by TN. 56 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/SampleTokyoMortalityGWPR.ctl: -------------------------------------------------------------------------------- 1 | Semiparametric GWPR: Tokyo mortality data (see Nakaya et al. 2005, Stat in Med.) 2 | Tokyomortality.txt 3 | FORMAT/DELIMITER: 0 4 | Number_of_fields: 9 5 | Number_of_areas: 262 6 | Fields 7 | AreaKey 001 IDnum0 8 | X 002 X_CENTROID 9 | Y 003 Y_CENTROID 10 | Gmetric 0 11 | Dependent 004 db2564 12 | Offset 005 eb2564 13 | Independent_geo 3 14 | 000 Intercept 15 | 006 OCC_TEC 16 | 009 UNEMP 17 | Independent_fix 2 18 | 007 OWNH 19 | 008 POP65 20 | Unused_fields 0 21 | MODELTYPE: 1 22 | STANDARDISATION: 1 23 | GTEST: 0 24 | VSG2F: 0 25 | VSF2G: 0 26 | KERNELTYPE: 0 27 | BANDSELECTIONMETHOD: 2 28 | Goldrangeflag: 0 29 | Goldenmax: 30 | Goldenmin: 31 | Fixedbandsize: 32 | IntervalMax: 20000 33 | IntervalMin: 10000 34 | IntervalStep: 1000 35 | Criteria: 1000 36 | summary_output: defaultGWRsummary.txt 37 | listwise_output: defaultGWRlistwise.csv 38 | predictflag: 0 39 | prediction_def: 40 | prediction_output: 41 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/tokyo_BS_F.ctl: -------------------------------------------------------------------------------- 1 | 2 | C:\Users\IEUser\Desktop\tokyo\tokyo\Tokyomortality.txt 3 | FORMAT/DELIMITER: 0 4 | Number_of_fields: 9 5 | Number_of_areas: 262 6 | Fields 7 | AreaKey 001 IDnum0 8 | X 002 X_CENTROID 9 | Y 003 Y_CENTROID 10 | Gmetric 0 11 | Dependent 004 db2564 12 | Offset 13 | Independent_geo 5 14 | 000 Intercept 15 | 006 OCC_TEC 16 | 007 OWNH 17 | 008 POP65 18 | 009 UNEMP 19 | Independent_fix 0 20 | Unused_fields 1 21 | 005 eb2564 22 | MODELTYPE: 1 23 | STANDARDISATION: 0 24 | GTEST: 0 25 | VSL2G: 0 26 | VSG2L: 0 27 | KERNELTYPE: 1 28 | BANDSELECTIONMETHOD: 1 29 | Goldrangeflag: 0 30 | Goldenmax: 31 | Goldenmin: 32 | Fixedbandsize: 33 | IntervalMax: 34 | IntervalMin: 35 | IntervalStep: 36 | Criteria: 37 | summary_output: C:\Users\IEUser\Desktop\tokyo\tokyo_results_no_off\tokyo_BS_F_summary.txt 38 | listwise_output: C:\Users\IEUser\Desktop\tokyo\tokyo_results_no_off\tokyo_BS_F_listwise.csv 39 | predictflag: 0 40 | prediction_def: 41 | prediction_output: 42 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/tokyo_BS_NN.ctl: -------------------------------------------------------------------------------- 1 | 2 | C:\Users\IEUser\Desktop\tokyo\tokyo\Tokyomortality.txt 3 | FORMAT/DELIMITER: 0 4 | Number_of_fields: 9 5 | Number_of_areas: 262 6 | Fields 7 | AreaKey 001 IDnum0 8 | X 002 X_CENTROID 9 | Y 003 Y_CENTROID 10 | Gmetric 0 11 | Dependent 004 db2564 12 | Offset 13 | Independent_geo 5 14 | 000 Intercept 15 | 006 OCC_TEC 16 | 007 OWNH 17 | 008 POP65 18 | 009 UNEMP 19 | Independent_fix 0 20 | Unused_fields 1 21 | 005 eb2564 22 | MODELTYPE: 1 23 | STANDARDISATION: 0 24 | GTEST: 0 25 | VSL2G: 0 26 | VSG2L: 0 27 | KERNELTYPE: 2 28 | BANDSELECTIONMETHOD: 1 29 | Goldrangeflag: 0 30 | Goldenmax: 31 | Goldenmin: 32 | Fixedbandsize: 33 | IntervalMax: 34 | IntervalMin: 35 | IntervalStep: 36 | Criteria: 37 | summary_output: C:\Users\IEUser\Desktop\tokyo\tokyo_results_no_off\tokyo_BS_NN_summary.txt 38 | listwise_output: C:\Users\IEUser\Desktop\tokyo\tokyo_results_no_off\tokyo_BS_NN_listwise.csv 39 | predictflag: 0 40 | prediction_def: 41 | prediction_output: 42 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/tokyo_BS_NN_OFF.ctl: -------------------------------------------------------------------------------- 1 | 2 | C:\Users\IEUser\Desktop\tokyo\tokyo\Tokyomortality.txt 3 | FORMAT/DELIMITER: 0 4 | Number_of_fields: 9 5 | Number_of_areas: 262 6 | Fields 7 | AreaKey 001 IDnum0 8 | X 002 X_CENTROID 9 | Y 003 Y_CENTROID 10 | Gmetric 0 11 | Dependent 004 db2564 12 | Offset 005 eb2564 13 | Independent_geo 5 14 | 000 Intercept 15 | 006 OCC_TEC 16 | 007 OWNH 17 | 008 POP65 18 | 009 UNEMP 19 | Independent_fix 0 20 | Unused_fields 0 21 | MODELTYPE: 1 22 | STANDARDISATION: 0 23 | GTEST: 0 24 | VSL2G: 0 25 | VSG2L: 0 26 | KERNELTYPE: 2 27 | BANDSELECTIONMETHOD: 0 28 | Goldrangeflag: 0 29 | Goldenmax: 30 | Goldenmin: 31 | Fixedbandsize: 100 32 | IntervalMax: 33 | IntervalMin: 34 | IntervalStep: 35 | Criteria: 36 | summary_output: C:\Users\IEUser\Desktop\tokyo\tokyo_results\tokyo_BS_NN_OFF_100_summary.txt 37 | listwise_output: C:\Users\IEUser\Desktop\tokyo\tokyo_results\tokyo_BS_NN_OFF_100_listwise.csv 38 | predictflag: 0 39 | prediction_def: 40 | prediction_output: 41 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/tokyo_BS_NN_OFF_summary.txt: -------------------------------------------------------------------------------- 1 | ***************************************************************************** 2 | * Semiparametric Geographically Weighted Regression * 3 | * Release 1.0.90 (GWR 4.0.90) * 4 | * 12 May 2015 * 5 | * (Originally coded by T. Nakaya: 1 Nov 2009) * 6 | * * 7 | * Tomoki Nakaya(1), Martin Charlton(2), Chris Brunsdon (2) * 8 | * Paul Lewis (2), Jing Yao (3), A Stewart Fotheringham (4) * 9 | * (c) GWR4 development team * 10 | * (1) Ritsumeikan University, (2) National University of Ireland, Maynooth, * 11 | * (3) University of Glasgow, (4) Arizona State University * 12 | ***************************************************************************** 13 | 14 | Program began at 9/7/2016 12:36:11 PM 15 | 16 | ***************************************************************************** 17 | Session: 18 | Session control file: C:\Users\IEUser\Desktop\tokyo\tokyo_results\tokyo_BS_NN_OFF_100.ctl 19 | ***************************************************************************** 20 | Data filename: C:\Users\IEUser\Desktop\tokyo\tokyo\Tokyomortality.txt 21 | Number of areas/points: 262 22 | 23 | Model settings--------------------------------- 24 | Model type: Poisson 25 | Geographic kernel: adaptive bi-square 26 | Method for optimal bandwidth search: fixed value 27 | Criterion for optimal bandwidth: AICc 28 | Number of varying coefficients: 5 29 | Number of fixed coefficients: 0 30 | 31 | Modelling options--------------------------------- 32 | Standardisation of independent variables: OFF 33 | Testing geographical variability of local coefficients: OFF 34 | Local to Global Variable selection: OFF 35 | Global to Local Variable selection: OFF 36 | Prediction at non-regression points: OFF 37 | 38 | Variable settings--------------------------------- 39 | Area key: field1: IDnum0 40 | Easting (x-coord): field2 : X_CENTROID 41 | Northing (y-coord): field3: Y_CENTROID 42 | Cartesian coordinates: Euclidean distance 43 | Dependent variable: field4: db2564 44 | Offset variable: field5: eb2564 45 | Intercept: varying (Local) intercept 46 | Independent variable with varying (Local) coefficient: field6: OCC_TEC 47 | Independent variable with varying (Local) coefficient: field7: OWNH 48 | Independent variable with varying (Local) coefficient: field8: POP65 49 | Independent variable with varying (Local) coefficient: field9: UNEMP 50 | ***************************************************************************** 51 | 52 | ***************************************************************************** 53 | Global regression result 54 | ***************************************************************************** 55 | < Diagnostic information > 56 | Number of parameters: 5 57 | Deviance: 389.281580 58 | Classic AIC: 399.281580 59 | AICc: 399.515955 60 | BIC/MDL: 417.123303 61 | Percent deviance explained 0.594601 62 | 63 | Variable Estimate Standard Error z(Est/SE) Exp(Est) 64 | -------------------- --------------- --------------- --------------- --------------- 65 | Intercept 0.007470 0.065139 0.114679 1.007498 66 | OCC_TEC -2.287906 0.162000 -14.122903 0.101479 67 | OWNH -0.259692 0.047050 -5.519470 0.771289 68 | POP65 2.199387 0.198270 11.092878 9.019480 69 | UNEMP 0.064025 0.010997 5.822059 1.066119 70 | 71 | ***************************************************************************** 72 | GWR (Geographically weighted regression) bandwidth selection 73 | ***************************************************************************** 74 | 75 | Bandwidth search : 100 76 | 77 | ***************************************************************************** 78 | GWR (Geographically weighted regression) result 79 | ***************************************************************************** 80 | Bandwidth and geographic ranges 81 | Bandwidth size: 100.000000 82 | Coordinate Min Max Range 83 | --------------- --------------- --------------- --------------- 84 | X-coord 276385.400000 408226.180000 131840.780000 85 | Y-coord -86587.480000 33538.420000 120125.900000 86 | 87 | Diagnostic information 88 | Effective number of parameters (model: trace(S)): 25.145091 89 | Effective number of parameters (variance: trace(S'WSW^-1)): 17.142370 90 | Degree of freedom (model: n - trace(S)): 236.854909 91 | Degree of freedom (residual: n - 2trace(S) + trace(S'WSW^-1)): 228.852188 92 | Deviance: 311.245301 93 | Classic AIC: 361.535483 94 | AICc: 367.110273 95 | BIC/MDL: 451.261832 96 | Percent deviance explained 0.675868 97 | 98 | *********************************************************** 99 | << Geographically varying (Local) coefficients >> 100 | *********************************************************** 101 | Estimates of varying coefficients have been saved in the following file. 102 | Listwise output file: C:\Users\IEUser\Desktop\tokyo\tokyo_results\tokyo_BS_NN_OFF_100_listwise.csv 103 | 104 | Summary statistics for varying (Local) coefficients 105 | Variable Mean STD 106 | -------------------- --------------- --------------- 107 | Intercept 0.038565 0.295395 108 | OCC_TEC -2.132644 1.004125 109 | OWNH -0.275802 0.157200 110 | POP65 2.169549 0.626589 111 | UNEMP 0.047531 0.038121 112 | 113 | Variable Min Max Range 114 | -------------------- --------------- --------------- --------------- 115 | Intercept -0.879764 0.408928 1.288692 116 | OCC_TEC -3.607038 1.218879 4.825918 117 | OWNH -0.547011 0.111386 0.658397 118 | POP65 1.319626 4.095840 2.776214 119 | UNEMP -0.051157 0.159427 0.210584 120 | 121 | Variable Lwr Quartile Median Upr Quartile 122 | -------------------- --------------- --------------- --------------- 123 | Intercept 0.001123 0.090003 0.254783 124 | OCC_TEC -2.661121 -2.503268 -1.837056 125 | OWNH -0.375947 -0.321084 -0.208341 126 | POP65 1.676893 2.083871 2.420870 127 | UNEMP 0.022264 0.044555 0.075398 128 | 129 | Variable Interquartile R Robust STD 130 | -------------------- --------------- --------------- 131 | Intercept 0.253660 0.188036 132 | OCC_TEC 0.824066 0.610872 133 | OWNH 0.167607 0.124245 134 | POP65 0.743976 0.551502 135 | UNEMP 0.053134 0.039388 136 | (Note: Robust STD is given by (interquartile range / 1.349) ) 137 | 138 | ***************************************************************************** 139 | GWR Analysis of Deviance Table 140 | ***************************************************************************** 141 | Source Deviance DOF Deviance/DOF 142 | ------------ ------------------- ---------- ---------------- 143 | Global model 389.282 257.000 1.515 144 | GWR model 311.245 228.852 1.360 145 | Difference 78.036 28.148 2.772 146 | 147 | ***************************************************************************** 148 | Program terminated at 9/7/2016 12:36:11 PM 149 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/tokyo_BS_NN_summary.txt: -------------------------------------------------------------------------------- 1 | ***************************************************************************** 2 | * Semiparametric Geographically Weighted Regression * 3 | * Release 1.0.90 (GWR 4.0.90) * 4 | * 12 May 2015 * 5 | * (Originally coded by T. Nakaya: 1 Nov 2009) * 6 | * * 7 | * Tomoki Nakaya(1), Martin Charlton(2), Chris Brunsdon (2) * 8 | * Paul Lewis (2), Jing Yao (3), A Stewart Fotheringham (4) * 9 | * (c) GWR4 development team * 10 | * (1) Ritsumeikan University, (2) National University of Ireland, Maynooth, * 11 | * (3) University of Glasgow, (4) Arizona State University * 12 | ***************************************************************************** 13 | 14 | Program began at 7/25/2016 8:23:10 AM 15 | 16 | ***************************************************************************** 17 | Session: 18 | Session control file: C:\Users\IEUser\Desktop\tokyo\tokyo_results_no_off\tokyo_BS_NN.ctl 19 | ***************************************************************************** 20 | Data filename: C:\Users\IEUser\Desktop\tokyo\tokyo\Tokyomortality.txt 21 | Number of areas/points: 262 22 | 23 | Model settings--------------------------------- 24 | Model type: Poisson 25 | Geographic kernel: adaptive bi-square 26 | Method for optimal bandwidth search: Golden section search 27 | Criterion for optimal bandwidth: AICc 28 | Number of varying coefficients: 5 29 | Number of fixed coefficients: 0 30 | 31 | Modelling options--------------------------------- 32 | Standardisation of independent variables: OFF 33 | Testing geographical variability of local coefficients: OFF 34 | Local to Global Variable selection: OFF 35 | Global to Local Variable selection: OFF 36 | Prediction at non-regression points: OFF 37 | 38 | Variable settings--------------------------------- 39 | Area key: field1: IDnum0 40 | Easting (x-coord): field2 : X_CENTROID 41 | Northing (y-coord): field3: Y_CENTROID 42 | Cartesian coordinates: Euclidean distance 43 | Dependent variable: field4: db2564 44 | Offset variable is not specified 45 | Intercept: varying (Local) intercept 46 | Independent variable with varying (Local) coefficient: field6: OCC_TEC 47 | Independent variable with varying (Local) coefficient: field7: OWNH 48 | Independent variable with varying (Local) coefficient: field8: POP65 49 | Independent variable with varying (Local) coefficient: field9: UNEMP 50 | ***************************************************************************** 51 | 52 | ***************************************************************************** 53 | Global regression result 54 | ***************************************************************************** 55 | < Diagnostic information > 56 | Number of parameters: 5 57 | Deviance: 24597.455544 58 | Classic AIC: 24607.455544 59 | AICc: 24607.689919 60 | BIC/MDL: 24625.297266 61 | Percent deviance explained 0.526746 62 | 63 | Variable Estimate Standard Error z(Est/SE) Exp(Est) 64 | -------------------- --------------- --------------- --------------- --------------- 65 | Intercept 8.432403 0.061613 136.859875 4593.526955 66 | OCC_TEC -4.270431 0.156467 -27.292831 0.013976 67 | OWNH -4.789311 0.046070 -103.957933 0.008318 68 | POP65 -1.252659 0.178384 -7.022265 0.285744 69 | UNEMP 0.061305 0.010099 6.070542 1.063223 70 | 71 | ***************************************************************************** 72 | GWR (Geographically weighted regression) bandwidth selection 73 | ***************************************************************************** 74 | 75 | Bandwidth search 76 | Limits: 50, 262 77 | Golden section search begins... 78 | Initial values 79 | pL Bandwidth: 50.000 Criterion: 13285.297 80 | p1 Bandwidth: 54.513 Criterion: 13883.832 81 | p2 Bandwidth: 57.302 Criterion: 14277.220 82 | pU Bandwidth: 61.814 Criterion: 14823.882 83 | iter 1 (p1) Bandwidth: 54.513 Criterion: 13883.832 Diff: 2.789 84 | iter 2 (p1) Bandwidth: 52.789 Criterion: 13595.764 Diff: 1.724 85 | iter 3 (p1) Bandwidth: 51.724 Criterion: 13457.435 Diff: 1.065 86 | The lower limit in your search has been selected as the optimal bandwidth size. 87 | A new sesssion is recommended to try with a smaller lowest limit of the bandwidth search. 88 | Best bandwidth size 50.000 89 | Minimum AICc 13285.297 90 | 91 | ***************************************************************************** 92 | GWR (Geographically weighted regression) result 93 | ***************************************************************************** 94 | Bandwidth and geographic ranges 95 | Bandwidth size: 50.000000 96 | Coordinate Min Max Range 97 | --------------- --------------- --------------- --------------- 98 | X-coord 276385.400000 408226.180000 131840.780000 99 | Y-coord -86587.480000 33538.420000 120125.900000 100 | 101 | Diagnostic information 102 | Effective number of parameters (model: trace(S)): 51.200710 103 | Effective number of parameters (variance: trace(S'WSW^-1)): 37.243822 104 | Degree of freedom (model: n - trace(S)): 210.799290 105 | Degree of freedom (residual: n - 2trace(S) + trace(S'WSW^-1)): 196.842402 106 | Deviance: 13157.416861 107 | Classic AIC: 13259.818280 108 | AICc: 13285.297045 109 | BIC/MDL: 13442.520052 110 | Percent deviance explained 0.746852 111 | 112 | *********************************************************** 113 | << Geographically varying (Local) coefficients >> 114 | *********************************************************** 115 | Estimates of varying coefficients have been saved in the following file. 116 | Listwise output file: C:\Users\IEUser\Desktop\tokyo\tokyo_results_no_off\tokyo_BS_NN_listwise.csv 117 | 118 | Summary statistics for varying (Local) coefficients 119 | Variable Mean STD 120 | -------------------- --------------- --------------- 121 | Intercept 6.999979 2.285454 122 | OCC_TEC 2.878608 8.847676 123 | OWNH -3.894854 1.746973 124 | POP65 1.787710 10.486526 125 | UNEMP 0.025665 0.509711 126 | 127 | Variable Min Max Range 128 | -------------------- --------------- --------------- --------------- 129 | Intercept 0.092823 13.643524 13.550701 130 | OCC_TEC -15.109710 37.386385 52.496096 131 | OWNH -7.776524 0.128994 7.905518 132 | POP65 -13.981412 34.398356 48.379768 133 | UNEMP -1.889846 1.238068 3.127914 134 | 135 | Variable Lwr Quartile Median Upr Quartile 136 | -------------------- --------------- --------------- --------------- 137 | Intercept 5.389016 7.348540 8.493162 138 | OCC_TEC -3.950324 2.752242 7.473013 139 | OWNH -5.048143 -4.141796 -2.717312 140 | POP65 -5.428713 -1.972543 6.458122 141 | UNEMP -0.283051 0.096767 0.340126 142 | 143 | Variable Interquartile R Robust STD 144 | -------------------- --------------- --------------- 145 | Intercept 3.104146 2.301072 146 | OCC_TEC 11.423338 8.468004 147 | OWNH 2.330831 1.727821 148 | POP65 11.886835 8.811590 149 | UNEMP 0.623177 0.461955 150 | (Note: Robust STD is given by (interquartile range / 1.349) ) 151 | 152 | ***************************************************************************** 153 | GWR Analysis of Deviance Table 154 | ***************************************************************************** 155 | Source Deviance DOF Deviance/DOF 156 | ------------ ------------------- ---------- ---------------- 157 | Global model 24597.456 257.000 95.710 158 | GWR model 13157.417 196.842 66.842 159 | Difference 11440.039 60.158 190.168 160 | 161 | ***************************************************************************** 162 | Program terminated at 7/25/2016 8:23:12 AM 163 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/tokyo_GS_F.ctl: -------------------------------------------------------------------------------- 1 | 2 | C:\Users\IEUser\Desktop\tokyo\tokyo\Tokyomortality.txt 3 | FORMAT/DELIMITER: 0 4 | Number_of_fields: 9 5 | Number_of_areas: 262 6 | Fields 7 | AreaKey 001 IDnum0 8 | X 002 X_CENTROID 9 | Y 003 Y_CENTROID 10 | Gmetric 0 11 | Dependent 004 db2564 12 | Offset 13 | Independent_geo 5 14 | 000 Intercept 15 | 006 OCC_TEC 16 | 007 OWNH 17 | 008 POP65 18 | 009 UNEMP 19 | Independent_fix 0 20 | Unused_fields 1 21 | 005 eb2564 22 | MODELTYPE: 1 23 | STANDARDISATION: 0 24 | GTEST: 0 25 | VSL2G: 0 26 | VSG2L: 0 27 | KERNELTYPE: 0 28 | BANDSELECTIONMETHOD: 1 29 | Goldrangeflag: 0 30 | Goldenmax: 31 | Goldenmin: 32 | Fixedbandsize: 33 | IntervalMax: 34 | IntervalMin: 35 | IntervalStep: 36 | Criteria: 37 | summary_output: C:\Users\IEUser\Desktop\tokyo\tokyo_results_no_off\tokyo_GS_F_summary.txt 38 | listwise_output: C:\Users\IEUser\Desktop\tokyo\tokyo_results_no_off\tokyo_GS_F_listwise.csv 39 | predictflag: 0 40 | prediction_def: 41 | prediction_output: 42 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/tokyo_GS_NN.ctl: -------------------------------------------------------------------------------- 1 | 2 | C:\Users\IEUser\Desktop\tokyo\tokyo\Tokyomortality.txt 3 | FORMAT/DELIMITER: 0 4 | Number_of_fields: 9 5 | Number_of_areas: 262 6 | Fields 7 | AreaKey 001 IDnum0 8 | X 002 X_CENTROID 9 | Y 003 Y_CENTROID 10 | Gmetric 0 11 | Dependent 004 db2564 12 | Offset 13 | Independent_geo 5 14 | 000 Intercept 15 | 006 OCC_TEC 16 | 007 OWNH 17 | 008 POP65 18 | 009 UNEMP 19 | Independent_fix 0 20 | Unused_fields 1 21 | 005 eb2564 22 | MODELTYPE: 1 23 | STANDARDISATION: 0 24 | GTEST: 0 25 | VSL2G: 0 26 | VSG2L: 0 27 | KERNELTYPE: 3 28 | BANDSELECTIONMETHOD: 1 29 | Goldrangeflag: 0 30 | Goldenmax: 31 | Goldenmin: 32 | Fixedbandsize: 33 | IntervalMax: 34 | IntervalMin: 35 | IntervalStep: 36 | Criteria: 37 | summary_output: C:\Users\IEUser\Desktop\tokyo\tokyo_results_no_off\tokyo_GS_NN_summary.txt 38 | listwise_output: C:\Users\IEUser\Desktop\tokyo\tokyo_results_no_off\tokyo_GS_NN_listwise.csv 39 | predictflag: 0 40 | prediction_def: 41 | prediction_output: 42 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/tokyo_GS_NN_summary.txt: -------------------------------------------------------------------------------- 1 | ***************************************************************************** 2 | * Semiparametric Geographically Weighted Regression * 3 | * Release 1.0.90 (GWR 4.0.90) * 4 | * 12 May 2015 * 5 | * (Originally coded by T. Nakaya: 1 Nov 2009) * 6 | * * 7 | * Tomoki Nakaya(1), Martin Charlton(2), Chris Brunsdon (2) * 8 | * Paul Lewis (2), Jing Yao (3), A Stewart Fotheringham (4) * 9 | * (c) GWR4 development team * 10 | * (1) Ritsumeikan University, (2) National University of Ireland, Maynooth, * 11 | * (3) University of Glasgow, (4) Arizona State University * 12 | ***************************************************************************** 13 | 14 | Program began at 7/25/2016 8:24:18 AM 15 | 16 | ***************************************************************************** 17 | Session: 18 | Session control file: C:\Users\IEUser\Desktop\tokyo\tokyo_results_no_off\tokyo_GS_NN.ctl 19 | ***************************************************************************** 20 | Data filename: C:\Users\IEUser\Desktop\tokyo\tokyo\Tokyomortality.txt 21 | Number of areas/points: 262 22 | 23 | Model settings--------------------------------- 24 | Model type: Poisson 25 | Geographic kernel: adaptive Gaussian 26 | Method for optimal bandwidth search: Golden section search 27 | Criterion for optimal bandwidth: AICc 28 | Number of varying coefficients: 5 29 | Number of fixed coefficients: 0 30 | 31 | Modelling options--------------------------------- 32 | Standardisation of independent variables: OFF 33 | Testing geographical variability of local coefficients: OFF 34 | Local to Global Variable selection: OFF 35 | Global to Local Variable selection: OFF 36 | Prediction at non-regression points: OFF 37 | 38 | Variable settings--------------------------------- 39 | Area key: field1: IDnum0 40 | Easting (x-coord): field2 : X_CENTROID 41 | Northing (y-coord): field3: Y_CENTROID 42 | Cartesian coordinates: Euclidean distance 43 | Dependent variable: field4: db2564 44 | Offset variable is not specified 45 | Intercept: varying (Local) intercept 46 | Independent variable with varying (Local) coefficient: field6: OCC_TEC 47 | Independent variable with varying (Local) coefficient: field7: OWNH 48 | Independent variable with varying (Local) coefficient: field8: POP65 49 | Independent variable with varying (Local) coefficient: field9: UNEMP 50 | ***************************************************************************** 51 | 52 | ***************************************************************************** 53 | Global regression result 54 | ***************************************************************************** 55 | < Diagnostic information > 56 | Number of parameters: 5 57 | Deviance: 24597.455544 58 | Classic AIC: 24607.455544 59 | AICc: 24607.689919 60 | BIC/MDL: 24625.297266 61 | Percent deviance explained 0.526746 62 | 63 | Variable Estimate Standard Error z(Est/SE) Exp(Est) 64 | -------------------- --------------- --------------- --------------- --------------- 65 | Intercept 8.432403 0.061613 136.859875 4593.526955 66 | OCC_TEC -4.270431 0.156467 -27.292831 0.013976 67 | OWNH -4.789311 0.046070 -103.957933 0.008318 68 | POP65 -1.252659 0.178384 -7.022265 0.285744 69 | UNEMP 0.061305 0.010099 6.070542 1.063223 70 | 71 | ***************************************************************************** 72 | GWR (Geographically weighted regression) bandwidth selection 73 | ***************************************************************************** 74 | 75 | Bandwidth search 76 | Limits: 50, 262 77 | Golden section search begins... 78 | Initial values 79 | pL Bandwidth: 50.000 Criterion: 21070.385 80 | p1 Bandwidth: 54.513 Criterion: 21300.064 81 | p2 Bandwidth: 57.302 Criterion: 21467.046 82 | pU Bandwidth: 61.814 Criterion: 21628.107 83 | iter 1 (p1) Bandwidth: 54.513 Criterion: 21300.064 Diff: 2.789 84 | iter 2 (p1) Bandwidth: 52.789 Criterion: 21186.366 Diff: 1.724 85 | iter 3 (p1) Bandwidth: 51.724 Criterion: 21119.354 Diff: 1.065 86 | The lower limit in your search has been selected as the optimal bandwidth size. 87 | A new sesssion is recommended to try with a smaller lowest limit of the bandwidth search. 88 | Best bandwidth size 50.000 89 | Minimum AICc 21070.385 90 | 91 | ***************************************************************************** 92 | GWR (Geographically weighted regression) result 93 | ***************************************************************************** 94 | Bandwidth and geographic ranges 95 | Bandwidth size: 50.000000 96 | Coordinate Min Max Range 97 | --------------- --------------- --------------- --------------- 98 | X-coord 276385.400000 408226.180000 131840.780000 99 | Y-coord -86587.480000 33538.420000 120125.900000 100 | 101 | Diagnostic information 102 | Effective number of parameters (model: trace(S)): 11.723460 103 | Effective number of parameters (variance: trace(S'WSW^-1)): 7.749046 104 | Degree of freedom (model: n - trace(S)): 250.276540 105 | Degree of freedom (residual: n - 2trace(S) + trace(S'WSW^-1)): 246.302127 106 | Deviance: 21045.741163 107 | Classic AIC: 21069.188082 108 | AICc: 21070.384849 109 | BIC/MDL: 21111.021425 110 | Percent deviance explained 0.595081 111 | 112 | *********************************************************** 113 | << Geographically varying (Local) coefficients >> 114 | *********************************************************** 115 | Estimates of varying coefficients have been saved in the following file. 116 | Listwise output file: C:\Users\IEUser\Desktop\tokyo\tokyo_results_no_off\tokyo_GS_NN_listwise.csv 117 | 118 | Summary statistics for varying (Local) coefficients 119 | Variable Mean STD 120 | -------------------- --------------- --------------- 121 | Intercept 8.599793 0.585380 122 | OCC_TEC -5.080341 1.478737 123 | OWNH -4.701071 0.496447 124 | POP65 0.046837 2.647462 125 | UNEMP -0.013079 0.063278 126 | 127 | Variable Min Max Range 128 | -------------------- --------------- --------------- --------------- 129 | Intercept 7.477564 9.572760 2.095196 130 | OCC_TEC -7.742931 -1.917576 5.825356 131 | OWNH -5.362232 -3.589268 1.772965 132 | POP65 -4.885369 4.836340 9.721710 133 | UNEMP -0.153164 0.095991 0.249155 134 | 135 | Variable Lwr Quartile Median Upr Quartile 136 | -------------------- --------------- --------------- --------------- 137 | Intercept 8.093103 8.594024 9.143286 138 | OCC_TEC -6.116852 -5.256411 -3.711580 139 | OWNH -5.168985 -4.721204 -4.342757 140 | POP65 -2.208547 0.299896 2.173021 141 | UNEMP -0.061169 -0.002452 0.038315 142 | 143 | Variable Interquartile R Robust STD 144 | -------------------- --------------- --------------- 145 | Intercept 1.050183 0.778490 146 | OCC_TEC 2.405272 1.783003 147 | OWNH 0.826228 0.612474 148 | POP65 4.381568 3.248012 149 | UNEMP 0.099484 0.073747 150 | (Note: Robust STD is given by (interquartile range / 1.349) ) 151 | 152 | ***************************************************************************** 153 | GWR Analysis of Deviance Table 154 | ***************************************************************************** 155 | Source Deviance DOF Deviance/DOF 156 | ------------ ------------------- ---------- ---------------- 157 | Global model 24597.456 257.000 95.710 158 | GWR model 21045.741 246.302 85.447 159 | Difference 3551.714 10.698 332.002 160 | 161 | ***************************************************************************** 162 | Program terminated at 7/25/2016 8:24:21 AM 163 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/tokyomet262.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/tokyo/tokyomet262.dbf -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/tokyomet262.prj: -------------------------------------------------------------------------------- 1 | PROJCS["Japan_Zone_6",GEOGCS["GCS_Tokyo",DATUM["D_Tokyo",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",136.0],PARAMETER["Scale_Factor",0.9999],PARAMETER["Latitude_Of_Origin",36.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/tokyomet262.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/tokyo/tokyomet262.shp -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/tokyomet262.shp.xml: -------------------------------------------------------------------------------- 1 | 2 | 20120518141820001.0TRUECalculateField tokyomet262 AreaID [FID] VB #DeleteField tokyomet262 MC6584;ME6584;SMR6584RepairGeometry tokyomet262 DELETE_NULL 3 | -------------------------------------------------------------------------------- /mgwrlib/mgwr/tests/tokyo/tokyomet262.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/mgwrlib/mgwr/tests/tokyo/tokyomet262.shx -------------------------------------------------------------------------------- /mgwrlib/mgwr/utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from libpysal.common import requires 3 | 4 | 5 | @requires('matplotlib') 6 | def shift_colormap(cmap, start=0, midpoint=0.5, stop=1.0, name='shiftedcmap'): 7 | ''' 8 | Function to offset the "center" of a colormap. Useful for 9 | data with a negative min and positive max and you want the 10 | middle of the colormap's dynamic range to be at zero 11 | 12 | Parameters 13 | ---------- 14 | cmap : The matplotlib colormap to be altered 15 | start : Offset from lowest point in the colormap's range. 16 | Defaults to 0.0 (no lower ofset). Should be between 17 | 0.0 and `midpoint`. 18 | midpoint : The new center of the colormap. Defaults to 19 | 0.5 (no shift). Should be between 0.0 and 1.0. In 20 | general, this should be 1 - vmax/(vmax + abs(vmin)) 21 | For example if your data range from -15.0 to +5.0 and 22 | you want the center of the colormap at 0.0, `midpoint` 23 | should be set to 1 - 5/(5 + 15)) or 0.75 24 | stop : Offset from highets point in the colormap's range. 25 | Defaults to 1.0 (no upper ofset). Should be between 26 | `midpoint` and 1.0. 27 | 28 | Returns 29 | ------- 30 | new_cmap : A new colormap that has been shifted. 31 | ''' 32 | 33 | import matplotlib as mpl 34 | import matplotlib.pyplot as plt 35 | 36 | cdict = {'red': [], 'green': [], 'blue': [], 'alpha': []} 37 | 38 | # regular index to compute the colors 39 | reg_index = np.linspace(start, stop, 257) 40 | 41 | # shifted index to match the data 42 | shift_index = np.hstack([ 43 | np.linspace(0.0, midpoint, 128, endpoint=False), 44 | np.linspace(midpoint, 1.0, 129, endpoint=True) 45 | ]) 46 | 47 | for ri, si in zip(reg_index, shift_index): 48 | r, g, b, a = cmap(ri) 49 | 50 | cdict['red'].append((si, r, r)) 51 | cdict['green'].append((si, g, g)) 52 | cdict['blue'].append((si, b, b)) 53 | cdict['alpha'].append((si, a, a)) 54 | 55 | new_cmap = mpl.colors.LinearSegmentedColormap(name, cdict) 56 | plt.register_cmap(cmap=new_cmap) 57 | 58 | return new_cmap 59 | 60 | 61 | @requires('matplotlib') 62 | def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100): 63 | ''' 64 | Function to truncate a colormap by selecting a subset of the original colormap's values 65 | 66 | Parameters 67 | ---------- 68 | cmap : Mmatplotlib colormap to be altered 69 | minval : Minimum value of the original colormap to include in the truncated colormap 70 | maxval : Maximum value of the original colormap to include in the truncated colormap 71 | n : Number of intervals between the min and max values for the gradient of the truncated colormap 72 | 73 | Returns 74 | ------- 75 | new_cmap : A new colormap that has been shifted. 76 | ''' 77 | 78 | import matplotlib as mpl 79 | 80 | new_cmap = mpl.colors.LinearSegmentedColormap.from_list( 81 | 'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval), 82 | cmap(np.linspace(minval, maxval, n))) 83 | return new_cmap 84 | 85 | 86 | @requires('matplotlib') 87 | @requires('geopandas') 88 | def compare_surfaces(data, var1, var2, gwr_t, gwr_bw, mgwr_t, mgwr_bw, name, 89 | kwargs1, kwargs2, savefig=None): 90 | ''' 91 | Function that creates comparative visualization of GWR and MGWR surfaces. 92 | 93 | Parameters 94 | ---------- 95 | data : pandas or geopandas Dataframe 96 | gwr/mgwr results 97 | var1 : string 98 | name of gwr parameter estimate column in frame 99 | var2 : string 100 | name of mgwr parameter estimate column in frame 101 | gwr_t : string 102 | name of gwr t-values column in frame associated with var1 103 | gwr_bw : float 104 | bandwidth for gwr model for var1 105 | mgwr_t : string 106 | name of mgwr t-values column in frame associated with var2 107 | mgwr_bw: float 108 | bandwidth for mgwr model for var2 109 | name : string 110 | common variable name to use for title 111 | kwargs1: 112 | additional plotting arguments for gwr surface 113 | kwargs2: 114 | additional plotting arguments for mgwr surface 115 | savefig: string, optional 116 | path to save the figure. Default is None. Not to save figure. 117 | ''' 118 | import matplotlib.pyplot as plt 119 | import geopandas as gp 120 | 121 | fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(45, 20)) 122 | ax0 = axes[0] 123 | ax0.set_title('GWR ' + name + ' Surface (BW: ' + str(gwr_bw) + ')', 124 | fontsize=40) 125 | ax1 = axes[1] 126 | ax1.set_title('MGWR ' + name + ' Surface (BW: ' + str(mgwr_bw) + ')', 127 | fontsize=40) 128 | 129 | #Set color map 130 | cmap = plt.cm.seismic 131 | 132 | #Find min and max values of the two combined datasets 133 | gwr_min = data[var1].min() 134 | gwr_max = data[var1].max() 135 | mgwr_min = data[var2].min() 136 | mgwr_max = data[var2].max() 137 | vmin = np.min([gwr_min, mgwr_min]) 138 | vmax = np.max([gwr_max, mgwr_max]) 139 | 140 | #If all values are negative use the negative half of the colormap 141 | if (vmin < 0) & (vmax < 0): 142 | cmap = truncate_colormap(cmap, 0.0, 0.5) 143 | #If all values are positive use the positive half of the colormap 144 | elif (vmin > 0) & (vmax > 0): 145 | cmap = truncate_colormap(cmap, 0.5, 1.0) 146 | #Otherwise, there are positive and negative values so the colormap so zero is the midpoint 147 | else: 148 | cmap = shift_colormap(cmap, start=0.0, 149 | midpoint=1 - vmax / (vmax + abs(vmin)), stop=1.) 150 | 151 | #Create scalar mappable for colorbar and stretch colormap across range of data values 152 | sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize( 153 | vmin=vmin, vmax=vmax)) 154 | 155 | #Plot GWR parameters 156 | data.plot(var1, cmap=sm.cmap, ax=ax0, vmin=vmin, vmax=vmax, **kwargs1) 157 | if (gwr_t == 0).any(): 158 | data[gwr_t == 0].plot(color='lightgrey', ax=ax0, **kwargs2) 159 | 160 | #Plot MGWR parameters 161 | data.plot(var2, cmap=sm.cmap, ax=ax1, vmin=vmin, vmax=vmax, **kwargs1) 162 | if (mgwr_t == 0).any(): 163 | data[mgwr_t == 0].plot(color='lightgrey', ax=ax1, **kwargs2) 164 | 165 | #Set figure options and plot 166 | fig.tight_layout() 167 | fig.subplots_adjust(right=0.9) 168 | cax = fig.add_axes([0.92, 0.14, 0.03, 0.75]) 169 | sm._A = [] 170 | cbar = fig.colorbar(sm, cax=cax) 171 | cbar.ax.tick_params(labelsize=50) 172 | ax0.get_xaxis().set_visible(False) 173 | ax0.get_yaxis().set_visible(False) 174 | ax1.get_xaxis().set_visible(False) 175 | ax1.get_yaxis().set_visible(False) 176 | if savefig is not None: 177 | plt.savefig(savefig) 178 | plt.show() 179 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | altgraph==0.16.1 2 | future==0.17.1 3 | libpysal==4.0.1 4 | macholib==1.11 5 | pandas==0.24.1 6 | pefile==2018.8.8 7 | PyInstaller==3.4 8 | PyQt5==5.9.2 9 | python-dateutil==2.8.0 10 | pytz==2018.9 11 | pywin32-ctypes==0.2.0 12 | scipy==1.2.1 13 | simpledbf==0.2.6 14 | sip==4.19.8 15 | six==1.12.0 16 | spglm==1.0.6 17 | spreg==1.0.4 18 | numba==0.42 19 | xlrd==1.02 20 | psutil==5.6.0 21 | -------------------------------------------------------------------------------- /resources/img/MGWR-pc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/resources/img/MGWR-pc.ico -------------------------------------------------------------------------------- /resources/img/MGWR.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/resources/img/MGWR.icns -------------------------------------------------------------------------------- /resources/img/MGWR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/resources/img/MGWR.png -------------------------------------------------------------------------------- /resources/screenshots/gui-advGWR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/resources/screenshots/gui-advGWR.png -------------------------------------------------------------------------------- /resources/screenshots/gui-advMGWR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/resources/screenshots/gui-advMGWR.png -------------------------------------------------------------------------------- /resources/screenshots/gui-export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/resources/screenshots/gui-export.png -------------------------------------------------------------------------------- /resources/screenshots/gui-logging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/resources/screenshots/gui-logging.png -------------------------------------------------------------------------------- /resources/screenshots/gui-main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/resources/screenshots/gui-main.png -------------------------------------------------------------------------------- /resources/screenshots/gui-summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ziqi-Li/MGWR-GUI/3b97dbc2b721ce37f48ec21239cc5e5a80632cbf/resources/screenshots/gui-summary.png -------------------------------------------------------------------------------- /resources/ui/advOptGWR.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | advDialog 4 | 5 | 6 | Qt::WindowModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 385 13 | 221 14 | 15 | 16 | 17 | Advanced Options 18 | 19 | 20 | true 21 | 22 | 23 | 24 | 25 | 250 26 | 20 27 | 110 28 | 32 29 | 30 | 31 | 32 | Apply 33 | 34 | 35 | 36 | 37 | 38 | 250 39 | 50 40 | 110 41 | 32 42 | 43 | 44 | 45 | Cancel 46 | 47 | 48 | 49 | 50 | 51 | 10 52 | 60 53 | 221 54 | 51 55 | 56 | 57 | 58 | Monte Carlo test for spatial variability 59 | 60 | 61 | 62 | 63 | 10 64 | 20 65 | 201 66 | 26 67 | 68 | 69 | 70 | 71 | Off 72 | 73 | 74 | 75 | 76 | On (Very Slow) 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 10 85 | 110 86 | 221 87 | 51 88 | 89 | 90 | 91 | Local collinearity diagnostics 92 | 93 | 94 | 95 | 96 | 10 97 | 20 98 | 201 99 | 26 100 | 101 | 102 | 103 | 104 | Off 105 | 106 | 107 | 108 | 109 | On 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 10 118 | 10 119 | 221 120 | 51 121 | 122 | 123 | 124 | Variable standardization 125 | 126 | 127 | 128 | 129 | 10 130 | 20 131 | 201 132 | 26 133 | 134 | 135 | 136 | 137 | On 138 | 139 | 140 | 141 | 142 | Off 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 10 151 | 160 152 | 221 153 | 51 154 | 155 | 156 | 157 | Bandwidth confidence interval 158 | 159 | 160 | 161 | 162 | 10 163 | 20 164 | 201 165 | 26 166 | 167 | 168 | 169 | 170 | Off 171 | 172 | 173 | 174 | 175 | On 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | -------------------------------------------------------------------------------- /resources/ui/advOptGWR_mul.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | advDialog 4 | 5 | 6 | Qt::WindowModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 385 13 | 221 14 | 15 | 16 | 17 | Advanced Options 18 | 19 | 20 | true 21 | 22 | 23 | 24 | 25 | 250 26 | 20 27 | 110 28 | 32 29 | 30 | 31 | 32 | Apply 33 | 34 | 35 | 36 | 37 | 38 | 250 39 | 50 40 | 110 41 | 32 42 | 43 | 44 | 45 | Cancel 46 | 47 | 48 | 49 | 50 | 51 | 10 52 | 60 53 | 221 54 | 51 55 | 56 | 57 | 58 | Monte Carlo test for spatial variability 59 | 60 | 61 | 62 | 63 | 10 64 | 20 65 | 201 66 | 26 67 | 68 | 69 | 70 | 71 | Off 72 | 73 | 74 | 75 | 76 | On (Very Slow) 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 10 85 | 110 86 | 221 87 | 51 88 | 89 | 90 | 91 | Local collinearity diagnostics 92 | 93 | 94 | 95 | 96 | 10 97 | 20 98 | 201 99 | 26 100 | 101 | 102 | 103 | 104 | Off 105 | 106 | 107 | 108 | 109 | On 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 10 118 | 10 119 | 221 120 | 51 121 | 122 | 123 | 124 | Variable standardization 125 | 126 | 127 | 128 | 129 | 10 130 | 20 131 | 201 132 | 26 133 | 134 | 135 | 136 | 137 | On 138 | 139 | 140 | 141 | 142 | Off 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 10 151 | 160 152 | 221 153 | 51 154 | 155 | 156 | 157 | Multiple Comparison Correction 158 | 159 | 160 | 161 | 162 | 10 163 | 20 164 | 201 165 | 26 166 | 167 | 168 | 169 | 170 | None 171 | 172 | 173 | 174 | 175 | Bonferroni 176 | 177 | 178 | 179 | 180 | Sidak 181 | 182 | 183 | 184 | 185 | FDR 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | -------------------------------------------------------------------------------- /resources/ui/advOptMGWR.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | advDialog 4 | 5 | 6 | Qt::WindowModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 480 13 | 231 14 | 15 | 16 | 17 | Advanced Options 18 | 19 | 20 | true 21 | 22 | 23 | 24 | 25 | 250 26 | 10 27 | 221 28 | 51 29 | 30 | 31 | 32 | Measure of Score of Change (SOC) 33 | 34 | 35 | 36 | 37 | 10 38 | 20 39 | 201 40 | 26 41 | 42 | 43 | 44 | 45 | SOC-f 46 | 47 | 48 | 49 | 50 | SOC-RSS 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 10 59 | 60 60 | 221 61 | 51 62 | 63 | 64 | 65 | Initialization 66 | 67 | 68 | 69 | 70 | 10 71 | 20 72 | 201 73 | 26 74 | 75 | 76 | 77 | 78 | GWR estimates 79 | 80 | 81 | 82 | 83 | OLS estimates 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 250 92 | 180 93 | 110 94 | 32 95 | 96 | 97 | 98 | Apply 99 | 100 | 101 | 102 | 103 | 104 | 360 105 | 180 106 | 110 107 | 32 108 | 109 | 110 | 111 | Cancel 112 | 113 | 114 | 115 | 116 | 117 | 250 118 | 60 119 | 221 120 | 51 121 | 122 | 123 | 124 | Convergence threshold 125 | 126 | 127 | 128 | 129 | 10 130 | 20 131 | 201 132 | 26 133 | 134 | 135 | 136 | 137 | 1e-5 138 | 139 | 140 | 141 | 142 | 1e-3 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 10 151 | 10 152 | 221 153 | 51 154 | 155 | 156 | 157 | Variable standardization 158 | 159 | 160 | 161 | 162 | 10 163 | 20 164 | 201 165 | 26 166 | 167 | 168 | 169 | 170 | On 171 | 172 | 173 | 174 | 175 | Off 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 10 184 | 110 185 | 221 186 | 51 187 | 188 | 189 | 190 | Monte Carlo test for spatial variability 191 | 192 | 193 | 194 | 195 | 10 196 | 20 197 | 201 198 | 26 199 | 200 | 201 | 202 | 203 | Off 204 | 205 | 206 | 207 | 208 | On (Very Slow) 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 250 217 | 110 218 | 221 219 | 51 220 | 221 | 222 | 223 | Local collinearity diagnostics 224 | 225 | 226 | 227 | 228 | 10 229 | 20 230 | 201 231 | 26 232 | 233 | 234 | 235 | 236 | Off 237 | 238 | 239 | 240 | 241 | On 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 10 250 | 160 251 | 221 252 | 51 253 | 254 | 255 | 256 | Bandwidths confidence intervals 257 | 258 | 259 | 260 | 261 | 10 262 | 20 263 | 201 264 | 26 265 | 266 | 267 | 268 | 269 | Off 270 | 271 | 272 | 273 | 274 | On 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | -------------------------------------------------------------------------------- /resources/ui/advOptMGWR_mul.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | advDialog 4 | 5 | 6 | Qt::WindowModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 480 13 | 231 14 | 15 | 16 | 17 | Advanced Options 18 | 19 | 20 | true 21 | 22 | 23 | 24 | 25 | 250 26 | 10 27 | 221 28 | 51 29 | 30 | 31 | 32 | Measure of Score of Change (SOC) 33 | 34 | 35 | 36 | 37 | 10 38 | 20 39 | 201 40 | 26 41 | 42 | 43 | 44 | 45 | SOC-f 46 | 47 | 48 | 49 | 50 | SOC-RSS 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 10 59 | 60 60 | 221 61 | 51 62 | 63 | 64 | 65 | Initialization 66 | 67 | 68 | 69 | 70 | 10 71 | 20 72 | 201 73 | 26 74 | 75 | 76 | 77 | 78 | GWR estimates 79 | 80 | 81 | 82 | 83 | OLS estimates 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 250 92 | 180 93 | 110 94 | 32 95 | 96 | 97 | 98 | Apply 99 | 100 | 101 | 102 | 103 | 104 | 360 105 | 180 106 | 110 107 | 32 108 | 109 | 110 | 111 | Cancel 112 | 113 | 114 | 115 | 116 | 117 | 250 118 | 60 119 | 221 120 | 51 121 | 122 | 123 | 124 | Convergence threshold 125 | 126 | 127 | 128 | 129 | 10 130 | 20 131 | 201 132 | 26 133 | 134 | 135 | 136 | 137 | 1e-5 138 | 139 | 140 | 141 | 142 | 1e-3 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 10 151 | 10 152 | 221 153 | 51 154 | 155 | 156 | 157 | Variable standardization 158 | 159 | 160 | 161 | 162 | 10 163 | 20 164 | 201 165 | 26 166 | 167 | 168 | 169 | 170 | On 171 | 172 | 173 | 174 | 175 | Off 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 10 184 | 110 185 | 221 186 | 51 187 | 188 | 189 | 190 | Monte Carlo test for spatial variability 191 | 192 | 193 | 194 | 195 | 10 196 | 20 197 | 201 198 | 26 199 | 200 | 201 | 202 | 203 | Off 204 | 205 | 206 | 207 | 208 | On (Very Slow) 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 250 217 | 110 218 | 221 219 | 51 220 | 221 | 222 | 223 | Local collinearity diagnostics 224 | 225 | 226 | 227 | 228 | 10 229 | 20 230 | 201 231 | 26 232 | 233 | 234 | 235 | 236 | Off 237 | 238 | 239 | 240 | 241 | On 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 10 250 | 160 251 | 221 252 | 51 253 | 254 | 255 | 256 | Multiple Comparison Correction 257 | 258 | 259 | 260 | 261 | 10 262 | 20 263 | 201 264 | 26 265 | 266 | 267 | 268 | 269 | None 270 | 271 | 272 | 273 | 274 | Bonferroni 275 | 276 | 277 | 278 | 279 | Sidak 280 | 281 | 282 | 283 | 284 | FDR 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | -------------------------------------------------------------------------------- /resources/ui/loader.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | runningDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 501 10 | 351 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | MGWR Running 21 | 22 | 23 | true 24 | 25 | 26 | 27 | 28 | 110 29 | 60 30 | 50 31 | 50 32 | 33 | 34 | 35 | Qt::LeftToRight 36 | 37 | 38 | 39 | 40 | 41 | Qt::AlignCenter 42 | 43 | 44 | 45 | 46 | 47 | 10 48 | 10 49 | 481 50 | 331 51 | 52 | 53 | 54 | 55 | 20 56 | 57 | 58 | 59 | 60 | 61 | 62 | Time Elapsed: 63 | 64 | 65 | 66 | 67 | 68 | 69 | 00:00:00 70 | 71 | 72 | Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /resources/ui/running_now.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | runningDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 270 10 | 144 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | 50 23 | 30 24 | 171 25 | 21 26 | 27 | 28 | 29 | 30 | 31 | 32 | Time Elapsed: 33 | 34 | 35 | 36 | 37 | 38 | 39 | 00:00:00 40 | 41 | 42 | Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 110 52 | 60 53 | 50 54 | 50 55 | 56 | 57 | 58 | Qt::LeftToRight 59 | 60 | 61 | 62 | 63 | 64 | Qt::AlignCenter 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/advancedGWR.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'advanced.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.9 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt5 import QtCore, QtGui, QtWidgets 10 | 11 | class Ui_advGWRDialog(object): 12 | def setupUi(self, advDialog): 13 | advDialog.setObjectName("advDialog") 14 | advDialog.setWindowModality(QtCore.Qt.WindowModal) 15 | advDialog.resize(385, 221) 16 | advDialog.setModal(True) 17 | self.applyBTN = QtWidgets.QPushButton(advDialog) 18 | self.applyBTN.setGeometry(QtCore.QRect(250, 20, 110, 32)) 19 | self.applyBTN.setObjectName("applyBTN") 20 | self.resetBTN = QtWidgets.QPushButton(advDialog) 21 | self.resetBTN.setGeometry(QtCore.QRect(250, 50, 110, 32)) 22 | self.resetBTN.setObjectName("resetBTN") 23 | self.groupBox_4 = QtWidgets.QGroupBox(advDialog) 24 | self.groupBox_4.setGeometry(QtCore.QRect(10, 60, 221, 51)) 25 | self.groupBox_4.setObjectName("groupBox_4") 26 | self.mcComboBox = QtWidgets.QComboBox(self.groupBox_4) 27 | self.mcComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 28 | self.mcComboBox.setObjectName("mcComboBox") 29 | self.mcComboBox.addItem("") 30 | self.mcComboBox.addItem("") 31 | self.groupBox_5 = QtWidgets.QGroupBox(advDialog) 32 | self.groupBox_5.setGeometry(QtCore.QRect(10, 110, 221, 51)) 33 | self.groupBox_5.setObjectName("groupBox_5") 34 | self.locollinearComboBox = QtWidgets.QComboBox(self.groupBox_5) 35 | self.locollinearComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 36 | self.locollinearComboBox.setObjectName("locollinearComboBox") 37 | self.locollinearComboBox.addItem("") 38 | self.locollinearComboBox.addItem("") 39 | self.SOCBox_2 = QtWidgets.QGroupBox(advDialog) 40 | self.SOCBox_2.setGeometry(QtCore.QRect(10, 10, 221, 51)) 41 | self.SOCBox_2.setObjectName("SOCBox_2") 42 | self.varSTDComboBox = QtWidgets.QComboBox(self.SOCBox_2) 43 | self.varSTDComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 44 | self.varSTDComboBox.setObjectName("varSTDComboBox") 45 | self.varSTDComboBox.addItem("") 46 | self.varSTDComboBox.addItem("") 47 | self.groupBox_6 = QtWidgets.QGroupBox(advDialog) 48 | self.groupBox_6.setGeometry(QtCore.QRect(10, 160, 221, 51)) 49 | self.groupBox_6.setObjectName("groupBox_6") 50 | self.bwciComboBox = QtWidgets.QComboBox(self.groupBox_6) 51 | self.bwciComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 52 | self.bwciComboBox.setObjectName("bwciComboBox") 53 | self.bwciComboBox.addItem("") 54 | self.bwciComboBox.addItem("") 55 | 56 | ''' 57 | self.groupBox_6 = QtWidgets.QGroupBox(advDialog) 58 | self.groupBox_6.setGeometry(QtCore.QRect(10, 160, 221, 51)) 59 | self.groupBox_6.setObjectName("groupBox_6") 60 | self.mccComboBox = QtWidgets.QComboBox(self.groupBox_6) 61 | self.mccComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 62 | self.mccComboBox.setObjectName("mccComboBox") 63 | self.mccComboBox.addItem("") 64 | self.mccComboBox.addItem("") 65 | self.mccComboBox.addItem("") 66 | self.mccComboBox.addItem("") 67 | ''' 68 | 69 | 70 | self.advDialog = advDialog 71 | self.mcTest = "Off" 72 | self.varSTD = "On" 73 | self.locollinear = "Off" 74 | self.bw_ci = "Off" 75 | #self.mcc = "None" 76 | 77 | self.retranslateUi(advDialog) 78 | QtCore.QMetaObject.connectSlotsByName(advDialog) 79 | 80 | def retranslateUi(self, advDialog): 81 | _translate = QtCore.QCoreApplication.translate 82 | advDialog.setWindowTitle(_translate("advDialog", "Advanced Options")) 83 | self.applyBTN.setText(_translate("advDialog", "Apply")) 84 | self.resetBTN.setText(_translate("advDialog", "Reset")) 85 | self.groupBox_4.setTitle(_translate("advDialog", "Monte Carlo test for spatial variability")) 86 | self.mcComboBox.setItemText(0, _translate("advDialog", "Off")) 87 | self.mcComboBox.setItemText(1, _translate("advDialog", "On (Very Slow)")) 88 | self.groupBox_5.setTitle(_translate("advDialog", "Local collinearity diagnostics")) 89 | self.locollinearComboBox.setItemText(0, _translate("advDialog", "Off")) 90 | self.locollinearComboBox.setItemText(1, _translate("advDialog", "On")) 91 | self.SOCBox_2.setTitle(_translate("advDialog", "Variable standardization")) 92 | self.varSTDComboBox.setItemText(0, _translate("advDialog", "On")) 93 | self.varSTDComboBox.setItemText(1, _translate("advDialog", "Off")) 94 | self.groupBox_6.setTitle(_translate("advDialog", "Bandwidth confidence interval")) 95 | self.bwciComboBox.setItemText(0, _translate("advDialog", "Off")) 96 | self.bwciComboBox.setItemText(1, _translate("advDialog", "On")) 97 | ''' 98 | self.groupBox_6.setTitle(_translate("advDialog", "Multiple comparison correction")) 99 | self.mccComboBox.setItemText(0, _translate("advDialog", "None")) 100 | self.mccComboBox.setItemText(1, _translate("advDialog", "Bonferroni")) 101 | self.mccComboBox.setItemText(2, _translate("advDialog", "Sidak")) 102 | self.mccComboBox.setItemText(3, _translate("advDialog", "FDR")) 103 | ''' 104 | 105 | 106 | def loadSettings(self): 107 | 108 | if self.locollinear == "Off": 109 | self.locollinearComboBox.setCurrentIndex(0) 110 | else: 111 | self.locollinearComboBox.setCurrentIndex(1) 112 | 113 | if self.mcTest == "Off": 114 | self.mcComboBox.setCurrentIndex(0) 115 | else: 116 | self.mcComboBox.setCurrentIndex(1) 117 | 118 | if self.varSTD == "On": 119 | self.varSTDComboBox.setCurrentIndex(0) 120 | else: 121 | self.varSTDComboBox.setCurrentIndex(1) 122 | 123 | if self.bw_ci == "Off": 124 | self.bwciComboBox.setCurrentIndex(0) 125 | else: 126 | self.bwciComboBox.setCurrentIndex(1) 127 | 128 | ''' 129 | if self.mcc == "None": 130 | self.mccComboBox.setCurrentIndex(0) 131 | elif self.mcc == "Bonferroni": 132 | self.mccComboBox.setCurrentIndex(1) 133 | elif self.mcc == "Sidak": 134 | self.mccComboBox.setCurrentIndex(2) 135 | elif self.mcc == "FDR": 136 | self.mccComboBox.setCurrentIndex(3) 137 | ''' 138 | 139 | def addActionsToUI(self): 140 | self.applyBTN.clicked.connect(self.applyOnClick) 141 | self.resetBTN.clicked.connect(self.resetOnClick) 142 | 143 | def applyOnClick(self): 144 | self.varSTD = self.varSTDComboBox.currentText() 145 | self.locollinear = self.locollinearComboBox.currentText() 146 | self.mcTest = self.mcComboBox.currentText() 147 | self.bw_ci = self.bwciComboBox.currentText() 148 | #self.mcc = self.mccComboBox.currentText() 149 | self.advDialog.close() 150 | 151 | def resetOnClick(self): 152 | self.varSTDComboBox.setCurrentIndex(0) 153 | self.locollinearComboBox.setCurrentIndex(0) 154 | self.mcComboBox.setCurrentIndex(0) 155 | self.bwciComboBox.setCurrentIndex(0) 156 | #self.mccComboBox.setCurrentIndex(0) 157 | 158 | 159 | -------------------------------------------------------------------------------- /src/advancedGWR_withmcc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'advanced.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.9 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt5 import QtCore, QtGui, QtWidgets 10 | 11 | class Ui_advGWRDialog(object): 12 | def setupUi(self, advDialog): 13 | advDialog.setObjectName("advDialog") 14 | advDialog.setWindowModality(QtCore.Qt.WindowModal) 15 | advDialog.resize(385, 221) 16 | advDialog.setModal(True) 17 | self.applyBTN = QtWidgets.QPushButton(advDialog) 18 | self.applyBTN.setGeometry(QtCore.QRect(250, 20, 110, 32)) 19 | self.applyBTN.setObjectName("applyBTN") 20 | self.resetBTN = QtWidgets.QPushButton(advDialog) 21 | self.resetBTN.setGeometry(QtCore.QRect(250, 50, 110, 32)) 22 | self.resetBTN.setObjectName("resetBTN") 23 | self.groupBox_4 = QtWidgets.QGroupBox(advDialog) 24 | self.groupBox_4.setGeometry(QtCore.QRect(10, 60, 221, 51)) 25 | self.groupBox_4.setObjectName("groupBox_4") 26 | self.mcComboBox = QtWidgets.QComboBox(self.groupBox_4) 27 | self.mcComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 28 | self.mcComboBox.setObjectName("mcComboBox") 29 | self.mcComboBox.addItem("") 30 | self.mcComboBox.addItem("") 31 | self.groupBox_5 = QtWidgets.QGroupBox(advDialog) 32 | self.groupBox_5.setGeometry(QtCore.QRect(10, 110, 221, 51)) 33 | self.groupBox_5.setObjectName("groupBox_5") 34 | self.locollinearComboBox = QtWidgets.QComboBox(self.groupBox_5) 35 | self.locollinearComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 36 | self.locollinearComboBox.setObjectName("locollinearComboBox") 37 | self.locollinearComboBox.addItem("") 38 | self.locollinearComboBox.addItem("") 39 | self.SOCBox_2 = QtWidgets.QGroupBox(advDialog) 40 | self.SOCBox_2.setGeometry(QtCore.QRect(10, 10, 221, 51)) 41 | self.SOCBox_2.setObjectName("SOCBox_2") 42 | self.varSTDComboBox = QtWidgets.QComboBox(self.SOCBox_2) 43 | self.varSTDComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 44 | self.varSTDComboBox.setObjectName("varSTDComboBox") 45 | self.varSTDComboBox.addItem("") 46 | self.varSTDComboBox.addItem("") 47 | self.groupBox_6 = QtWidgets.QGroupBox(advDialog) 48 | self.groupBox_6.setGeometry(QtCore.QRect(10, 160, 221, 51)) 49 | self.groupBox_6.setObjectName("groupBox_6") 50 | self.mccComboBox = QtWidgets.QComboBox(self.groupBox_6) 51 | self.mccComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 52 | self.mccComboBox.setObjectName("mccComboBox") 53 | self.mccComboBox.addItem("") 54 | self.mccComboBox.addItem("") 55 | self.mccComboBox.addItem("") 56 | self.mccComboBox.addItem("") 57 | 58 | 59 | self.advDialog = advDialog 60 | self.mcTest = "Off" 61 | self.varSTD = "On" 62 | self.locollinear = "Off" 63 | self.mcc = "None" 64 | 65 | self.retranslateUi(advDialog) 66 | QtCore.QMetaObject.connectSlotsByName(advDialog) 67 | 68 | def retranslateUi(self, advDialog): 69 | _translate = QtCore.QCoreApplication.translate 70 | advDialog.setWindowTitle(_translate("advDialog", "Advanced Options")) 71 | self.applyBTN.setText(_translate("advDialog", "Apply")) 72 | self.resetBTN.setText(_translate("advDialog", "Reset")) 73 | self.groupBox_4.setTitle(_translate("advDialog", "Monte Carlo test for spatial variability")) 74 | self.mcComboBox.setItemText(0, _translate("advDialog", "Off")) 75 | self.mcComboBox.setItemText(1, _translate("advDialog", "On (Very Slow)")) 76 | self.groupBox_5.setTitle(_translate("advDialog", "Local collinearity diagnostics")) 77 | self.locollinearComboBox.setItemText(0, _translate("advDialog", "Off")) 78 | self.locollinearComboBox.setItemText(1, _translate("advDialog", "On")) 79 | self.SOCBox_2.setTitle(_translate("advDialog", "Variable standardization")) 80 | self.varSTDComboBox.setItemText(0, _translate("advDialog", "On")) 81 | self.varSTDComboBox.setItemText(1, _translate("advDialog", "Off")) 82 | self.groupBox_6.setTitle(_translate("advDialog", "Multiple comparison correction")) 83 | self.mccComboBox.setItemText(0, _translate("advDialog", "None")) 84 | self.mccComboBox.setItemText(1, _translate("advDialog", "Bonferroni")) 85 | self.mccComboBox.setItemText(2, _translate("advDialog", "Sidak")) 86 | self.mccComboBox.setItemText(3, _translate("advDialog", "FDR")) 87 | 88 | 89 | def loadSettings(self): 90 | 91 | if self.locollinear == "Off": 92 | self.locollinearComboBox.setCurrentIndex(0) 93 | else: 94 | self.locollinearComboBox.setCurrentIndex(1) 95 | 96 | if self.mcTest == "Off": 97 | self.mcComboBox.setCurrentIndex(0) 98 | else: 99 | self.mcComboBox.setCurrentIndex(1) 100 | 101 | if self.varSTD == "On": 102 | self.varSTDComboBox.setCurrentIndex(0) 103 | else: 104 | self.varSTDComboBox.setCurrentIndex(1) 105 | 106 | if self.mcc == "None": 107 | self.mccComboBox.setCurrentIndex(0) 108 | elif self.mcc == "Bonferroni": 109 | self.mccComboBox.setCurrentIndex(1) 110 | elif self.mcc == "Sidak": 111 | self.mccComboBox.setCurrentIndex(2) 112 | elif self.mcc == "FDR": 113 | self.mccComboBox.setCurrentIndex(3) 114 | 115 | 116 | def addActionsToUI(self): 117 | self.applyBTN.clicked.connect(self.applyOnClick) 118 | self.resetBTN.clicked.connect(self.resetOnClick) 119 | 120 | def applyOnClick(self): 121 | self.varSTD = self.varSTDComboBox.currentText() 122 | self.locollinear = self.locollinearComboBox.currentText() 123 | self.mcTest = self.mcComboBox.currentText() 124 | self.mcc = self.mccComboBox.currentText() 125 | self.advDialog.close() 126 | 127 | def resetOnClick(self): 128 | self.varSTDComboBox.setCurrentIndex(0) 129 | self.locollinearComboBox.setCurrentIndex(0) 130 | self.mcComboBox.setCurrentIndex(0) 131 | self.mccComboBox.setCurrentIndex(0) 132 | 133 | 134 | -------------------------------------------------------------------------------- /src/advancedMGWR_withmcc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'advanced.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.9 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt5 import QtCore, QtGui, QtWidgets 10 | 11 | class Ui_advMGWRDialog(object): 12 | def setupUi(self, advDialog): 13 | advDialog.setObjectName("advDialog") 14 | advDialog.setWindowModality(QtCore.Qt.WindowModal) 15 | advDialog.resize(480, 231) 16 | advDialog.setModal(True) 17 | self.SOCBox = QtWidgets.QGroupBox(advDialog) 18 | self.SOCBox.setGeometry(QtCore.QRect(250, 10, 221, 51)) 19 | self.SOCBox.setObjectName("SOCBox") 20 | self.SOCComboBox = QtWidgets.QComboBox(self.SOCBox) 21 | self.SOCComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 22 | self.SOCComboBox.setObjectName("SOCComboBox") 23 | self.SOCComboBox.addItem("") 24 | self.SOCComboBox.addItem("") 25 | self.groupBox_2 = QtWidgets.QGroupBox(advDialog) 26 | self.groupBox_2.setGeometry(QtCore.QRect(10, 60, 221, 51)) 27 | self.groupBox_2.setObjectName("groupBox_2") 28 | self.initComboBox = QtWidgets.QComboBox(self.groupBox_2) 29 | self.initComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 30 | self.initComboBox.setObjectName("initComboBox") 31 | self.initComboBox.addItem("") 32 | self.initComboBox.addItem("") 33 | self.applyBTN = QtWidgets.QPushButton(advDialog) 34 | self.applyBTN.setGeometry(QtCore.QRect(250, 180, 110, 32)) 35 | self.applyBTN.setObjectName("applyBTN") 36 | self.resetBTN = QtWidgets.QPushButton(advDialog) 37 | self.resetBTN.setGeometry(QtCore.QRect(360, 180, 110, 32)) 38 | self.resetBTN.setObjectName("resetBTN") 39 | self.groupBox_3 = QtWidgets.QGroupBox(advDialog) 40 | self.groupBox_3.setGeometry(QtCore.QRect(250, 60, 221, 51)) 41 | self.groupBox_3.setObjectName("groupBox_3") 42 | self.convComboBox = QtWidgets.QComboBox(self.groupBox_3) 43 | self.convComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 44 | self.convComboBox.setObjectName("convComboBox") 45 | self.convComboBox.addItem("") 46 | self.convComboBox.addItem("") 47 | self.SOCBox_2 = QtWidgets.QGroupBox(advDialog) 48 | self.SOCBox_2.setGeometry(QtCore.QRect(10, 10, 221, 51)) 49 | self.SOCBox_2.setObjectName("SOCBox_2") 50 | self.varSTDComboBox = QtWidgets.QComboBox(self.SOCBox_2) 51 | self.varSTDComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 52 | self.varSTDComboBox.setObjectName("varSTDComboBox") 53 | self.varSTDComboBox.addItem("") 54 | self.varSTDComboBox.addItem("") 55 | self.groupBox_4 = QtWidgets.QGroupBox(advDialog) 56 | self.groupBox_4.setGeometry(QtCore.QRect(10, 110, 221, 51)) 57 | self.groupBox_4.setObjectName("groupBox_4") 58 | self.mcComboBox = QtWidgets.QComboBox(self.groupBox_4) 59 | self.mcComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 60 | self.mcComboBox.setObjectName("mcComboBox") 61 | self.mcComboBox.addItem("") 62 | self.mcComboBox.addItem("") 63 | self.groupBox_5 = QtWidgets.QGroupBox(advDialog) 64 | self.groupBox_5.setGeometry(QtCore.QRect(250, 110, 221, 51)) 65 | self.groupBox_5.setObjectName("groupBox_5") 66 | self.locollinearComboBox = QtWidgets.QComboBox(self.groupBox_5) 67 | self.locollinearComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 68 | self.locollinearComboBox.setObjectName("locollinearComboBox") 69 | self.locollinearComboBox.addItem("") 70 | self.locollinearComboBox.addItem("") 71 | self.groupBox_6 = QtWidgets.QGroupBox(advDialog) 72 | self.groupBox_6.setGeometry(QtCore.QRect(10, 160, 221, 51)) 73 | self.groupBox_6.setObjectName("groupBox_6") 74 | self.mccComboBox = QtWidgets.QComboBox(self.groupBox_6) 75 | self.mccComboBox.setGeometry(QtCore.QRect(10, 20, 201, 26)) 76 | self.mccComboBox.setObjectName("mccComboBox") 77 | self.mccComboBox.addItem("") 78 | self.mccComboBox.addItem("") 79 | self.mccComboBox.addItem("") 80 | self.mccComboBox.addItem("") 81 | 82 | 83 | self.advDialog = advDialog 84 | self.varSTD = "On" 85 | self.mcTest = "Off" 86 | self.locollinear = "Off" 87 | self.soc = "SOC-f" 88 | self.init = "GWR estimates" 89 | self.converg = "1e-5" 90 | self.mcc = "None" 91 | 92 | self.retranslateUi(advDialog) 93 | QtCore.QMetaObject.connectSlotsByName(advDialog) 94 | 95 | def retranslateUi(self, advDialog): 96 | _translate = QtCore.QCoreApplication.translate 97 | advDialog.setWindowTitle(_translate("advDialog", "Advanced Options")) 98 | self.SOCBox.setTitle(_translate("advDialog", "Measure of Score of Change (SOC)")) 99 | self.SOCComboBox.setItemText(0, _translate("advDialog", "SOC-f")) 100 | self.SOCComboBox.setItemText(1, _translate("advDialog", "SOC-RSS")) 101 | self.groupBox_2.setTitle(_translate("advDialog", "Initialization")) 102 | self.initComboBox.setItemText(0, _translate("advDialog", "GWR estimates")) 103 | self.initComboBox.setItemText(1, _translate("advDialog", "OLS estimates")) 104 | self.applyBTN.setText(_translate("advDialog", "Apply")) 105 | self.resetBTN.setText(_translate("advDialog", "Reset")) 106 | self.groupBox_3.setTitle(_translate("advDialog", "Convergence threshold")) 107 | self.convComboBox.setItemText(0, _translate("advDialog", "1e-5")) 108 | self.convComboBox.setItemText(1, _translate("advDialog", "1e-3")) 109 | self.SOCBox_2.setTitle(_translate("advDialog", "Variable standardization")) 110 | self.varSTDComboBox.setItemText(0, _translate("advDialog", "On")) 111 | self.varSTDComboBox.setItemText(1, _translate("advDialog", "Off")) 112 | self.groupBox_4.setTitle(_translate("advDialog", "Monte Carlo test for spatial variability")) 113 | self.mcComboBox.setItemText(0, _translate("advDialog", "Off")) 114 | self.mcComboBox.setItemText(1, _translate("advDialog", "On (Very Slow)")) 115 | self.groupBox_5.setTitle(_translate("advDialog", "Local collinearity diagnostics")) 116 | self.locollinearComboBox.setItemText(0, _translate("advDialog", "Off")) 117 | self.locollinearComboBox.setItemText(1, _translate("advDialog", "On")) 118 | self.groupBox_6.setTitle(_translate("advDialog", "Multiple comparison correction")) 119 | self.mccComboBox.setItemText(0, _translate("advDialog", "None")) 120 | self.mccComboBox.setItemText(1, _translate("advDialog", "Bonferroni")) 121 | self.mccComboBox.setItemText(2, _translate("advDialog", "Sidak")) 122 | self.mccComboBox.setItemText(3, _translate("advDialog", "FDR")) 123 | 124 | def loadSettings(self): 125 | 126 | if self.locollinear == "Off": 127 | self.locollinearComboBox.setCurrentIndex(0) 128 | else: 129 | self.locollinearComboBox.setCurrentIndex(1) 130 | 131 | if self.mcTest == "Off": 132 | self.mcComboBox.setCurrentIndex(0) 133 | else: 134 | self.mcComboBox.setCurrentIndex(1) 135 | 136 | if self.varSTD == "On": 137 | self.varSTDComboBox.setCurrentIndex(0) 138 | else: 139 | self.varSTDComboBox.setCurrentIndex(1) 140 | 141 | if self.soc == "SOC-f": 142 | self.SOCComboBox.setCurrentIndex(0) 143 | else: 144 | self.SOCComboBox.setCurrentIndex(1) 145 | 146 | if self.init == "GWR estimates": 147 | self.initComboBox.setCurrentIndex(0) 148 | else: 149 | self.initComboBox.setCurrentIndex(1) 150 | 151 | if self.converg == "1e-5": 152 | self.convComboBox.setCurrentIndex(0) 153 | else: 154 | self.convComboBox.setCurrentIndex(1) 155 | 156 | if self.mcc == "None": 157 | self.mccComboBox.setCurrentIndex(0) 158 | elif self.mcc == "Bonferroni": 159 | self.mccComboBox.setCurrentIndex(1) 160 | elif self.mcc == "Sidak": 161 | self.mccComboBox.setCurrentIndex(2) 162 | elif self.mcc == "FDR": 163 | self.mccComboBox.setCurrentIndex(3) 164 | 165 | 166 | def addActionsToUI(self): 167 | self.applyBTN.clicked.connect(self.applyOnClick) 168 | self.resetBTN.clicked.connect(self.resetOnClick) 169 | 170 | def applyOnClick(self): 171 | self.varSTD = self.varSTDComboBox.currentText() 172 | self.soc = self.SOCComboBox.currentText() 173 | self.init = self.initComboBox.currentText() 174 | self.converg = self.convComboBox.currentText() 175 | self.locollinear = self.locollinearComboBox.currentText() 176 | self.mcTest = self.mcComboBox.currentText() 177 | self.mcc = self.mccComboBox.currentText() 178 | 179 | self.advDialog.close() 180 | 181 | def resetOnClick(self): 182 | self.locollinearComboBox.setCurrentIndex(0) 183 | self.mcComboBox.setCurrentIndex(0) 184 | self.varSTDComboBox.setCurrentIndex(0) 185 | self.SOCComboBox.setCurrentIndex(0) 186 | self.initComboBox.setCurrentIndex(0) 187 | self.convComboBox.setCurrentIndex(0) 188 | self.mccComboBox.setCurrentIndex(0) 189 | 190 | 191 | -------------------------------------------------------------------------------- /src/loader.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'loader.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.9 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt5 import QtCore, QtGui, QtWidgets 10 | import sys,os 11 | 12 | class Ui_runningDialog(object): 13 | def setupUi(self, runningDialog): 14 | runningDialog.setObjectName("runningDialog") 15 | runningDialog.resize(501, 351) 16 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) 17 | sizePolicy.setHorizontalStretch(0) 18 | sizePolicy.setVerticalStretch(0) 19 | sizePolicy.setHeightForWidth(runningDialog.sizePolicy().hasHeightForWidth()) 20 | runningDialog.setSizePolicy(sizePolicy) 21 | runningDialog.setModal(True) 22 | self.loadingGIFLabel = QtWidgets.QLabel(runningDialog) 23 | self.loadingGIFLabel.setGeometry(QtCore.QRect(110, 60, 50, 50)) 24 | self.loadingGIFLabel.setLayoutDirection(QtCore.Qt.LeftToRight) 25 | self.loadingGIFLabel.setText("") 26 | self.loadingGIFLabel.setAlignment(QtCore.Qt.AlignCenter) 27 | self.loadingGIFLabel.setObjectName("loadingGIFLabel") 28 | self.gridLayoutWidget = QtWidgets.QWidget(runningDialog) 29 | self.gridLayoutWidget.setGeometry(QtCore.QRect(10, 10, 481, 331)) 30 | self.gridLayoutWidget.setObjectName("gridLayoutWidget") 31 | self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget) 32 | self.gridLayout.setContentsMargins(20, 20, 20, 20) 33 | self.gridLayout.setObjectName("gridLayout") 34 | self.horizontalLayout = QtWidgets.QHBoxLayout() 35 | self.horizontalLayout.setObjectName("horizontalLayout") 36 | self.label = QtWidgets.QLabel(self.gridLayoutWidget) 37 | self.label.setObjectName("label") 38 | self.horizontalLayout.addWidget(self.label) 39 | self.label_2 = QtWidgets.QLabel(self.gridLayoutWidget) 40 | self.label_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) 41 | self.label_2.setObjectName("label_2") 42 | self.horizontalLayout.addWidget(self.label_2) 43 | self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1) 44 | self.printTextEdit = QtWidgets.QTextEdit(self.gridLayoutWidget) 45 | self.printTextEdit.setObjectName("printTextEdit") 46 | self.gridLayout.addWidget(self.printTextEdit, 1, 0, 1, 1) 47 | runningDialog.setLayout(self.gridLayout) 48 | 49 | 50 | 51 | 52 | """ 53 | self.movie = QtGui.QMovie(resource_path("img/loader-50.gif"), QtCore.QByteArray()) 54 | self.movie.setCacheMode(QtGui.QMovie.CacheAll) 55 | self.movie.setSpeed(100) 56 | self.loadingGIFLabel.setMovie(self.movie) 57 | self.movie.start() 58 | """ 59 | self.printTextEdit.setReadOnly(True) 60 | self.retranslateUi(runningDialog) 61 | QtCore.QMetaObject.connectSlotsByName(runningDialog) 62 | 63 | def retranslateUi(self, runningDialog): 64 | _translate = QtCore.QCoreApplication.translate 65 | runningDialog.setWindowTitle(_translate("runningDialog", "MGWR Running")) 66 | self.label.setText(_translate("runningDialog", "Time Elapsed:")) 67 | self.label_2.setText(_translate("runningDialog", "00:00:00")) 68 | 69 | def restartTimer(self): 70 | self.printTextEdit.clear() 71 | self.label_2.setText("00:00:00") 72 | 73 | def stopThread(self,thread): 74 | thread.terminate() 75 | 76 | def __init__(self, parent=None, **kwargs): 77 | sys.stdout = EmittingStream(textWritten=self.normalOutputWritten) 78 | 79 | def __del__(self): 80 | sys.stdout = sys.__stdout__ 81 | 82 | def normalOutputWritten(self, text): 83 | cursor = self.printTextEdit.textCursor() 84 | cursor.movePosition(QtGui.QTextCursor.End) 85 | cursor.insertText(text) 86 | self.printTextEdit.setTextCursor(cursor) 87 | self.printTextEdit.ensureCursorVisible() 88 | 89 | def resource_path(relative_path): 90 | if hasattr(sys, '_MEIPASS'): 91 | return os.path.join(sys._MEIPASS, relative_path) 92 | return os.path.join(os.path.abspath("."), relative_path) 93 | 94 | 95 | class EmittingStream(QtCore.QObject): 96 | 97 | textWritten = QtCore.pyqtSignal(str) 98 | 99 | def write(self, text): 100 | self.textWritten.emit(str(text)) 101 | 102 | def flush(self): 103 | pass 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /src/outputs.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'gui.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.9 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt5 import QtCore, QtGui, QtWidgets 10 | from scipy.stats.mstats import mquantiles 11 | from datetime import datetime 12 | import numpy as np 13 | import pandas as pd 14 | from spglm.family import Gaussian, Binomial, Poisson 15 | from mgwrlib.mgwr.summary import * 16 | 17 | 18 | def outputGWR(self): 19 | saveSummaryGWR(self) 20 | saveBetasToCSVGWR(self) 21 | 22 | 23 | def outputMGWR(self): 24 | saveSummaryMGWR(self) 25 | saveBetasToCSVMGWR(self) 26 | #saveProcessToCSVMGWR(self) 27 | 28 | 29 | def saveSummaryGWR(self): 30 | summary = summaryAbout(self) + summaryModel( 31 | self.results, self) + summaryGLM(self.results, self) + summaryGWR( 32 | self.results, self) + summaryACK(self) 33 | with open(self.sumFileSavePath.text(), "w") as text_file: 34 | print(summary, file=text_file) 35 | 36 | 37 | def saveSummaryMGWR(self): 38 | summary = summaryAbout(self) + summaryModel( 39 | self.results, self) + summaryGLM(self.results, self) + summaryMGWR( 40 | self.results, self) + summaryACK(self) 41 | with open(self.sumFileSavePath.text(), "w") as text_file: 42 | print(summary, file=text_file) 43 | 44 | 45 | def saveProcessToCSVMGWR(self): 46 | bw = self.bw 47 | processDF = pd.concat([ 48 | pd.DataFrame(bw.bw[1]), 49 | pd.DataFrame(bw.bw[2]), 50 | pd.DataFrame(bw.bw[3]) 51 | ], 52 | axis=1) 53 | processDF.columns = ['bw_' + x for x in self.XNames 54 | ] + [self.criterion + '_' + x 55 | for x in self.XNames] + [self.SOC] 56 | processDF.to_csv( 57 | self.betaFileSavePath.text()[:-10] + '_process.csv', 58 | sep=',', 59 | index=True) 60 | 61 | 62 | def saveBetasToCSVMGWR(self): 63 | resultsDF = pd.DataFrame( 64 | np.column_stack( 65 | (self.id, self.xCoor, self.yCoor, self.y, self.glm_rslt.resid_response, self.results.predy, 66 | self.results.resid_response, self.results.localR2,self.results.params, 67 | self.results.bse, self.results.tvalues, self.results.pvalues, self.results.sumW))) 68 | resultsDF.columns = [self.idName] + [ 69 | 'x_coor', 'y_coor', 'y', 'ols_residual','mgwr_yhat', 'mgwr_residual','localR2' 70 | ] + ['beta_' + x for x in self.XNames] + [ 71 | 'se_' + x for x in self.XNames 72 | ] + ['t_' + x for x in self.XNames] + ['p_' + x for x in self.XNames] + ['sumW_' + x for x in self.XNames] 73 | 74 | if self.locollinear != "Off": 75 | old_columns = resultsDF.columns 76 | resultsDF = pd.concat([ 77 | resultsDF, 78 | pd.DataFrame( 79 | np.column_stack([ 80 | self.locollinearResults[-2], self.locollinearResults[-1] 81 | ])) 82 | ], 83 | axis=1) 84 | resultsDF.columns = list(old_columns) + ['local_CN'] + [ 85 | 'local_vdp_' + x for x in self.XNames 86 | ] 87 | 88 | resultsDF.to_csv(self.betaFileSavePath.text(), sep=',', index=False) 89 | 90 | 91 | def saveBetasToCSVGWR(self): 92 | if isinstance(self.family, Gaussian): 93 | resultsDF = pd.DataFrame( 94 | np.column_stack( 95 | (self.id, self.xCoor, self.yCoor, self.y, self.glm_rslt.resid_response, self.results.predy, 96 | self.results.resid_response, self.results.localR2, 97 | self.results.influ, self.results.cooksD, self.results.params, 98 | self.results.bse, self.results.tvalues, 99 | self.results.pvalues, self.results.sumW))) 100 | resultsDF.columns = [self.idName] + [ 101 | 'x_coor', 'y_coor', 'y', 'ols_residual', 'gwr_yhat', 'gwr_residual', 'localR2', 'influ', 102 | 'CooksD' 103 | ] + ['beta_' + x for x in self.XNames] + [ 104 | 'se_' + x for x in self.XNames 105 | ] + ['t_' + x for x in self.XNames] + ['p_' + x for x in self.XNames] + ['sumW'] 106 | else: 107 | resultsDF = pd.DataFrame( 108 | np.column_stack( 109 | (self.id, self.xCoor, self.yCoor, self.y, self.results.predy, 110 | self.results.resid_response, self.results.pDev, 111 | self.results.influ, self.results.cooksD, self.results.params, 112 | self.results.bse, self.results.tvalues, 113 | self.results.pvalues))) 114 | resultsDF.columns = [self.idName] + [ 115 | 'x_coor', 'y_coor', 'y', 'gwr_yhat', 'gwr_residual', 'pDev', 'influ', 116 | 'CooksD' 117 | ] + ['beta_' + x for x in self.XNames] + [ 118 | 'se_' + x for x in self.XNames 119 | ] + ['t_' + x for x in self.XNames] + ['p_' + x for x in self.XNames] 120 | 121 | if self.locollinear != "Off": 122 | old_columns = resultsDF.columns 123 | names = self.XNames 124 | if "Intercept" in self.XNames: 125 | names = self.XNames[1:] 126 | resultsDF = pd.concat([ 127 | resultsDF, 128 | pd.DataFrame( 129 | np.column_stack([ 130 | self.locollinearResults[-2], self.locollinearResults[-3], 131 | self.locollinearResults[-1] 132 | ])) 133 | ], 134 | axis=1) 135 | resultsDF.columns = list(old_columns) + ['local_CN'] + [ 136 | 'local_vif_' + x for x in names 137 | ] + ['local_vdp_' + x for x in self.XNames] 138 | 139 | resultsDF.to_csv(self.betaFileSavePath.text(), sep=',', index=False) 140 | -------------------------------------------------------------------------------- /src/summaryGUI.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'summary.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.10 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt5 import QtCore, QtGui, QtWidgets 10 | class Ui_summaryDlg(object): 11 | def setupUi(self, summaryDlg): 12 | 13 | summaryDlg.setObjectName("summaryDlg") 14 | summaryDlg.setWindowModality(QtCore.Qt.WindowModal) 15 | summaryDlg.setEnabled(True) 16 | summaryDlg.resize(750, 400) 17 | 18 | grid = QtWidgets.QGridLayout() 19 | summaryDlg.setLayout(grid) 20 | font = QtGui.QFont() 21 | font.setFamily("Courier New") 22 | font.setPointSize(14) 23 | summaryDlg.setFont(font) 24 | 25 | self.summaryEdit = QtWidgets.QTextEdit() 26 | self.summaryEdit.setReadOnly(True) 27 | grid.addWidget(self.summaryEdit, 0,0) 28 | self.retranslateUi(summaryDlg) 29 | QtCore.QMetaObject.connectSlotsByName(summaryDlg) 30 | 31 | def retranslateUi(self, summaryDlg): 32 | _translate = QtCore.QCoreApplication.translate 33 | summaryDlg.setWindowTitle(_translate("summaryDlg", "Summary")) 34 | 35 | def loadText(self,filePath): 36 | self.summaryEdit.setReadOnly(True) 37 | text=open(filePath).read() 38 | self.summaryEdit.setText(text) 39 | 40 | 41 | 42 | if __name__ == "__main__": 43 | import sys 44 | app = QtWidgets.QApplication(sys.argv) 45 | summaryDlg = QtWidgets.QDialog() 46 | ui = Ui_summaryDlg() 47 | ui.setupUi(summaryDlg) 48 | summaryDlg.show() 49 | sys.exit(app.exec_()) 50 | 51 | --------------------------------------------------------------------------------