Skip to content

Commit

Permalink
GA build of book HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 14, 2023
1 parent d709b61 commit 34dea6d
Show file tree
Hide file tree
Showing 36 changed files with 198 additions and 153 deletions.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
24 changes: 12 additions & 12 deletions docs/_sources/notebooks/06_spatial_autocorrelation.ipynb

Large diffs are not rendered by default.

166 changes: 95 additions & 71 deletions docs/_sources/notebooks/12_feature_engineering.ipynb

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions docs/notebooks/06_spatial_autocorrelation.html
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,14 @@ <h2>An empirical illustration: the EU Referendum<a class="headerlink" href="#an-
<span class="n">contextily</span><span class="o">.</span><span class="n">add_basemap</span><span class="p">(</span>
<span class="n">ax</span><span class="p">,</span>
<span class="n">crs</span><span class="o">=</span><span class="n">db</span><span class="o">.</span><span class="n">crs</span><span class="p">,</span>
<span class="n">source</span><span class="o">=</span><span class="n">contextily</span><span class="o">.</span><span class="n">providers</span><span class="o">.</span><span class="n">Stamen</span><span class="o">.</span><span class="n">TerrainBackground</span><span class="p">,</span>
<span class="n">source</span><span class="o">=</span><span class="n">contextily</span><span class="o">.</span><span class="n">providers</span><span class="o">.</span><span class="n">Esri</span><span class="o">.</span><span class="n">WorldTerrain</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">set_axis_off</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="../_images/0ec1497bc01fcbf161dea4b52fa4ef3538964a0b166119328059c20499e30355.png" src="../_images/0ec1497bc01fcbf161dea4b52fa4ef3538964a0b166119328059c20499e30355.png" />
<img alt="../_images/35c9d49e1ed20ec88b03f794fb30d73c0b8cfe7e855fe4a0f8b90275ece37dac.png" src="../_images/35c9d49e1ed20ec88b03f794fb30d73c0b8cfe7e855fe4a0f8b90275ece37dac.png" />
</div>
</div>
<p>The final piece we need before we can delve into autocorrelation is the spatial weights matrix. We will use eight nearest neighbors for the sake of the example, but our earlier discussion of spatial weights in Chapter 4 applies in this context, and other criteria would be valid too. We also row-standardize them:</p>
Expand Down Expand Up @@ -720,7 +720,7 @@ <h3>Spatial lag<a class="headerlink" href="#spatial-lag" title="Permalink to thi
<span class="n">contextily</span><span class="o">.</span><span class="n">add_basemap</span><span class="p">(</span>
<span class="n">ax1</span><span class="p">,</span>
<span class="n">crs</span><span class="o">=</span><span class="n">db</span><span class="o">.</span><span class="n">crs</span><span class="p">,</span>
<span class="n">source</span><span class="o">=</span><span class="n">contextily</span><span class="o">.</span><span class="n">providers</span><span class="o">.</span><span class="n">Stamen</span><span class="o">.</span><span class="n">TerrainBackground</span><span class="p">,</span>
<span class="n">source</span><span class="o">=</span><span class="n">contextily</span><span class="o">.</span><span class="n">providers</span><span class="o">.</span><span class="n">Esri</span><span class="o">.</span><span class="n">WorldTerrain</span><span class="p">,</span>
<span class="p">)</span>

<span class="n">db</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span>
Expand All @@ -739,15 +739,15 @@ <h3>Spatial lag<a class="headerlink" href="#spatial-lag" title="Permalink to thi
<span class="n">contextily</span><span class="o">.</span><span class="n">add_basemap</span><span class="p">(</span>
<span class="n">ax2</span><span class="p">,</span>
<span class="n">crs</span><span class="o">=</span><span class="n">db</span><span class="o">.</span><span class="n">crs</span><span class="p">,</span>
<span class="n">source</span><span class="o">=</span><span class="n">contextily</span><span class="o">.</span><span class="n">providers</span><span class="o">.</span><span class="n">Stamen</span><span class="o">.</span><span class="n">TerrainBackground</span><span class="p">,</span>
<span class="n">source</span><span class="o">=</span><span class="n">contextily</span><span class="o">.</span><span class="n">providers</span><span class="o">.</span><span class="n">Esri</span><span class="o">.</span><span class="n">WorldTerrain</span><span class="p">,</span>
<span class="p">)</span>

<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="../_images/2b05f39b68fb2a2c1d2d09124079f1b1713216899b083a568adc8ba473dbc26b.png" src="../_images/2b05f39b68fb2a2c1d2d09124079f1b1713216899b083a568adc8ba473dbc26b.png" />
<img alt="../_images/c34fe506758db93132670cac1d7cbd813c227cb646eb9e68f5a46d8b4ee049a5.png" src="../_images/c34fe506758db93132670cac1d7cbd813c227cb646eb9e68f5a46d8b4ee049a5.png" />
</div>
</div>
<p>The stark differences on the left between immediate neighbors (as in the case of Liverpool, in the NW of England) are diminished in the map on the right. Thus, as discussed above, the spatial lag can also smooth out the differences between nearby observations.</p>
Expand Down Expand Up @@ -843,7 +843,7 @@ <h3>Binary case: join counts<a class="headerlink" href="#binary-case-join-counts
</div>
</div>
<div class="cell_output docutils container">
<img alt="../_images/042cde699d623dad35d48f35fe6566bf8a702b5d1ea11928078002b7a859a1dd.png" src="../_images/042cde699d623dad35d48f35fe6566bf8a702b5d1ea11928078002b7a859a1dd.png" />
<img alt="../_images/9dd0bce07aaa084cb208e64c4b726ae13933c3b494344c60ecbc350dea5fe2b1.png" src="../_images/9dd0bce07aaa084cb208e64c4b726ae13933c3b494344c60ecbc350dea5fe2b1.png" />
</div>
</div>
<p>Visually, it appears that the map represents a clear case of positive spatial autocorrelation: overall, there are few visible cases where a given observation is surrounded by others in the opposite category. To formally explore this initial assessment, we can use what is called a “join count” statistic (JC; <span id="id5">[<a class="reference internal" href="references.html#id18" title="Andrew David Cliff and J Keith Ord. Spatial processes: models &amp; applications. Taylor &amp; Francis, 1981.">CO81</a>]</span>). Imagine a checkerboard with green (G, value 0) and yellow (Y, value 1) squares. The idea of the statistic is to count occurrences of green-green (GG), yellow-yellow (YY), or green-yellow/yellow-green (GY) joins (or neighboring pairs) on the map. In this context, both GG and YY reflect positive spatial autocorrelation, while GY captures its negative counterpart. The intuition of the statistic is to provide a baseline of how many GG, YY, and GY one would expect under the case of complete spatial randomness, and to compare this with the observed counts in the dataset. A situation where we observe more GG/YY than expected and less GY than expected would suggest positive spatial autocorrelation; while the opposite, more GY than GG/YY, would point towards negative spatial autocorrelation.</p>
Expand Down Expand Up @@ -889,7 +889,7 @@ <h3>Binary case: join counts<a class="headerlink" href="#binary-case-join-counts
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;esda.join_counts.Join_Counts at 0x7fcea84aa080&gt;
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;esda.join_counts.Join_Counts at 0x7f2c58389f40&gt;
</pre></div>
</div>
</div>
Expand Down Expand Up @@ -1052,7 +1052,7 @@ <h3>Continuous case: Moran Plot and Moran’s I<a class="headerlink" href="#cont
</div>
</div>
<div class="cell_output docutils container">
<img alt="../_images/10f3711c980509b1a52c9a6730b4184c39790340dbc5c8004dcc33bae9076a82.png" src="../_images/10f3711c980509b1a52c9a6730b4184c39790340dbc5c8004dcc33bae9076a82.png" />
<img alt="../_images/ecdcfecda6e93d15f8d1eb278f6f9541d052406ca37e46f26bc47544e7fc0b27.png" src="../_images/ecdcfecda6e93d15f8d1eb278f6f9541d052406ca37e46f26bc47544e7fc0b27.png" />
</div>
</div>
<p>The figure above displays the relationship between the standardized “Leave” voting percentage in a local authority and its spatial lag which, because the <span class="math notranslate nohighlight">\(W\)</span> used is row-standardized, can be interpreted as the average standardized density of the percent Leave vote in the neighborhood of each observation. In order to guide the interpretation of the plot, a linear fit is also included. This line represents the best linear fit to the scatterplot or, in other words, what is the best way to represent the relationship between the two variables as a straight line.</p>
Expand Down Expand Up @@ -1104,7 +1104,7 @@ <h3>Continuous case: Moran Plot and Moran’s I<a class="headerlink" href="#cont
</div>
</div>
<div class="cell_output docutils container">
<img alt="../_images/68ebb7f44e3266c6f8a5f2218ec7a8db32c246570b2b3b96213bb85aab1cc2a2.png" src="../_images/68ebb7f44e3266c6f8a5f2218ec7a8db32c246570b2b3b96213bb85aab1cc2a2.png" />
<img alt="../_images/b64ad1e13e85b7a10c0a2ca19d8dd82d686380b0d5d7e8ef00f0deeba663e611.png" src="../_images/b64ad1e13e85b7a10c0a2ca19d8dd82d686380b0d5d7e8ef00f0deeba663e611.png" />
</div>
</div>
<p>On the left panel we can see in grey the empirical distribution generated from simulating 999 random maps with the values of the <code class="docutils literal notranslate"><span class="pre">Pct_Leave</span></code> variable and then calculating Moran’s I for each of those maps. The blue rug signals the mean. In contrary, the red rug shows Moran’s I calculated for the variable using the geography observed in the dataset. It is clear the value under the observed pattern is significantly higher than under randomness. This insight is confirmed on the right panel, which shows an equivalent plot to the Moran Scatterplot we created above.</p>
Expand Down Expand Up @@ -1284,16 +1284,16 @@ <h2>Next steps<a class="headerlink" href="#next-steps" title="Permalink to this
},
codeMirrorConfig: {
theme: "abcdef",
mode: "python"
mode: "gds"
},
kernelOptions: {
name: "python3",
name: "gds",
path: "./notebooks"
},
predefinedOutput: true
}
</script>
<script>kernelName = 'python3'</script>
<script>kernelName = 'gds'</script>

</article>

Expand Down
Loading

0 comments on commit 34dea6d

Please sign in to comment.