Lab 4
This lab covers an introductory tutorial for Python and, in particular, PySAL.
All the content is contained in the IPython notebook Lab-04.ipynb
, available
from the repository ([raw], [html]) and included in the .zip
file with the data.
Data analysis in Python and PySAL
- What is Python?
- Why Python?
- Flexible
- Intuitive and high-level
- Widely used and extended
- How Python?
- Scripts + interpreter (IPython)
- IPython notebook
- Basic Python in the notebook
- Cells (code, markdown…)
- Libraries
- Help (inline, called)
Scientific computing in Python
pandas
- IO operations
- Data manipulation
numpy
and scipy
- Core data structures
- Statistical functions and low-level methods
matplotlib
PySAL Intro
High-level library for advanced spatial analysis
- Shapefile IO
- Spatial weights
- Create (contiguity and distance)
- Query
- Save
- Combine –> intersection of queen and block weights (example)
- Spatial lag
- Choropleth mapping
- ESDA
- Global statistics
- Local statistics
spreg
Replication of all of the models run in Lab 3 with GeoDaSpace:
- Non-spatial models:
- OLS
- OLS + White
- OLS + spatial diagnostics
- Spatial heterogeneity:
- OLS + spatial fixed effects
- OLS + spatial regimes
- Spatial dependence:
- OLS + WX
- Spatial lag model (IV and ML)
- Spatial error (GMM and ML)
- Spatial HAC
- Batch example: spatial diagnostics with several weight matrices
References