Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gboeing committed Mar 20, 2024
1 parent e6c7270 commit f6ce641
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions modules/10-spatial-models/lecture.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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"
]
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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\""
]
},
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit f6ce641

Please sign in to comment.