diff --git a/modules/10-spatial-models/lecture.ipynb b/modules/10-spatial-models/lecture.ipynb index eddcc4f..ad579f3 100644 --- a/modules/10-spatial-models/lecture.ipynb +++ b/modules/10-spatial-models/lecture.ipynb @@ -83,7 +83,8 @@ "import mgwr\n", "import pandas as pd\n", "import spreg\n", - "from libpysal import weights" + "from libpysal import weights\n", + "from matplotlib import colormaps as cmaps" ] }, { @@ -112,8 +113,8 @@ "outputs": [], "source": [ "# load CA tract-level census variables\n", - "df_census = pd.read_csv(\"../../data/census_tracts_data_ca.csv\", dtype={\"GEOID10\": str}).set_index(\n", - " \"GEOID10\"\n", + "df_census = pd.read_csv(\n", + " \"../../data/census_tracts_data_ca.csv\", dtype={\"GEOID10\": str}, index_col=\"GEOID10\"\n", ")\n", "df_census.shape" ] @@ -452,7 +453,7 @@ " from matplotlib.colors import LinearSegmentedColormap as lsc\n", "\n", " name = f\"{cmap_name}_new\"\n", - " cmap = plt.cm.get_cmap(cmap_name)\n", + " cmap = cmaps.get_cmap(cmap_name)\n", " vmin = values.min()\n", " vmax = values.max()\n", "\n", @@ -579,7 +580,7 @@ "outputs": [], "source": [ "# compute spatial weights for only those tracts that appear in design matrix\n", - "W = weights.Queen.from_dataframe(tracts.loc[X.index])\n", + "W = weights.Queen.from_dataframe(tracts.loc[X.index], use_index=True)\n", "W.transform = \"r\"" ] }, @@ -735,7 +736,7 @@ "\n", "> Due to spatial spillover, each coefficient alone does not represent the marginal effect on the response of a unit increase in the predictor. Instead, it represents the direct effect: what happens locally if you make a unit change in the predictor only in one tract. But also present are indirect effects: local spillovers in each tract from a unit predictor change in other tracts.\n", "\n", - "Refer to the article for details on how to calculate and interpret total effects.\n", + "Refer to the article for details on how to calculate and interpret *total effects*.\n", "\n", "## 8. Spatial error model\n", "\n",