diff --git a/courses.md b/courses.md index 291a706..54af62c 100644 --- a/courses.md +++ b/courses.md @@ -1,5 +1,10 @@ ## Courses, Workshops, and Tutorials + +* [SciPy 2018](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=26&cad=rja&uact=8&ved=0ahUKEwjKreXT_abcAhULxVQKHbPsAKkQtwIIYjAZ&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DkJXUUO5M4ok&usg=AOvVaw0fMlkj1OkQEtJZJpOw2t4P) +* [GeoPython 2018](https://github.com/ljwolf/geopython) +* [NARSC 2017](https://www.youtube.com/watch?v=TY4QWnnd4jY) * [SciPy 2016](https://www.youtube.com/watch?v=TY4QWnnd4jY) +* [NARSC 2016](https://github.com/sjsrey/narsc16) * [UCGIS 2016](https://github.com/sjsrey/ucgis_workshop_2016) * [NARSC 2015](http://www.narsc.org/newsite/wp-content/uploads/2012/04/PySAL-tutorial.pdf) * [AUERS 2015](https://github.com/pysal/notebooks/tree/aerus2015) @@ -13,6 +18,7 @@ ## Presentations +* [SciPy 2018](https://www.youtube.com/watch?v=VWMj_rNb0io) * [SciPy 2015](https://www.youtube.com/watch?v=rfQ0LIaOgQs) * [CyberGIS 2013](https://www.youtube.com/watch?v=piB7zTADzcE) * [ESRI UC 2012](http://video.esri.com/watch/1925/integrating-open_dash_source-statistical-packages-with-arcgis) diff --git a/notebooks/PySAL_modules.ipynb b/notebooks/PySAL_modules.ipynb index c2b0afc..c4b6221 100644 --- a/notebooks/PySAL_modules.ipynb +++ b/notebooks/PySAL_modules.ipynb @@ -1,462 +1,493 @@ { - "metadata": { - "name": "PySAL_modules" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ + "cells": [ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Contributors to this notebook\n", - "\n", - "* Daniel Arribas-Bel [@darribas](http://twitter.com/darribas)\n", - "* Serge Rey http://sjrey.org" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import pysal as ps # 1.5 or higher\n", - "import pandas as pd # 0.10 or higher" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 1 - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Specialized modules in `PySAL`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Before we brush through more specialized functionality in `PySAL`, let's load up example data:" - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "dbf = ps.open('data/amsterdam_hoods.dbf')\n", - "db = pd.DataFrame(dict([(col, np.array(dbf.by_col(col))) for col in dbf.header]))\n", - "w = ps.open('data/adam.gal').read()" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## `region`\n", - "\n", - "* Spatial aggregation of areas into regions\n", - "* \"Spatial clustering\"\n", - "* Right now, it implements only the `max-p` algorithm:\n", - " * Duque, J. C., Anselin, L. and Rey, S. J. 2011 [*\"The MAX-P regions problem\"*](http://onlinelibrary.wiley.com/doi/10.1111/j.1467-9787.2011.00743.x/abstract)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example of aggregation of areas using the `max-p`:" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "z = db[[i for i in db.columns if 'h_' in i]].values\n", - "floor_var = db['total'].values[:, None]\n", - "maxp = ps.Maxp(w, z, floor=500, floor_variable=floor_var)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 3 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Cardinalities\n", - "maxp.area2region" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "pyout", - "prompt_number": 4, - "text": [ - "{'0': 49,\n", - " '1': 43,\n", - " '10': 3,\n", - " '11': 46,\n", - " '12': 24,\n", - " '13': 47,\n", - " '14': 37,\n", - " '15': 47,\n", - " '16': 26,\n", - " '17': 32,\n", - " '18': 26,\n", - " '19': 32,\n", - " '2': 42,\n", - " '20': 29,\n", - " '21': 29,\n", - " '22': 17,\n", - " '23': 33,\n", - " '24': 18,\n", - " '25': 5,\n", - " '26': 18,\n", - " '27': 50,\n", - " '28': 18,\n", - " '29': 15,\n", - " '3': 10,\n", - " '30': 15,\n", - " '31': 26,\n", - " '32': 6,\n", - " '33': 26,\n", - " '34': 6,\n", - " '35': 36,\n", - " '36': 36,\n", - " '37': 12,\n", - " '38': 14,\n", - " '39': 12,\n", - " '4': 38,\n", - " '40': 12,\n", - " '41': 12,\n", - " '42': 12,\n", - " '43': 12,\n", - " '44': 12,\n", - " '45': 12,\n", - " '46': 14,\n", - " '47': 12,\n", - " '48': 3,\n", - " '49': 14,\n", - " '5': 24,\n", - " '50': 14,\n", - " '51': 9,\n", - " '52': 9,\n", - " '53': 6,\n", - " '54': 9,\n", - " '55': 9,\n", - " '56': 6,\n", - " '57': 1,\n", - " '58': 1,\n", - " '59': 6,\n", - " '6': 23,\n", - " '60': 1,\n", - " '61': 35,\n", - " '62': 8,\n", - " '63': 11,\n", - " '64': 25,\n", - " '65': 19,\n", - " '66': 0,\n", - " '67': 4,\n", - " '68': 4,\n", - " '69': 0,\n", - " '7': 22,\n", - " '70': 4,\n", - " '71': 4,\n", - " '72': 27,\n", - " '73': 20,\n", - " '74': 33,\n", - " '75': 20,\n", - " '76': 28,\n", - " '77': 30,\n", - " '78': 28,\n", - " '79': 44,\n", - " '8': 45,\n", - " '80': 16,\n", - " '81': 2,\n", - " '82': 7,\n", - " '83': 8,\n", - " '84': 29,\n", - " '85': 21,\n", - " '86': 13,\n", - " '87': 41,\n", - " '88': 41,\n", - " '89': 13,\n", - " '9': 39,\n", - " '90': 40,\n", - " '91': 7,\n", - " '92': 40,\n", - " '93': 48,\n", - " '94': 31,\n", - " '95': 34}" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "maxp.regions" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "pyout", - "prompt_number": 5, - "text": [ - "[['69', '66'],\n", - " ['57', '58', '60'],\n", - " ['81'],\n", - " ['10', '48'],\n", - " ['68', '71', '70', '67'],\n", - " ['25'],\n", - " ['59', '56', '53', '32', '34'],\n", - " ['91', '82'],\n", - " ['83', '62'],\n", - " ['52', '51', '55', '54'],\n", - " ['3'],\n", - " ['63'],\n", - " ['47', '44', '41', '37', '45', '42', '43', '40', '39'],\n", - " ['89', '86'],\n", - " ['46', '50', '49', '38'],\n", - " ['29', '30'],\n", - " ['80'],\n", - " ['22'],\n", - " ['24', '26', '28'],\n", - " ['65'],\n", - " ['73', '75'],\n", - " ['85'],\n", - " ['7'],\n", - " ['6'],\n", - " ['12', '5'],\n", - " ['64'],\n", - " ['31', '33', '16', '18'],\n", - " ['72'],\n", - " ['78', '76'],\n", - " ['20', '21', '84'],\n", - " ['77'],\n", - " ['94'],\n", - " ['17', '19'],\n", - " ['23', '74'],\n", - " ['95'],\n", - " ['61'],\n", - " ['35', '36'],\n", - " ['14'],\n", - " ['4'],\n", - " ['9'],\n", - " ['92', '90'],\n", - " ['88', '87'],\n", - " ['2'],\n", - " ['1'],\n", - " ['79'],\n", - " ['8'],\n", - " ['11'],\n", - " ['15', '13'],\n", - " ['93'],\n", - " ['0'],\n", - " ['27']]" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## `spreg`\n", - "\n", - "State-of-the-art spatial regression.\n", - "\n", - "* Standard linear regression $\\rightarrow y = X \\beta + \\epsilon$\n", - "* Spatial autocorrelation diagnostics\n", - "* Spatial autocorrelation\n", - " * Spatial lag model $\\rightarrow y = \\rho Wy + X \\beta + \\epsilon$\n", - " * Spatial error model $\\rightarrow y = X \\beta + u \\; \\text{;} \\; u = Wu + \\epsilon$\n", - " * Combo models $\\rightarrow y = \\rho Wy + X \\beta + u \\; \\text{;} \\; u = Wu + \\epsilon$\n", - "* Spatial heterogeneity $\\rightarrow$ spatial regimes" - ] - }, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Contributors to this notebook\n", + "\n", + "* Daniel Arribas-Bel [@darribas](http://twitter.com/darribas)\n", + "* Serge Rey http://sjrey.org" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import pysal as ps # 1.5 or higher\n", + "import pandas as pd # 0.10 or higher\n", + "import numpy as np" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Specialized modules in `PySAL`" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Before we brush through more specialized functionality in `PySAL`, let's load up example data:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example of standard model:" + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING: there is one disconnected observation (no neighbors)\n", + "Island id: ['27']\n" ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "y = db['total'].values[:, None]\n", - "x = db[['h_0', 'h_7', 'h_16']].values" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 6 - }, + } + ], + "source": [ + "dbf = ps.open('data/amsterdam_hoods.dbf')\n", + "db = pd.DataFrame(dict([(col, np.array(dbf.by_col(col))) for col in dbf.header]))\n", + "w = ps.open('data/adam.gal').read()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## `region`\n", + "\n", + "* Spatial aggregation of areas into regions\n", + "* \"Spatial clustering\"\n", + "* Right now, it implements only the `max-p` algorithm:\n", + " * Duque, J. C., Anselin, L. and Rey, S. J. 2011 [*\"The MAX-P regions problem\"*](http://onlinelibrary.wiley.com/doi/10.1111/j.1467-9787.2011.00743.x/abstract)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example of aggregation of areas using the `max-p`:" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "z = db[[i for i in db.columns if 'h_' in i]].values\n", + "floor_var = db['total'].values[:, None]\n", + "maxp = ps.Maxp(w, z, floor=500, floor_variable=floor_var)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ { - "cell_type": "code", - "collapsed": false, - "input": [ - "ols = ps.spreg.OLS(y, x, w)\n", - "print ols.summary" - ], - "language": "python", + "data": { + "text/plain": [ + "{'0': 50,\n", + " '1': 13,\n", + " '10': 12,\n", + " '11': 25,\n", + " '12': 12,\n", + " '13': 34,\n", + " '14': 14,\n", + " '15': 33,\n", + " '16': 22,\n", + " '17': 22,\n", + " '18': 22,\n", + " '19': 41,\n", + " '2': 8,\n", + " '20': 6,\n", + " '21': 6,\n", + " '22': 49,\n", + " '23': 27,\n", + " '24': 27,\n", + " '25': 1,\n", + " '26': 27,\n", + " '27': 15,\n", + " '28': 27,\n", + " '29': 33,\n", + " '3': 7,\n", + " '30': 33,\n", + " '31': 43,\n", + " '32': 43,\n", + " '33': 22,\n", + " '34': 23,\n", + " '35': 23,\n", + " '36': 23,\n", + " '37': 2,\n", + " '38': 2,\n", + " '39': 2,\n", + " '4': 24,\n", + " '40': 2,\n", + " '41': 2,\n", + " '42': 12,\n", + " '43': 12,\n", + " '44': 12,\n", + " '45': 2,\n", + " '46': 12,\n", + " '47': 12,\n", + " '48': 11,\n", + " '49': 2,\n", + " '5': 29,\n", + " '50': 2,\n", + " '51': 5,\n", + " '52': 5,\n", + " '53': 39,\n", + " '54': 5,\n", + " '55': 5,\n", + " '56': 5,\n", + " '57': 19,\n", + " '58': 19,\n", + " '59': 5,\n", + " '6': 38,\n", + " '60': 5,\n", + " '61': 0,\n", + " '62': 39,\n", + " '63': 18,\n", + " '64': 35,\n", + " '65': 32,\n", + " '66': 3,\n", + " '67': 21,\n", + " '68': 21,\n", + " '69': 21,\n", + " '7': 47,\n", + " '70': 21,\n", + " '71': 21,\n", + " '72': 42,\n", + " '73': 26,\n", + " '74': 45,\n", + " '75': 26,\n", + " '76': 20,\n", + " '77': 4,\n", + " '78': 31,\n", + " '79': 31,\n", + " '8': 44,\n", + " '80': 36,\n", + " '81': 17,\n", + " '82': 37,\n", + " '83': 10,\n", + " '84': 10,\n", + " '85': 6,\n", + " '86': 30,\n", + " '87': 40,\n", + " '88': 6,\n", + " '89': 17,\n", + " '9': 9,\n", + " '90': 28,\n", + " '91': 37,\n", + " '92': 37,\n", + " '93': 46,\n", + " '94': 48,\n", + " '95': 16}" + ] + }, + "execution_count": 6, "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "REGRESSION\n", - "----------\n", - "SUMMARY OF OUTPUT: ORDINARY LEAST SQUARES\n", - "-----------------------------------------\n", - "Data set : unknown\n", - "Weights matrix : unknown\n", - "Dependent Variable : dep_var Number of Observations: 96\n", - "Mean dependent var : 806.5312 Number of Variables : 4\n", - "S.D. dependent var : 1070.2103 Degrees of Freedom : 92\n", - "\n", - "R-squared : 0.981934\n", - "Adjusted R-squared : 0.9813\n", - "Sum squared residual: 1965750.735 F-statistic : 1666.7952\n", - "Sigma-square : 21366.856 Prob(F-statistic) : 5.004e-80\n", - "S.E. of regression : 146.174 Log likelihood : -612.716\n", - "Sigma-square ML : 20476.570 Akaike info criterion : 1233.432\n", - "S.E of regression ML: 143.0964 Schwarz criterion : 1243.689\n", - "\n", - "------------------------------------------------------------------------------------\n", - " Variable Coefficient Std.Error t-Statistic Probability\n", - "------------------------------------------------------------------------------------\n", - " CONSTANT 63.8201539 18.8890437 3.3786863 0.0010695\n", - " var_1 6.3273241 1.5145256 4.1777598 0.0000669\n", - " var_2 4.2722981 0.4779627 8.9385588 0.0000000\n", - " var_3 8.7344856 0.4145940 21.0675663 0.0000000\n", - "------------------------------------------------------------------------------------\n", - "\n", - "REGRESSION DIAGNOSTICS\n", - "MULTICOLLINEARITY CONDITION NUMBER 6.441391\n", - "\n", - "TEST ON NORMALITY OF ERRORS\n", - "TEST DF VALUE PROB\n", - "Jarque-Bera 2 75.051777 0.0000000\n", - "\n", - "DIAGNOSTICS FOR HETEROSKEDASTICITY\n", - "RANDOM COEFFICIENTS\n", - "TEST DF VALUE PROB\n", - "Breusch-Pagan test 3 198.378173 0.0000000\n", - "Koenker-Bassett test 3 62.693334 0.0000000\n", - "\n", - "SPECIFICATION ROBUST TEST\n", - "TEST DF VALUE PROB\n", - "White 9 72.695091 0.0000000\n", - "================================ END OF REPORT =====================================\n" - ] - } - ], - "prompt_number": 7 - }, + "output_type": "execute_result" + } + ], + "source": [ + "# Cardinalities\n", + "maxp.area2region" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ { - "cell_type": "code", - "collapsed": true, - "input": [ - "combo = ps.spreg.GM_Combo_Hom(y, x, w=w)\n", - "print combo.summary" - ], - "language": "python", + "data": { + "text/plain": [ + "[['61'],\n", + " ['25'],\n", + " ['41', '49', '50', '45', '38', '40', '37', '39'],\n", + " ['66'],\n", + " ['77'],\n", + " ['54', '56', '59', '51', '55', '60', '52'],\n", + " ['21', '85', '20', '88'],\n", + " ['3'],\n", + " ['2'],\n", + " ['9'],\n", + " ['84', '83'],\n", + " ['48'],\n", + " ['43', '42', '47', '46', '44', '10', '12'],\n", + " ['1'],\n", + " ['14'],\n", + " ['27'],\n", + " ['95'],\n", + " ['89', '81'],\n", + " ['63'],\n", + " ['57', '58'],\n", + " ['76'],\n", + " ['67', '68', '69', '71', '70'],\n", + " ['16', '18', '33', '17'],\n", + " ['35', '36', '34'],\n", + " ['4'],\n", + " ['11'],\n", + " ['75', '73'],\n", + " ['26', '24', '28', '23'],\n", + " ['90'],\n", + " ['5'],\n", + " ['86'],\n", + " ['79', '78'],\n", + " ['65'],\n", + " ['30', '15', '29'],\n", + " ['13'],\n", + " ['64'],\n", + " ['80'],\n", + " ['92', '91', '82'],\n", + " ['6'],\n", + " ['53', '62'],\n", + " ['87'],\n", + " ['19'],\n", + " ['72'],\n", + " ['31', '32'],\n", + " ['8'],\n", + " ['74'],\n", + " ['93'],\n", + " ['7'],\n", + " ['94'],\n", + " ['22'],\n", + " ['0']]" + ] + }, + "execution_count": 7, "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "REGRESSION\n", - "----------\n", - "SUMMARY OF OUTPUT: SPATIALLY WEIGHTED TWO STAGE LEAST SQUARES (HOM)\n", - "-------------------------------------------------------------------\n", - "Data set : unknown\n", - "Weights matrix : unknown\n", - "Dependent Variable : dep_var Number of Observations: 96\n", - "Mean dependent var : 806.5312 Number of Variables : 5\n", - "S.D. dependent var : 1070.2103 Degrees of Freedom : 91\n", - "\n", - "Pseudo R-squared : 0.9847\n", - "Spatial Pseudo R-squared: 0.9846\n", - "\n", - "------------------------------------------------------------------------------------\n", - " Variable Coefficient Std.Error z-Statistic Probability\n", - "------------------------------------------------------------------------------------\n", - " CONSTANT 5.9614487 21.9138624 0.2720401 0.7855912\n", - " W_dep_var 0.0169552 0.0041102 4.1251978 0.0000370\n", - " var_1 5.6181654 1.3746269 4.0870473 0.0000437\n", - " var_2 4.4575079 0.4328943 10.2969898 0.0000000\n", - " var_3 8.1950028 0.3953213 20.7299804 0.0000000\n", - " lambda -0.0026513 0.0334001 -0.0793806 0.9367299\n", - "------------------------------------------------------------------------------------\n", - "Instrumented: W_dep_var\n", - "Instruments: W_var_1, W_var_2, W_var_3\n", - "================================ END OF REPORT =====================================\n" - ] - } - ], - "prompt_number": 8 - }, + "output_type": "execute_result" + } + ], + "source": [ + "maxp.regions" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## `spreg`\n", + "\n", + "State-of-the-art spatial regression.\n", + "\n", + "* Standard linear regression $\\rightarrow y = X \\beta + \\epsilon$\n", + "* Spatial autocorrelation diagnostics\n", + "* Spatial autocorrelation\n", + " * Spatial lag model $\\rightarrow y = \\rho Wy + X \\beta + \\epsilon$\n", + " * Spatial error model $\\rightarrow y = X \\beta + u \\; \\text{;} \\; u = Wu + \\epsilon$\n", + " * Combo models $\\rightarrow y = \\rho Wy + X \\beta + u \\; \\text{;} \\; u = Wu + \\epsilon$\n", + "* Spatial heterogeneity $\\rightarrow$ spatial regimes" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example of standard model:" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "y = db['total'].values[:, None]\n", + "x = db[['h_0', 'h_7', 'h_16']].values" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## `spatial_dynamics`\n", + "name": "stdout", + "output_type": "stream", + "text": [ + "REGRESSION\n", + "----------\n", + "SUMMARY OF OUTPUT: ORDINARY LEAST SQUARES\n", + "-----------------------------------------\n", + "Data set : unknown\n", + "Weights matrix : unknown\n", + "Dependent Variable : dep_var Number of Observations: 96\n", + "Mean dependent var : 806.5312 Number of Variables : 4\n", + "S.D. dependent var : 1070.2103 Degrees of Freedom : 92\n", + "R-squared : 0.9819\n", + "Adjusted R-squared : 0.9813\n", + "Sum squared residual: 1965750.735 F-statistic : 1666.7952\n", + "Sigma-square : 21366.856 Prob(F-statistic) : 5.004e-80\n", + "S.E. of regression : 146.174 Log likelihood : -612.716\n", + "Sigma-square ML : 20476.570 Akaike info criterion : 1233.432\n", + "S.E of regression ML: 143.0964 Schwarz criterion : 1243.689\n", "\n", - "Several exploratory measure and approaches to the analysis of spatial dynamics of systems.\n", + "------------------------------------------------------------------------------------\n", + " Variable Coefficient Std.Error t-Statistic Probability\n", + "------------------------------------------------------------------------------------\n", + " CONSTANT 63.8201539 18.8890437 3.3786863 0.0010695\n", + " var_1 6.3273241 1.5145256 4.1777598 0.0000669\n", + " var_2 4.2722981 0.4779627 8.9385588 0.0000000\n", + " var_3 8.7344856 0.4145940 21.0675663 0.0000000\n", + "------------------------------------------------------------------------------------\n", "\n", - "* Directional statistics (Rey et al. 2011)\n", - "* Space-time interaction measures (Kulldorf)\n", - "* Non-spatial Markov chains\n", - "* Spatial Markov chains (Rey, 2004)\n", - "* Spatial rank Markov chains (Rey, 2012)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## `inequality`\n", + "REGRESSION DIAGNOSTICS\n", + "MULTICOLLINEARITY CONDITION NUMBER 6.441\n", "\n", - "Inequality measures for the analysis of regional systems. Spatial and non-spatial.\n", + "TEST ON NORMALITY OF ERRORS\n", + "TEST DF VALUE PROB\n", + "Jarque-Bera 2 75.052 0.0000\n", "\n", - "* Theil\n", - "* Spatial decomposition of Theil" + "DIAGNOSTICS FOR HETEROSKEDASTICITY\n", + "RANDOM COEFFICIENTS\n", + "TEST DF VALUE PROB\n", + "Breusch-Pagan test 3 198.378 0.0000\n", + "Koenker-Bassett test 3 62.693 0.0000\n", + "================================ END OF REPORT =====================================\n" ] - }, + } + ], + "source": [ + "ols = ps.spreg.OLS(y, x, w)\n", + "print(ols.summary)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## `contrib`\n", - "\n", - "The contrib module serves two main purposes:\n", + "name": "stdout", + "output_type": "stream", + "text": [ + "REGRESSION\n", + "----------\n", + "SUMMARY OF OUTPUT: SPATIALLY WEIGHTED TWO STAGE LEAST SQUARES (HOM)\n", + "-------------------------------------------------------------------\n", + "Data set : unknown\n", + "Weights matrix : unknown\n", + "Dependent Variable : dep_var Number of Observations: 96\n", + "Mean dependent var : 806.5312 Number of Variables : 5\n", + "S.D. dependent var : 1070.2103 Degrees of Freedom : 91\n", + "Pseudo R-squared : 0.9847\n", + "Spatial Pseudo R-squared: 0.9846\n", + "N. of iterations : 1\n", "\n", - "* **Sandbox** for code that is not quite ready for prime time but it's fairly advanced and still under intense development\n", - "* **Interface** between `PySAL` and third party libraries that are not required as \"dependencies\" (e.g. `networkX`, `shapely`)" + "------------------------------------------------------------------------------------\n", + " Variable Coefficient Std.Error z-Statistic Probability\n", + "------------------------------------------------------------------------------------\n", + " CONSTANT 5.9614487 21.9138624 0.2720401 0.7855912\n", + " W_dep_var 0.0169552 0.0041102 4.1251978 0.0000370\n", + " var_1 5.6181654 1.3746269 4.0870473 0.0000437\n", + " var_2 4.4575079 0.4328943 10.2969898 0.0000000\n", + " var_3 8.1950028 0.3953213 20.7299804 0.0000000\n", + " lambda -0.0026513 0.0334001 -0.0793806 0.9367299\n", + "------------------------------------------------------------------------------------\n", + "Instrumented: W_dep_var\n", + "Instruments: W_var_1, W_var_2, W_var_3\n", + "================================ END OF REPORT =====================================\n" ] } ], - "metadata": {} + "source": [ + "combo = ps.spreg.GM_Combo_Hom(y, x, w=w)\n", + "print(combo.summary)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## `spatial_dynamics`\n", + "\n", + "Several exploratory measure and approaches to the analysis of spatial dynamics of systems.\n", + "\n", + "* Directional statistics (Rey et al. 2011)\n", + "* Space-time interaction measures (Kulldorf)\n", + "* Non-spatial Markov chains\n", + "* Spatial Markov chains (Rey, 2004)\n", + "* Spatial rank Markov chains (Rey, 2012)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## `inequality`\n", + "\n", + "Inequality measures for the analysis of regional systems. Spatial and non-spatial.\n", + "\n", + "* Theil\n", + "* Spatial decomposition of Theil" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## `contrib`\n", + "\n", + "The contrib module serves two main purposes:\n", + "\n", + "* **Sandbox** for code that is not quite ready for prime time but it's fairly advanced and still under intense development\n", + "* **Interface** between `PySAL` and third party libraries that are not required as \"dependencies\" (e.g. `networkX`, `shapely`)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.1" } - ] -} \ No newline at end of file + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/notebooks/data/adam.gal b/notebooks/data/adam.gal index ecf31d3..3f1237c 100644 --- a/notebooks/data/adam.gal +++ b/notebooks/data/adam.gal @@ -20,7 +20,7 @@ 9 5 8 25 74 4 73 10 5 -48 43 11 12 13 +11 48 43 12 13 11 7 32 10 13 51 52 29 30 12 4 @@ -28,7 +28,7 @@ 13 7 5 10 11 12 14 15 29 14 5 -16 15 13 6 5 +16 15 5 6 13 15 6 33 13 14 16 29 30 16 6 @@ -44,7 +44,7 @@ 21 7 19 36 83 84 85 22 20 22 5 -86 20 21 85 7 +85 20 21 86 7 23 4 24 25 74 77 24 4 @@ -72,7 +72,7 @@ 35 4 33 34 36 62 36 7 -33 83 35 19 21 62 63 +19 33 35 83 21 62 63 37 6 1 5 38 41 47 48 38 6 @@ -86,7 +86,7 @@ 42 4 48 43 44 47 43 4 -48 42 44 10 +48 10 44 42 44 3 42 43 47 45 5 @@ -96,15 +96,15 @@ 47 6 37 41 42 44 46 48 48 8 -1 37 42 43 12 47 10 5 +1 5 10 43 12 47 42 37 49 5 -41 50 45 38 25 +25 50 45 38 41 50 5 -41 25 45 46 49 +25 49 45 46 41 51 5 11 52 53 54 55 52 4 -32 11 51 53 +32 51 11 53 53 8 32 51 52 54 56 57 61 62 54 4 @@ -146,9 +146,9 @@ 72 9 7 8 73 75 76 80 81 82 91 73 5 -72 9 74 75 8 +8 9 74 75 72 74 8 -8 73 75 76 77 9 23 25 +8 9 75 76 77 73 23 25 75 5 72 73 74 76 77 76 8 @@ -160,15 +160,15 @@ 79 4 92 76 78 95 80 6 -81 72 7 8 86 89 +81 8 7 72 86 89 81 8 72 80 82 86 88 89 90 91 82 4 72 81 90 91 83 7 -36 94 84 21 87 62 63 +36 62 84 21 87 94 63 84 4 -87 83 21 85 +83 21 85 87 85 6 22 84 21 86 87 88 86 8 @@ -188,6 +188,6 @@ 93 5 88 90 95 94 87 94 6 -64 83 87 95 93 63 +64 83 87 63 93 95 95 5 90 92 93 94 79