Maps and Basic Statistics

Important note

In what follows, I describe some modules for spatial data that were available before Stata introduced their own sp commands for the analysis of spatial data in version 15.

As far as I can judge, the modules I describe here are still available and working. For information about the inbuilt sp commands, see Stata's help system (help sp will provide access to the introductory remarks and an overview of all available commands).



Visualizing spatial data: Maps

Maps offer rich possibilities of visualizing spatial data. At the moment this section is about simple choropleth maps only.

spmap some-variable using my-coord , id(id-var) fcolor(Blues)

This will draw a choropleth map of variable some-variable (which is a column of your database file; this file is the current working file) using the coordinates file my-coord (with id variable id-var). Several shades of blue are used to characterize different degress of some-variable.

Unsurprisingly, there is a plethora of options available for finetuning the map according to your wishes.


Statistics for spatial autocorrelation

There are global and local statistics. The most common is Moran's I (with both a global and a local version), but some other statistics may be computed as well.

spatgsa some-variable, weights(w-matrix) moran

will compute Moran's (global) I for variable some-variable. The variable is part of the (spatial) database file (which is supposed to be your current working, or master, file), and the computation uses weight matrix w-matrix created by spatwmat.

No statistics will be computed if there is any missing value in the variable under investigation (without any reason given!). Regrettably, if does not work with spatgsa (or with the command presented next, spatlsa.

spatlsa some-variable, weights(w-matrix) moran id(id-var)

will compute Moran's (Local) I for variable some-variable. The variable is part of the (spatial) database file (which is supposed to be your current working, or master, file), and the computation uses weight matrix w-matrix created by spatwmat. Variable id-var (which uniquely characterizes the observation) is used for identification of observations in the output.

Option moran restricts the output to Moran's I. See the help function for other statistics (or just omit this option, in which case you will get several statistics). Note that no statistics are computed if there are missing values in some-variable.

© W. Ludwig-Mayerhofer, Stata Guide | Last update: 18 Aug 2016