<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>chris hanretty</title>
<link>http://www.chrishanretty.co.uk/</link>
<atom:link href="http://www.chrishanretty.co.uk/index.xml" rel="self" type="application/rss+xml"/>
<description>chris hanretty&#39;s site</description>
<generator>quarto-1.9.36</generator>
<lastBuildDate>Sun, 17 May 2026 23:00:00 GMT</lastBuildDate>
<item>
  <title>The dead of Makerfield</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/makerfield/</link>
  <description><![CDATA[ 





<p>Last week Josh Simons resigned as MP for Makerfield, prompting a by-election in which Andy Burnham is expected to be the Labour candidate.</p>
<p>People (mostly journalists) want to characterise Makerfield politically.</p>
<p>One way of doing this is by reporting how “Leave” or “Remain” the constituency is. The 2016 membership plebiscite becomes less a referendum, and more a revenant, doomed to characterize constituencies until the end of time.</p>
<p>Because the referendum was counted by local authorities, we almost never know exactly how many people in Westminster constituencies voted to Leave and Remain. In 2016 I published estimates of how many people had voted to Leave and Remain in each constituency. You can find those estimates at <a href="https://docs.google.com/spreadsheets/d/1wTK5dV2_YjCMsUYlwg0l48uWWf44sKgG8uFVMv5OWlA/edit?usp=sharing">Google Sheets</a>. Those figures suggest that in Makerfield 65% of those voted voted to Leave.</p>
<p>Since 2016, a lot has happened. One thing that happened is that new boundaries for Westminster constituencies were introduced. I’ve produced estimates of the number of people who voted Leave and Remain in those areas. You can find them at <a href="https://docs.google.com/spreadsheets/d/1mtph-ml7CYVoeEUIc1g_IbOvbiZMa_ezRGQlHQoCpF4/edit?usp=sharing">Google Sheets</a>. Because Makerfield (2024 edition) is very similar to Makerfield (2010-2024 edition), there’s not much difference. I estimate that 65.8% of those who voted in that area voted to Leave. In terms of people, that’s 35,020 Leave voters, and 18,150 Remain voters, rounding to the nearest ten.</p>
<p>These figures give the result of the referendum sliced up by different geographies. They are, I believe, the best guide as to how an area voted at a particular point in time. However, the further we get from time of the referendum, the stranger it is to see these figures cited. The statistic remains the same, but the place to which it refers changes. Most crudely, many people who voted in 2016 have since died. Since those who voted Leave tended to be older than those who voted Remain, this means that the current proportion of Leave voters is lower than it was in 2016. There might be good reasons for continuing to cite the 2016 figure – maybe it’s the most easily understood, or maybe there’s a strange contractual argument that we owe duties to all those who voted in the referendum, dead or alive. But it would be a poor guide to current behaviour even if no one had changed their opinion.</p>
<p>Prompted by a question on BlueSky from Tim Bale, I decided to work out how many Leave and Remain voters from 2016 are still around. This turns out to be a slightly awkward question to answer, and not just because the exercise itself is slightly crass. To answer the question, we’ll need information of three kinds:</p>
<ul>
<li>the age and gender distribution of the 2024 Makerfield constituency, as things stood at the time of the referendum</li>
<li>some guide as to how age and gender affected how people voted in the 2016 referendum</li>
<li>the age and gender distribution of deaths in Makerfield since 2016.</li>
</ul>
<p>In what follows, I’ll describe how I put these sources of information together to estimate how many Leave and Remain voters have died since 2016. Everything I calculate assumes that there was no movement in or out of Makerfield. Accounting for flows of population between constituencies is not in my judgement possible given the data available.</p>
<section id="makerfield-as-it-was-then" class="level1">
<h1>Makerfield as it was then</h1>
<p>We need to know the age distribution of the 2024 Makerfield constituency as it was in 2016. We can find the necessary data at <a href="https://www.nomisweb.co.uk/">Nomisweb</a>. The query tool allows us to get the 2021-based small area estimates of population. Because the people at Nomisweb are wonderful, and foresee all eventualities, they make it possible to aggregate these small area estimates not just to the 2010-2024 boundaries that were in use at the time, but also to the 2024- boundaries which were not even a twinkle in the eye of the Boundary Commission.</p>
<p>This age distribution is available for men and women separately. Because I never want to download things manually, I’ve been greedy and downloaded information for all of the country, and only latterly filter this to Makerfield.</p>
<p>Here’s what a random selection of rows of that data look like.</p>
<div class="cell">
<div id="tbl-age" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-age-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;1: Selected counts of individuals by age and gender in Makerfield in 2016
</figcaption>
<div aria-describedby="tbl-age-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_pr6sne1qq57nilm27ww4(i, j, css_id) {
          var table = document.getElementById("tinytable_pr6sne1qq57nilm27ww4");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_pr6sne1qq57nilm27ww4(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_pr6sne1qq57nilm27ww4");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '10', j: 0 }, { i: '10', j: 1 }, { i: '10', j: 2 },  ], css_id: 'tinytable_css_khdpssfcli6id0srin3l',}, 
          { positions: [ { i: '0', j: 0 }, { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_ldeju25b3refd3s817u8',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_pr6sne1qq57nilm27ww4(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_khdpssfcli6id0srin3l, .table th.tinytable_css_khdpssfcli6id0srin3l { border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_ldeju25b3refd3s817u8, .table th.tinytable_css_ldeju25b3refd3s817u8 { border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_pr6sne1qq57nilm27ww4" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col" data-row="0" data-col="0">Gender</th>
                <th scope="col" data-row="0" data-col="1">Age</th>
                <th scope="col" data-row="0" data-col="2">count</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td data-row="1" data-col="0">Female</td>
                  <td data-row="1" data-col="1">24</td>
                  <td data-row="1" data-col="2">610</td>
                </tr>
                <tr>
                  <td data-row="2" data-col="0">Female</td>
                  <td data-row="2" data-col="1">85</td>
                  <td data-row="2" data-col="2">193</td>
                </tr>
                <tr>
                  <td data-row="3" data-col="0">Female</td>
                  <td data-row="3" data-col="1">21</td>
                  <td data-row="3" data-col="2">435</td>
                </tr>
                <tr>
                  <td data-row="4" data-col="0">Female</td>
                  <td data-row="4" data-col="1">27</td>
                  <td data-row="4" data-col="2">619</td>
                </tr>
                <tr>
                  <td data-row="5" data-col="0">Male</td>
                  <td data-row="5" data-col="1">30</td>
                  <td data-row="5" data-col="2">621</td>
                </tr>
                <tr>
                  <td data-row="6" data-col="0">Female</td>
                  <td data-row="6" data-col="1">73</td>
                  <td data-row="6" data-col="2">545</td>
                </tr>
                <tr>
                  <td data-row="7" data-col="0">Male</td>
                  <td data-row="7" data-col="1">63</td>
                  <td data-row="7" data-col="2">577</td>
                </tr>
                <tr>
                  <td data-row="8" data-col="0">Female</td>
                  <td data-row="8" data-col="1">87</td>
                  <td data-row="8" data-col="2">137</td>
                </tr>
                <tr>
                  <td data-row="9" data-col="0">Female</td>
                  <td data-row="9" data-col="1">67</td>
                  <td data-row="9" data-col="2">643</td>
                </tr>
                <tr>
                  <td data-row="10" data-col="0">Female</td>
                  <td data-row="10" data-col="1">77</td>
                  <td data-row="10" data-col="2">415</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
</section>
<section id="age-and-gender-and-referendum-vote-choice" class="level1">
<h1>Age and gender and referendum vote choice</h1>
<p>We know the number of people of different ages and different genders in Makerfield in 2016, but no official source will tell us how these people voted (or indeed whether they voted). We must therefore learn from national data.</p>
<p>Here I’m going to build a model of referendum vote choice based on the post-referendum wave of the <a href="https://www.britishelectionstudy.com/">British Election Study</a>. The model is a generalized additive model, which allows for a smooth relationship between age and voting behaviour, where that relationship is different for men and women.</p>
<p>With generalized additive models, the best way to understand the model is to plot it. So here are the predicted probabilities of voting Leave and not voting at all, by age and by gender.</p>
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="http://www.chrishanretty.co.uk/posts/makerfield/index_files/figure-html/unnamed-chunk-4-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>There are two problems with these model derived predictions. First, the proportion of people not voting is far too low. Although turnout in the EU referendum was high, it was still less than 75%. The predicted probability of not voting is always less than 25% for all ages and either gender.</p>
<p>Second, this model derived prediction doesn’t know anything about Makerfield, and any predictions we make for the voters in Makerfield won’t match to the results for Makerfield.</p>
<p>In order to make our predictions match know results, we’ll use a logit shift. The logit shift is one of those techniques in political science which is <a href="https://doi.org/10.1017/pan.2022.31">unreasonably effective</a>. Instead of working on the probability scale, we turn those probabilities into “logits”. We then add on a little extra (or subtract a little extra), convert it back into a probability, and see what this does to the result. Here’s my code which will adjust our probabilities so that everything matches the results of the referendum .</p>
<p>We can now get the number of people in 2016 Makerfield, of different ages and genders, who voted for each option, or did not vote at all. Here is another random draw of rows from our data, with those counts now added.</p>
<div class="cell">
<div id="tbl-age2" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-age2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;2: Selected counts of individuals by age and gender in Makerfield in 2016
</figcaption>
<div aria-describedby="tbl-age2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_lz1l64742g44o8kgcag3(i, j, css_id) {
          var table = document.getElementById("tinytable_lz1l64742g44o8kgcag3");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_lz1l64742g44o8kgcag3(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_lz1l64742g44o8kgcag3");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '10', j: 0 }, { i: '10', j: 1 }, { i: '10', j: 2 }, { i: '10', j: 3 }, { i: '10', j: 4 },  ], css_id: 'tinytable_css_hvqecxtpo11v1fwol5m7',}, 
          { positions: [ { i: '0', j: 0 }, { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 }, { i: '0', j: 4 },  ], css_id: 'tinytable_css_jp22c25gh0yj82hs6rd9',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_lz1l64742g44o8kgcag3(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_hvqecxtpo11v1fwol5m7, .table th.tinytable_css_hvqecxtpo11v1fwol5m7 { border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_jp22c25gh0yj82hs6rd9, .table th.tinytable_css_jp22c25gh0yj82hs6rd9 { border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_lz1l64742g44o8kgcag3" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col" data-row="0" data-col="0">Gender</th>
                <th scope="col" data-row="0" data-col="1">Age</th>
                <th scope="col" data-row="0" data-col="2">Remain</th>
                <th scope="col" data-row="0" data-col="3">Leave</th>
                <th scope="col" data-row="0" data-col="4">DNV</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td data-row="1" data-col="0">Male</td>
                  <td data-row="1" data-col="1">69</td>
                  <td data-row="1" data-col="2">161.81008</td>
                  <td data-row="1" data-col="3">444.8409</td>
                  <td data-row="1" data-col="4">144.34901</td>
                </tr>
                <tr>
                  <td data-row="2" data-col="0">Male</td>
                  <td data-row="2" data-col="1">40</td>
                  <td data-row="2" data-col="2">133.58838</td>
                  <td data-row="2" data-col="3">211.9879</td>
                  <td data-row="2" data-col="4">253.42372</td>
                </tr>
                <tr>
                  <td data-row="3" data-col="0">Male</td>
                  <td data-row="3" data-col="1">67</td>
                  <td data-row="3" data-col="2">141.60622</td>
                  <td data-row="3" data-col="3">373.7457</td>
                  <td data-row="3" data-col="4">131.64807</td>
                </tr>
                <tr>
                  <td data-row="4" data-col="0">Female</td>
                  <td data-row="4" data-col="1">82</td>
                  <td data-row="4" data-col="2">54.01603</td>
                  <td data-row="4" data-col="3">170.4479</td>
                  <td data-row="4" data-col="4">25.53602</td>
                </tr>
                <tr>
                  <td data-row="5" data-col="0">Male</td>
                  <td data-row="5" data-col="1">65</td>
                  <td data-row="5" data-col="2">140.55197</td>
                  <td data-row="5" data-col="3">356.9899</td>
                  <td data-row="5" data-col="4">137.45812</td>
                </tr>
                <tr>
                  <td data-row="6" data-col="0">Male</td>
                  <td data-row="6" data-col="1">55</td>
                  <td data-row="6" data-col="2">158.24504</td>
                  <td data-row="6" data-col="3">349.4100</td>
                  <td data-row="6" data-col="4">214.34497</td>
                </tr>
                <tr>
                  <td data-row="7" data-col="0">Male</td>
                  <td data-row="7" data-col="1">45</td>
                  <td data-row="7" data-col="2">181.30601</td>
                  <td data-row="7" data-col="3">333.0447</td>
                  <td data-row="7" data-col="4">319.64927</td>
                </tr>
                <tr>
                  <td data-row="8" data-col="0">Female</td>
                  <td data-row="8" data-col="1">27</td>
                  <td data-row="8" data-col="2">145.09001</td>
                  <td data-row="8" data-col="3">114.3505</td>
                  <td data-row="8" data-col="4">359.55952</td>
                </tr>
                <tr>
                  <td data-row="9" data-col="0">Male</td>
                  <td data-row="9" data-col="1">41</td>
                  <td data-row="9" data-col="2">152.86180</td>
                  <td data-row="9" data-col="3">250.3816</td>
                  <td data-row="9" data-col="4">286.75663</td>
                </tr>
                <tr>
                  <td data-row="10" data-col="0">Male</td>
                  <td data-row="10" data-col="1">79</td>
                  <td data-row="10" data-col="2">56.11936</td>
                  <td data-row="10" data-col="3">185.9735</td>
                  <td data-row="10" data-col="4">45.90711</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
</section>
<section id="introducing-mortality" class="level1">
<h1>Introducing mortality</h1>
<p>Given this information, we can now start introducing information on mortality. Once more, we return to NomisWeb, where we can find mortality statistics by sex and age by using the query tool (“Life events”). Working with this data is slightly awkward: unlike the figures for the age distribution, these figures are not baked into ready aggregates. We must download the data at a low level, and aggregate back up.</p>
<p>The data itself gives the count of deaths by age group, gender and geography. Here’s a random sample of rows, for lots of different constituencies, showing a large number of zero returns.</p>
<div class="cell">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_r4myzc1280ebzgug5czg(i, j, css_id) {
          var table = document.getElementById("tinytable_r4myzc1280ebzgug5czg");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_r4myzc1280ebzgug5czg(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_r4myzc1280ebzgug5czg");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '10', j: 0 }, { i: '10', j: 1 }, { i: '10', j: 2 }, { i: '10', j: 3 }, { i: '10', j: 4 }, { i: '10', j: 5 },  ], css_id: 'tinytable_css_zvwcjmwq8cdsaebb7yzp',}, 
          { positions: [ { i: '0', j: 0 }, { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 }, { i: '0', j: 4 }, { i: '0', j: 5 },  ], css_id: 'tinytable_css_wav6epp8o3kyiydxj67a',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_r4myzc1280ebzgug5czg(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_zvwcjmwq8cdsaebb7yzp, .table th.tinytable_css_zvwcjmwq8cdsaebb7yzp { border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_wav6epp8o3kyiydxj67a, .table th.tinytable_css_wav6epp8o3kyiydxj67a { border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_r4myzc1280ebzgug5czg" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col" data-row="0" data-col="0">Date</th>
                <th scope="col" data-row="0" data-col="1">Gender</th>
                <th scope="col" data-row="0" data-col="2">measure</th>
                <th scope="col" data-row="0" data-col="3">geogcode</th>
                <th scope="col" data-row="0" data-col="4">Age</th>
                <th scope="col" data-row="0" data-col="5">value</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td data-row="1" data-col="0">2023</td>
                  <td data-row="1" data-col="1">Female</td>
                  <td data-row="1" data-col="2">Deaths</td>
                  <td data-row="1" data-col="3">E02001908</td>
                  <td data-row="1" data-col="4">Aged 15-19</td>
                  <td data-row="1" data-col="5">0</td>
                </tr>
                <tr>
                  <td data-row="2" data-col="0">2017</td>
                  <td data-row="2" data-col="1">Female</td>
                  <td data-row="2" data-col="2">Deaths</td>
                  <td data-row="2" data-col="3">E02000180</td>
                  <td data-row="2" data-col="4">Aged 90 and over</td>
                  <td data-row="2" data-col="5">5</td>
                </tr>
                <tr>
                  <td data-row="3" data-col="0">2021</td>
                  <td data-row="3" data-col="1">Male</td>
                  <td data-row="3" data-col="2">Deaths</td>
                  <td data-row="3" data-col="3">E02003844</td>
                  <td data-row="3" data-col="4">Aged 60-64</td>
                  <td data-row="3" data-col="5">0</td>
                </tr>
                <tr>
                  <td data-row="4" data-col="0">2018</td>
                  <td data-row="4" data-col="1">Female</td>
                  <td data-row="4" data-col="2">Deaths</td>
                  <td data-row="4" data-col="3">E02004392</td>
                  <td data-row="4" data-col="4">Aged 45-49</td>
                  <td data-row="4" data-col="5">0</td>
                </tr>
                <tr>
                  <td data-row="5" data-col="0">2021</td>
                  <td data-row="5" data-col="1">Female</td>
                  <td data-row="5" data-col="2">Deaths</td>
                  <td data-row="5" data-col="3">E02000843</td>
                  <td data-row="5" data-col="4">Aged 80-84</td>
                  <td data-row="5" data-col="5">0</td>
                </tr>
                <tr>
                  <td data-row="6" data-col="0">2021</td>
                  <td data-row="6" data-col="1">Female</td>
                  <td data-row="6" data-col="2">Deaths</td>
                  <td data-row="6" data-col="3">E02003344</td>
                  <td data-row="6" data-col="4">Aged 20-24</td>
                  <td data-row="6" data-col="5">0</td>
                </tr>
                <tr>
                  <td data-row="7" data-col="0">2023</td>
                  <td data-row="7" data-col="1">Female</td>
                  <td data-row="7" data-col="2">Deaths</td>
                  <td data-row="7" data-col="3">E02000520</td>
                  <td data-row="7" data-col="4">Aged 60-64</td>
                  <td data-row="7" data-col="5">0</td>
                </tr>
                <tr>
                  <td data-row="8" data-col="0">2022</td>
                  <td data-row="8" data-col="1">Female</td>
                  <td data-row="8" data-col="2">Deaths</td>
                  <td data-row="8" data-col="3">E02002686</td>
                  <td data-row="8" data-col="4">Aged 75-79</td>
                  <td data-row="8" data-col="5">8</td>
                </tr>
                <tr>
                  <td data-row="9" data-col="0">2017</td>
                  <td data-row="9" data-col="1">Male</td>
                  <td data-row="9" data-col="2">Deaths</td>
                  <td data-row="9" data-col="3">E02005406</td>
                  <td data-row="9" data-col="4">Aged 35-39</td>
                  <td data-row="9" data-col="5">0</td>
                </tr>
                <tr>
                  <td data-row="10" data-col="0">2021</td>
                  <td data-row="10" data-col="1">Female</td>
                  <td data-row="10" data-col="2">Deaths</td>
                  <td data-row="10" data-col="3">E02005210</td>
                  <td data-row="10" data-col="4">Aged 55-59</td>
                  <td data-row="10" data-col="5">0</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>Unfortunately the data only includes mortality figures for 2017 to 2023. I have therefore had to assume that mortality in Makerfield in 2024 and 2025 was the same as mortality in 2023.</p>
<p>I can aggregate my predictions to the age ranges shown in the mortality data, adding up the numbers of Remain voters, the numbers of Leave voters, and so on. I can then proportionally allocate the deaths in each age-by-gender group, and working out how many voters of each type have died.</p>
</section>
<section id="how-many-then" class="level1">
<h1>How many then?</h1>
<p>Overall, I estimate that 6167 Leave voters might have died since 2016, compared to around 2003 Remain voters. That’s a mortality rate amongst Leave voters of 17% amongst Leave voters, compared to a rate of 11% amongst the (on average younger) group of Remain voters.</p>
<p>This means that amongst the still living in Makerfield, the Leave:Remain split moves from 66:34 to 64:36.</p>
<p>These are estimates. To the extent that they are wrong, they are likely to under-estimate the number of Leave voters who died, and over-estimate the number of Remain voters who died. Bad health was a significant individual- and aggregate-level predictor of voting for Leave, and that would affect mortality estimates. However, more sophisticated modelling, or including mortality for 2026 to date is unlikely to change significantly the qualitative conclusion.</p>
<p>Ultimately, these actuarial exercises don’t affect the main reason why continuing to cite these numbers feels odd, and that’s that some people have changed their mind since then.</p>


</section>

 ]]></description>
  <category>constituencies</category>
  <guid>http://www.chrishanretty.co.uk/posts/makerfield/</guid>
  <pubDate>Sun, 17 May 2026 23:00:00 GMT</pubDate>
</item>
<item>
  <title>The measurement of disproportionality in mixed member systems</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/mixed_member_proportionality/</link>
  <description><![CDATA[ 





<section id="introduction" class="level1">
<h1>Introduction</h1>
<p>In the 2026 Scottish Parliament elections, the Scottish National Party won 44.6% of seats despite winning just 27.2% of the list vote. A gap of seventeen percentage points between vote and seat share might not seem exceptional by the standards of majoritarian elections, but the Scottish Parliament was elected by a form of mixed member proportional system which was designed to avoid the iniquities of first-past-the-post. If the disproportionality between seat shares and list vote shares is measured using the Gallagher index, then the 2026 election was the most disproportional Scottish Parliament election yet.</p>
<p>The reason the SNP won so many seats was that it performed much better in the nominal tier, winning 38% of the vote and 57 of 73 seats. It is common for large parties in mixed member systems to do better in the nominal tier than in the list tier, and we can give good reasons why: supporters of these parties often lend or rent out their vote to other parties <span class="citation" data-cites="meffert2010strategic gschwend2016drives">(Meffert and Gschwend 2010; Gschwend et al. 2016)</span>. The list vote, despite being cast in a proportional tier, ends up being the less sincere and more strategic vote.</p>
<p>Despite the nominal tier vote being at least as sincere as the list, almost all<sup>1</sup> measures of disproportionality for mixed member systems are based on the share of the vote won in the list tier of the vote. For example: <span class="citation" data-cites="linhart2019mixed">Linhart et al. (2019)</span> compare levels of disproportionality using the Gallagher index and the list share of the vote. They do so even though they study several cases where the list vote was clearly strategic, including the notorious 2005 Albanian election, where the Democratic Party encouraged its supporters to vote for smaller satellite lists <span class="citation" data-cites="bochsler2012quasi">(Bochsler 2012)</span>, and where the party won 40% of seats on 7.7% of the list vote. The abuse of the system can surely have no defenders – but it does seem absurd that this measure of disproportionality does not depend at all on whether the Democratic Party won 7.7% of the votes in the nominal tier or the 44% it did in fact win.</p>
<p>In this note, I set out a way to measure disproportionality in mixed electoral systems which takes into account both nominal and list votes. This measure extends the Sainte-Laguë index, the disproportionality index which takes most seriously the element of unfairness present in seats-votes disproportionality. The measure is based on different voter types, defined by the party or parties each voter voted for across multiple tiers. Where all voters vote sincerely for the same party across both tiers, the measure collapses to the traditional Sainte-Laguë index. Where voters split their vote, the measure incorporates the electoral success of voted-for parties at both levels. The index shows that basing disproportionality just on the list share of the vote exaggerates the disproportionality found in mixed member systems.</p>
</section>
<section id="problems-with-calculating-disproportionality-on-the-basis-of-the-list-share" class="level1">
<h1>Problems with calculating disproportionality on the basis of the list share</h1>
<p>There are at least three reasons why calculating disproportionality on the basis of the list vote alone – or what I’ll call <em>standard practice</em> – is bad. These reasons apply to all commonly used indices of disproportionality.</p>
<p>First, standard practice does not take account of the fact that the list share of the vote may not be principal determinant of seat shares. In particular, standard practice makes little sense in parallel systems where a majority of seats are awarded based on the nominal tier, or in compensatory systems where the nominal tier makes up more than three-quarters of the total seats <span class="citation" data-cites="bochsler2023balancing">(Bochsler 2023, 102557)</span>. Japan is an example of a parallel system where the nominal tier is more important (289 of 465 seats awarded in the nominal tier); Korea is an example of a notionally compensatory system where the proportional tier makes up just 15% of the legislature. These systems are not designed to make seat shares fully match list shares, and so presenting information on the gap between list shares and seat shares seems to miss the point. For these systems we might consider calculating disproportionality on the basis of the nominal tier share of the vote, but this would create a demarcation problem (when is the nominal tier share so large that the relevant vote share is the nominal tier share rather than the list tier share?)</p>
<p>Second, standard practice does not take account of the fact that the set of parties competing in the nominal and list tiers may vary for reasons good or bad. Take as an example the Non-Partisan Solidarity Union in Taiwan, which in the 2012 election ran only in single member districts, winning two seats. Because its list vote share was technically zero, the gap between its seat and vote share contributes significantly to overall disproportionality as measured by the Gallagher or Loosemore-Hanby indices. Worse still, the fact that the party won seats on zero percent of the vote creates a division-by-zero error in the formula used to calculate the Sainte-Laguë index, meaning that disproportionality is undefined!</p>
<p>Nominal and list-tier parties may differ for bad reasons. Decoy lists – where a party runs constituency candidates in a separate list to frustrate compensatory mechanisms in the list tier – are commonly held to be a bad thing <span class="citation" data-cites="bochsler2012quasi">(Bochsler 2012)</span>. These lists are bad because they frustrate the intent of the electoral law, but they are also bad because they make it harder to calculate a meaningful measure of disproportionality if the decoy list technically has negligible list vote share.</p>
<p>Third, standard practice ignores the fact that some voters “lend” or “rent out” their vote precisely because there is another approved party which is likely already to benefit from the electoral system <span class="citation" data-cites="meffert2010strategic meffert2011polls gschwend2016drives">(Meffert and Gschwend 2010, 2011; Gschwend et al. 2016)</span>. CDU/CSU voters in Germany often lend their vote to the FDP so that it can pass the electoral threshold <span class="citation" data-cites="roberts1988second">(Roberts 1988)</span>; SNP voters in Scotland similarly lend their vote to the Green party so that they can broaden the set of pro-independence parties. Should that strategy fail – as it did in the 2013 German elections – then it would seem strange to regard those lent votes as major contributors to disproportionality: the people who cast those lent votes already got a good return on their nominal tier vote.</p>
<p>Sadly it is not possible to remedy these problems easily. We can’t calculate separate indices of disproportionality for the different tiers and aggregate these together: the disproportionality in a nominal tier will advantage one set of parties, whilst the disproportionality in a compensatory tier will advantage a different set of parties, and because disproportionality is not signed, these two disproportionalities will add to something greater than any plausible measure of overall disproportionality.</p>
<p>We also can’t average the vector of vote shares across the two tiers. Averaging shares across the two tiers makes sense, but it fails to deal with the problem of parties that don’t run in both tiers, and parties that create decoy lists. It also fails to address “rental” mechanisms which mean that the vote share in one tier may be “low” precisely because support is strategically being directed to the other tier.</p>
</section>
<section id="an-extension-to-the-sainte-laguë-index" class="level1">
<h1>An extension to the Sainte-Laguë index</h1>
<p>I suggest extending an existing measure of disproportionality (the Sainte-Laguë index) to deal with the problem of multiple tiers. Because the Sainte-Laguë index can be represented as though it aggregated over <em>voters</em> rather than parties, it can be extended to analyse disproportionalities across multiple voter types, where a voter type is defined by the set of parties voted for across multiple tiers. This party/party-supporter duality allows me to combine the two tiers and present a measure of disproportionality that summarizes inequality amongst voters and disproportionality between parties.</p>
<p>The Sainte-Laguë index has two inputs: a vector of vote shares <img src="https://latex.codecogs.com/png.latex?v">, and a vector of seat shares <img src="https://latex.codecogs.com/png.latex?s">. The index can be written using two formula which look different but give identical results. The index can be written using squared differences between seat and vote shares:</p>
<p><span id="eq-chi"><img src="https://latex.codecogs.com/png.latex?%0AD_%7BSL%7D%20=%20%5Csum_i%5EN%20%5Cfrac%7B(s_i%20-%20v_i)%5E2)%7D%7Bv_i%7D%0A%5Ctag%7B1%7D"></span></p>
<p>where each party is indexed by <img src="https://latex.codecogs.com/png.latex?i">, and the summation runs over all parties <img src="https://latex.codecogs.com/png.latex?i%20=%201,%20...%20N">. This way of writing the index makes the index resemble the chi-squared index used to measure association.</p>
<p>Alternately, the index can be written as a weighted average of <em>advantage ratios</em>. The advantage ratio for a party, <img src="https://latex.codecogs.com/png.latex?A_i">, is equal to its seat share divided by its vote share: <img src="https://latex.codecogs.com/png.latex?A_i%20=%0A%5Cfrac%7Bs_i%7D%7Bv_i%7D">. Because shares always sum to one, the weighted mean advantage ratio across all parties must equal one. Departures from an advantage ratio of <em>one</em> therefore indicate disproportionality. The index is:</p>
<p><span id="eq-adv"><img src="https://latex.codecogs.com/png.latex?%0AD_%7BSL%7D%20=%20%5Csum_i%5En%20v_i%20(A_i%20-%201)%5E2%0A%5Ctag%7B2%7D"></span></p>
<p>Writing the Sainte-Laguë index in the form given by Equation&nbsp;2 allows us to think about what an extended index might look like if voters, not parties, were the unit of account <span class="citation" data-cites="van2008proportional">(Van Puyenbroeck 2008)</span>. Rather than speak of individual voters, I am going to aggregate and deal with voter <em>types</em>.</p>
<p>A voter type is defined by the set of parties they vote for across multiple tiers. The voter who votes for the CDU in the constituency vote and for the FDP in the list vote is one type. So too is the voter who votes for the SPD in the constituency vote and the AfD in the list vote. The voter who votes for the CDU in both the constituency vote and in the region vote is a particular type of voter: a <em>straight-ticket voter</em>.</p>
<p>Voter types are defined by <em>unordered</em> sets of parties, and don’t take account of which vote was cast for which party. This means that the voter who votes for the CDU in the constituency vote and the FDP in the list vote is of the same type as the voter who votes for the FDP in the constituency vote and the CDU in the list vote.</p>
<p>If there are <img src="https://latex.codecogs.com/png.latex?n"> parties competing, then the number of voter types is equal to the square of the number of parties. This is the number of <em>logically possible</em> voter types, but not all of these types are <em>politically plausible</em>: there are some voters who voted for the SPD in the constituency vote but AfD in the list vote, but this type is rare.</p>
<p>Having introduced the language of voter types, I’ll now make a further conceptual shift, and talk about <em>advantage ratios</em> for voter types rather than parties. I’m going to stipulate that the advantage ratio for a voter of type <img src="https://latex.codecogs.com/png.latex?t"> is equal to the average of advantage ratios of the parties that they supported, and that the advantage ratio for each party is now calculated based on the seats they won, divided by the proportion of voters who voted for them <em>on either vote</em>.</p>
<p>Formally,</p>
<p><span id="eq-ind-adv"><img src="https://latex.codecogs.com/png.latex?%0AA_t%20=%20%5Csum_%7Bi%20%5Cin%20t%7D%20%5Cfrac%7B1%7D%7B2%7D%20%5Cfrac%7Bs_i%7D%7Bq_i%7D%0A%5Ctag%7B3%7D"></span></p>
<p>where <img src="https://latex.codecogs.com/png.latex?i"> is a party that makes up voter type <img src="https://latex.codecogs.com/png.latex?t">, and where <img src="https://latex.codecogs.com/png.latex?q_i"> is the proportion of people that voted for party <img src="https://latex.codecogs.com/png.latex?i"> in either ballot. The proportion <img src="https://latex.codecogs.com/png.latex?q_i"> is always greater than a party’s list share or their nominal tier share, and the sum of all values of <img src="https://latex.codecogs.com/png.latex?q_i"> ranges between 100% (all voters are sincere and do not split their votes) to 200% (all voters split their ballot).</p>
<p>It should be clear from these definitions that we cannot work out how many people belong to each different voter type from the results data alone. If a party wins 10% of the constituency vote and 20% of the regional vote, then it’s <em>likely</em> that the overwhelming share of the constituency voters also gave their regional vote to that party, but even that is not guaranteed, and we have no way of knowing where the other ten percentage points came from.</p>
<p>I therefore work with survey data to develop this extended measure of disproportionality. My example is drawn from the 2021 Scottish Election Study. The figures in this section are based on the post-election survey wave, <em>except that</em> the survey weights for respondents have been raked so that the sample proportions of nominal and list votes for each party exactly match the reported results.</p>
<div class="cell">
<div id="tbl-voter-types" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-voter-types-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;1: Information on voter types. Cell entries give the proportion who gave votes to both the column and the row party. Some cells highlighted for illustration.
</figcaption>
<div aria-describedby="tbl-voter-types-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_8v733bovq97kpwi96eav(i, j, css_id) {
          var table = document.getElementById("tinytable_8v733bovq97kpwi96eav");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_8v733bovq97kpwi96eav(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_8v733bovq97kpwi96eav");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '6', j: 6 },  ], css_id: 'tinytable_css_tsudmy75izrf4imotxta',}, 
          { positions: [ { i: '2', j: 6 },  ], css_id: 'tinytable_css_odxlv4ajcbik725mgxq4',}, 
          { positions: [ { i: '1', j: 6 }, { i: '3', j: 6 }, { i: '4', j: 6 }, { i: '5', j: 6 },  ], css_id: 'tinytable_css_o6615o3ejqneiao4nzsh',}, 
          { positions: [ { i: '2', j: 3 }, { i: '2', j: 4 }, { i: '2', j: 5 },  ], css_id: 'tinytable_css_w1jkp3xs6sgsgc9o88qu',}, 
          { positions: [ { i: '2', j: 2 },  ], css_id: 'tinytable_css_u1p0fw83qz1a831bplm4',}, 
          { positions: [ { i: '1', j: 2 },  ], css_id: 'tinytable_css_pvlpm4tuo10bujpmz9ed',}, 
          { positions: [ { i: '1', j: 1 }, { i: '3', j: 3 }, { i: '4', j: 4 }, { i: '5', j: 5 },  ], css_id: 'tinytable_css_8y5wadr1xadsom3rzpoq',}, 
          { positions: [ { i: '6', j: 1 }, { i: '6', j: 2 }, { i: '6', j: 3 }, { i: '6', j: 4 }, { i: '6', j: 5 }, { i: '6', j: 0 },  ], css_id: 'tinytable_css_iipl69jso7hrtvev1edd',}, 
          { positions: [ { i: '0', j: 0 }, { i: '0', j: 2 }, { i: '0', j: 1 }, { i: '0', j: 3 }, { i: '0', j: 4 }, { i: '0', j: 5 }, { i: '0', j: 6 },  ], css_id: 'tinytable_css_r08gr0ms5x2yc6n5udpq',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_8v733bovq97kpwi96eav(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_tsudmy75izrf4imotxta, .table th.tinytable_css_tsudmy75izrf4imotxta { background-color: #99999966; background-color: #FDF38E; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_odxlv4ajcbik725mgxq4, .table th.tinytable_css_odxlv4ajcbik725mgxq4 { border-bottom: solid #00B14066 0.4em; background-color: #FDF38E; }
      .table td.tinytable_css_o6615o3ejqneiao4nzsh, .table th.tinytable_css_o6615o3ejqneiao4nzsh { background-color: #FDF38E; }
      .table td.tinytable_css_w1jkp3xs6sgsgc9o88qu, .table th.tinytable_css_w1jkp3xs6sgsgc9o88qu { border-bottom: solid #00B14066 0.4em; }
      .table td.tinytable_css_u1p0fw83qz1a831bplm4, .table th.tinytable_css_u1p0fw83qz1a831bplm4 { background-color: #99999966; border-right: solid #00B14066 0.4em; border-bottom: solid #00B14066 0.4em; }
      .table td.tinytable_css_pvlpm4tuo10bujpmz9ed, .table th.tinytable_css_pvlpm4tuo10bujpmz9ed { border-right: solid #00B14066 0.4em; }
      .table td.tinytable_css_8y5wadr1xadsom3rzpoq, .table th.tinytable_css_8y5wadr1xadsom3rzpoq { background-color: #99999966; }
      .table td.tinytable_css_iipl69jso7hrtvev1edd, .table th.tinytable_css_iipl69jso7hrtvev1edd { border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_r08gr0ms5x2yc6n5udpq, .table th.tinytable_css_r08gr0ms5x2yc6n5udpq { border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_8v733bovq97kpwi96eav" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col" data-row="0" data-col="0">Party</th>
                <th scope="col" data-row="0" data-col="1">Con</th>
                <th scope="col" data-row="0" data-col="2">Green</th>
                <th scope="col" data-row="0" data-col="3">Lab</th>
                <th scope="col" data-row="0" data-col="4">LDem</th>
                <th scope="col" data-row="0" data-col="5">Other</th>
                <th scope="col" data-row="0" data-col="6">SNP</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td data-row="1" data-col="0">Con</td>
                  <td data-row="1" data-col="1">18.06%</td>
                  <td data-row="1" data-col="2">0.05%</td>
                  <td data-row="1" data-col="3">5.33%</td>
                  <td data-row="1" data-col="4">1.78%</td>
                  <td data-row="1" data-col="5">1.62%</td>
                  <td data-row="1" data-col="6">0.47%</td>
                </tr>
                <tr>
                  <td data-row="2" data-col="0">Green</td>
                  <td data-row="2" data-col="1">.</td>
                  <td data-row="2" data-col="2">0.62%</td>
                  <td data-row="2" data-col="3">0.90%</td>
                  <td data-row="2" data-col="4">0.43%</td>
                  <td data-row="2" data-col="5">0.09%</td>
                  <td data-row="2" data-col="6">6.70%</td>
                </tr>
                <tr>
                  <td data-row="3" data-col="0">Lab</td>
                  <td data-row="3" data-col="1">.</td>
                  <td data-row="3" data-col="2">.</td>
                  <td data-row="3" data-col="3">14.45%</td>
                  <td data-row="3" data-col="4">1.67%</td>
                  <td data-row="3" data-col="5">0.85%</td>
                  <td data-row="3" data-col="6">1.86%</td>
                </tr>
                <tr>
                  <td data-row="4" data-col="0">LDem</td>
                  <td data-row="4" data-col="1">.</td>
                  <td data-row="4" data-col="2">.</td>
                  <td data-row="4" data-col="3">.</td>
                  <td data-row="4" data-col="4">3.57%</td>
                  <td data-row="4" data-col="5">0.26%</td>
                  <td data-row="4" data-col="6">0.71%</td>
                </tr>
                <tr>
                  <td data-row="5" data-col="0">Other</td>
                  <td data-row="5" data-col="1">.</td>
                  <td data-row="5" data-col="2">.</td>
                  <td data-row="5" data-col="3">.</td>
                  <td data-row="5" data-col="4">.</td>
                  <td data-row="5" data-col="5">0.44%</td>
                  <td data-row="5" data-col="6">1.96%</td>
                </tr>
                <tr>
                  <td data-row="6" data-col="0">SNP</td>
                  <td data-row="6" data-col="1">.</td>
                  <td data-row="6" data-col="2">.</td>
                  <td data-row="6" data-col="3">.</td>
                  <td data-row="6" data-col="4">.</td>
                  <td data-row="6" data-col="5">.</td>
                  <td data-row="6" data-col="6">38.16%</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
<p>Table&nbsp;1 gives information on the break-down of types in the 2021 election. The largest single type of voter (38.16% of all voters) is the voter who cast their vote for the SNP in both contests. There are large entries on the diagonals, which represent straight-ticket voters, but some of the off-diagonal entries are clearly relevant, like the 7% of voters who split their votes between the SNP and the Greens.</p>
<p>We can use this information to calculate advantage ratios for different voter types:</p>
<ul>
<li><p>for the voter type {SNP}: the number of seats won by the SNP in the 2021 election was <img src="https://latex.codecogs.com/png.latex?64%20/%20129%20=%200.496">; the proportion of people who voted for the SNP on either ballot was 0.499 (this being the sum of all entries in the yellow column); the party’s advantage ratio is therefore 0.994.</p></li>
<li><p>for the voter type {SNP, Green}: the advantage ratio for the SNP is as previously calculated. The advantage ratio for the Green party is their seat share (6.2%) divided by the proportion who voted for them on either ballot, or 0.0879153 (this being the sum of all entries in the L-shaped group of cells with a green border); the party’s advantage ratio is therefore 0.705; the average of these two advantage ratios is 0.85</p></li>
</ul>
<p>Because <img src="https://latex.codecogs.com/png.latex?q"> sum to more than 100%, the average advantage ratio is less than one. That means we can’t apply the Sainte-Laguë formula above in Equation&nbsp;2, which relies on the accounting identity that the population weighted advantage ratio is one. We must normalize by dividing by the share-weighted average of advantage ratios, or 0.827. Call this adjusted figure <img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BA%7D">. We can then use <img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BA%7D"> in Equation&nbsp;2, and replace the vote share with the proportion of voters in each type.</p>
<p>Formally,</p>
<p><span id="eq-sl-ext"><img src="https://latex.codecogs.com/png.latex?%0AD_%7BSL%7D%5E%7B%5Cast%7D%20=%20%5Csum_t%5ET%20p_t%20(%5Ctilde%7BA_t%7D%20-%201)%5E2%0A%5Ctag%7B4%7D"></span></p>
<p>where <img src="https://latex.codecogs.com/png.latex?%5Ctilde%7BA_t%7D%20=%20%5Cfrac%7BA_t%7D%7B%5Cbar%7BA%7D%7D">, <img src="https://latex.codecogs.com/png.latex?%5Cbar%7BA%7D%20=%20%5Csum_t%5ET%20p_t%20A_t">, and <img src="https://latex.codecogs.com/png.latex?A_t"> is as described in Equation&nbsp;3.</p>
<p>Given Equation&nbsp;4, then disproportionality in the 2021 Scottish Parliament election was<br>
5.3%, rather than the value of 0.069 that one would get by following standard practice and calculating the Sainte-Laguë index using the list share alone. Extending the Sainte-Laguë index in this allows us to recognize that many people voted for the SNP in the nominal tier and lent their votes to other parties in the list tier, and that therefore the SNP is not as over-represented as one might think – except that now we must say, “voter types involving the SNP” are not as advantaged as the list share alone would suggest.</p>
</section>
<section id="comparative-evidence" class="level1">
<h1>Comparative evidence</h1>
<p>We can repeat this exercise for other countries which use mixed systems. Here I draw on the Comparative Study of Electoral Systems Integrated file and two elections from module 6 of the CSES. I am able to use all mixed elections save one: the 2005 survey of Albanian voters does not include anyone who voted for some seat-winning parties. As such, I am unable to construct the joint distribution for all relevant parties for this election. I return to this issue in the conclusion.</p>
<p>Figure&nbsp;1 shows the values for all the mixed member elections in the CSES. In general, disproportionality under the extended Sainte-Laguë index is around two-thirds of disproportionality under the basic Sainte-Laguë index. Most elections have lower values under the extended index, but there are some exceptions. I discuss the Korean case below in more detail, as it is the most obvious exception to the pattern. Other elections where the extended Sainte-Laguë index exceeds the basic index result from complexities of the nominal tier: in Hungarian elections, the higher figure under the extended Sainte-Laguë arises because of disproportionalities in the two-round nominal tier, where first-round shares can be a poor guide to seat outcomes.</p>
<p>The two measures are visibly correlated (<img src="https://latex.codecogs.com/png.latex?r%20=%200.725">), and so elections which have high disproportionality based on the list votes alone are also likely to have high disproportionality based on this extended index – but the overall levels are lower. This in turn has implications for the level of disproportionality achieved in mixed systems compared to other simpler systems.</p>
<p>Whether the mixed system is mixed member proportional or mixed member parallel does not seem to affect the relationship between basic Sainte-Laguë and the extended version. Mixed member parallel systems generally have higher disproportionality, and so they are further to the right side of the graph. However, mixed member proportional systems can also have high disproportionality, as in Germany in 2013, when the FDP, AfD, and Piraten all fell foul of the five percent threshold. That disproportionality concerned the proportional tier alone, and this election result looks disproportional on either the basic Sainte-Laguë index or the extended version.</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-scatter" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-scatter-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/mixed_member_proportionality/index_files/figure-html/fig-scatter-1.png" class="img-fluid figure-img" width="1152">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-scatter-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: Scatter-plot showing values of the ordinary Sainte-Laguë index calculating using vote shares from the proportional tier, and the extended Sainte-Laguë using information from votes in both tiers. Countries below the 45 degree line have lower values under the extended index.
</figcaption>
</figure>
</div>
</div>
</div>
<p>We can also compare the extended version of the Sainte-Laguë index that I have argued for to the simpler version which involves averaging over vote shares in the nominal and list tiers before calculating disproportionality. This is shown in Figure&nbsp;2. These two measures are more strongly correlated (<img src="https://latex.codecogs.com/png.latex?r%20=%200.878">), but there are differences in the levels. Levels of disproportionality under the extended Sainte-Laguë index are generally lower, and are on average around 87.3 percent of the values of the index when averaging over nominal and list tier votes.</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-scatter2" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-scatter2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/mixed_member_proportionality/index_files/figure-html/fig-scatter2-1.png" class="img-fluid figure-img" width="1152">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-scatter2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;2: Scatter-plot showing values of an ’averaged’Sainte-Laguë index calculating using the average of vote shares from the nominal and list tiers, and the extended Sainte-Laguë using information from votes in both tiers. Countries below the 45 degree line have lower values under the extended index.
</figcaption>
</figure>
</div>
</div>
</div>
<p>Whether we compare the extended Sainte-Laguë to the basic Sainte-Laguë index or to a version which averages over list and nominal shares, there are pairs of countries which have very different values on the two indices. The most obvious contrast is between New Zealand in 2023 and South Korea in 2012. These two elections were equally disproportional if we are to judge by the standard Sainte-Laguë index: the values are almost identical (0.066 for Korea, 064 for New Zealand). However, the extended index suggests that the South Korean result was much more disproportional. Why is this?</p>
<p>The answer lies in a combination of the gap between list and nominal shares, the dispersion of advantage ratios; and the size of split-ticketing groups which choose “poorly”. First, note that in the 2012 Korean election, the gap between the list tier share and the nominal tier share was small for the two largest parties – of the order of a percentage point. The extended Sainte-Lagüe index can make an outcome that seems disproportional on the basis of the list tier look better by incorporating information from the nominal tier. Here, there is no gap to make good. Second, note that the Korean system is heavily majoritarian – the nominal tier contributes 85% of seats. This means that the votes-seats curve is extremely steep at its inflection point. The contrast is with the New Zealand system which has a discontinuity in the votes-seats curve at the threshold of five percent, but is otherwise fairly smooth. Whether they lend their votes to the Greens, the ACT, or NZ First, voters are similarly treated, even though these parties differ in vote share by five to six percentage points. Third, although many voters in the Korean election were straight-ticket voters, a sizeable proportion of Saenuri and Democratic United Party voters experimented with other parties. Because the votes-seats curve is so steep, any defection from one of the two big parties means that these voters advantage ratio couples one fairly good advantage ratio to one fairly disastrous advantage ratio. In other words, the extended Sainte-Laguë index shows that in a more majoritarian mixed system, trying to split your vote risks wasting at least one vote. The difference in values is therefore indicative of the difference in the two systems which, although both formally of the same mixed member proportional type, differ substantially in their composition.</p>
</section>
<section id="conclusions" class="level1">
<h1>Conclusions</h1>
<p>In this note I’ve introduced an extension of the Sainte-Laguë index which allows the measurement of disproportionality across multiple votes given information on the joint distribution of those votes.</p>
<p>This index has several desirable features. First, it allows us to incorporate information from both votes cast by voters, rather than privileging one vote and ignoring the other. Second, the index collapses to the normal Sainte-Laguë index if all voters are straight-ticket voters. Third, the index deals with decoy lists by exploiting the empirical overlap between nominal slates and upper-tier lists.</p>
<p>The major disadvantage of the index is that it requires information on the joint distribution of votes across tiers. In this note I have used survey information to construct that joint distribution, but I have also noted that in one case (Albania 2005) the survey data was not detailed enough to construct the marginal distributions for at least one seat-winning party. I would suggest that estimating the joint distribution of votes is a basic descriptive task for anyone involved in studying elections in countries which use mixed systems, and so this information <em>ought</em> to be available. If it is not available then it would in principle be possible to estimate the joint distribution using ecological inference, particularly where electoral results are available at a very granular level.</p>
<p>This extension to the Sainte-Laguë index is not the only possible way of extending the index. In particular, I have made some design choices that seemed to me appropriate, but that are not the only valid choices. I have defined voter types as the unordered set of parties supported by each voter, rather than the set ordered by tier. In some senses, the voter who votes for the CDU/CSU in the nominal tier and lends their vote gets the same representation as the voter who votes the other way around, but it seems odd to say that they are equally advantaged. Paying attention to ordering raises the question of whether we should attach the same weight to advantage ratios for “list-tier” parties and “nominal tier” parties. Our present standard for calculating disproportionality attaches zero weight to the constituency tier, and I think that is wrong, but it does not follow from this that the best weighting is an equal weighting. I have not gone beyond equal weighting because unequal weighting seems to move us beyond disproportionality and into an assessment of how well election outcomes match voters’ cardinal utility over parties, and that is definitely a much bigger topic than can be handled here <span class="citation" data-cites="monroe1995fully blais2022party">(Monroe 1995; Blais et al. 2022)</span>.</p>



</section>


<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent">
<div id="ref-blais2022party" class="csl-entry">
Blais, André, Eric Guntermann, Vincent Arel-Bundock, Ruth Dassonneville, Jean-François Laslier, and Gabrielle Péloquin-Skulski. 2022. <span>“Party Preference Representation.”</span> <em>Party Politics</em> 28 (1): 48–60.
</div>
<div id="ref-bochsler2012quasi" class="csl-entry">
Bochsler, Daniel. 2012. <span>“A Quasi-Proportional Electoral System <span>‘Only for Honest Men’</span>? The Hidden Potential for Manipulating Mixed Compensatory Electoral Systems.”</span> <em>International Political Science Review</em> 33 (4): 401–20.
</div>
<div id="ref-bochsler2023balancing" class="csl-entry">
Bochsler, Daniel. 2023. <span>“Balancing District and Party Seats: The Arithmetic of Mixed-Member Proportional Electoral Systems.”</span> <em>Electoral Studies</em> 81: 102557.
</div>
<div id="ref-gschwend2016drives" class="csl-entry">
Gschwend, Thomas, Lukas Stoetzer, and Steffen Zittlau. 2016. <span>“What Drives Rental Votes? How Coalitions Signals Facilitate Strategic Coalition Voting.”</span> <em>Electoral Studies</em> 44: 293–306.
</div>
<div id="ref-linhart2019mixed" class="csl-entry">
Linhart, Eric, Johannes Raabe, and Patrick Statsch. 2019. <span>“Mixed-Member Proportional Electoral Systems–the Best of Both Worlds?”</span> <em>Journal of Elections, Public Opinion and Parties</em> 29 (1): 21–40.
</div>
<div id="ref-meffert2010strategic" class="csl-entry">
Meffert, Michael F, and Thomas Gschwend. 2010. <span>“Strategic Coalition Voting: Evidence from Austria.”</span> <em>Electoral Studies</em> 29 (3): 339–49.
</div>
<div id="ref-meffert2011polls" class="csl-entry">
Meffert, Michael F, and Thomas Gschwend. 2011. <span>“Polls, Coalition Signals and Strategic Voting: An Experimental Investigation of Perceptions and Effects.”</span> <em>European Journal of Political Research</em> 50 (5): 636–67.
</div>
<div id="ref-monroe1995fully" class="csl-entry">
Monroe, Burt L. 1995. <span>“Fully Proportional Representation.”</span> <em>American Political Science Review</em> 89 (4): 925–40.
</div>
<div id="ref-roberts1988second" class="csl-entry">
Roberts, Geoffrey K. 1988. <span>“The ‘Second-Vote’campaign Strategy of the West German Free Democratic Party.”</span> <em>European Journal of Political Research</em> 16 (3): 317–37.
</div>
<div id="ref-tanacs2025hacking" class="csl-entry">
Tanács-Mandák, Fanni, and Attila Horváth. 2025. <span>“The <span>‘Hacking’</span> of a Mixed Electoral System: A Case Study of Hungary.”</span> <em>Public Choice</em> 204 (1): 75–99.
</div>
<div id="ref-van2008proportional" class="csl-entry">
Van Puyenbroeck, Tom. 2008. <span>“Proportional Representation, Gini Coefficients, and the Principle of Transfers.”</span> <em>Journal of Theoretical Politics</em> 20 (4): 498–526.
</div>
</div></section><section id="footnotes" class="footnotes footnotes-end-of-document"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>

<ol>
<li id="fn1"><p>There are some papers which calculate disproportionality in different ways, but this is usually only intended as a way of decomposing electoral advantage, rather than stipulating a measure of disproportionality <em>as such</em>. <span class="citation" data-cites="tanacs2025hacking">Tanács-Mandák and Horváth (2025)</span>, for example, measure “total disproportionality” in Hungary by comparing seat share to list share, but also compare the share of list votes to the share of list seats, and the share of list votes to the share of SMD seats, a measure which makes little sense in the context of the measurement of disproportionality but which helps explain a great deal about Fidesz’ advantage under the Hungarian system.↩︎</p></li>
</ol>
</section></div> ]]></description>
  <category>elections</category>
  <category>proportionality</category>
  <guid>http://www.chrishanretty.co.uk/posts/mixed_member_proportionality/</guid>
  <pubDate>Thu, 14 May 2026 23:00:00 GMT</pubDate>
</item>
<item>
  <title>French lessons</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/french_lessons/</link>
  <description><![CDATA[ 





<p>Recent polling suggests that if a UK general election were held tomorrow, no party would win more than thirty percent, but five parties would win more than ten percent of the vote. To use terms familiar to political scientists, we currently have a high <a href="https://en.wikipedia.org/wiki/Effective_number_of_parties">effective number</a> of vote-winning parties.</p>
<p>It’s hard to say how this would translate to seats given the single member district plurality (SMDP) system used in the UK.<sup>1</sup> <a href="https://bsky.app/profile/appgfairelections.bsky.social/post/3mesv773ih22k">Many people are saying this</a>. There are SMDP systems like India which have a high effective number of vote-winning parties, but they typically involve congeries of more predictable regional party systems.</p>
<p>Because such a high effective number of vote winning parties would be unprecedented, unpredictable, and very likely unwelcome for all, interest has grown in alternative electoral systems. Aided by <a href="https://www.chrishanretty.co.uk/posts/single_party_majority_limbo/">one of the most disproportional elections ever</a>, public support for proportional representation has reached <a href="https://electoral-reform.org.uk/support-for-proportional-representation-hits-record-high-according-to-new-research/">record levels</a>.</p>
<p>Unfortunately, “proportional representation” is not a single product that you can buy off-the-shelf. There are qualitative differences between systems: single transferable voting; varieties of mixed systems; and even differences between open and closed lists in the largest single family, that of of list proportional representation. There are also quantitative differences: systems of proportional representation with small districts (like Spain) work very differently to systems of proportional representation with a single nationwide district (like the Netherlands).</p>
<p>All of this is to say that any move to adopt proportional representation would have first to answer the question, “what kind of proportional representation”.</p>
<p>It’s therefore somewhat quixotic for David Klemperer to suggest that what we need is change the electoral system <a href="https://blogs.bath.ac.uk/iprblog/2026/03/10/electoral-reformers-should-look-beyond-proportionality/"><em>to another system from the majoritarian family</em>.</a>. David suggests that adopting the two-round system as used in France would be better than adopting proportional representation.</p>
<p>David describes his post as a provocation, and I consider myself provoked. I think David dismisses the benefits of PR, misunderstands French politics, and builds his reform proposal around a block politics which is a product of the present moment.</p>
<section id="are-the-benefits-of-pr-overstated" class="level2">
<h2 class="anchored" data-anchor-id="are-the-benefits-of-pr-overstated">Are the benefits of PR overstated?</h2>
<p>David writes:</p>
<blockquote class="blockquote">
<p>“claims of PR’s downstream benefits (in terms of higher turnout, higher trust, or lower inequality) are often highly overstated, and often relate more to contingent party system dynamics or to the historical circumstances of its initial introduction to a given country than to inherent properties of proportionality itself”.</p>
</blockquote>
<p>I don’t wish to defend all claims made in favour of PR. No doubt campaigning organisations present <a href="https://electoral-reform.org.uk/does-proportional-representation-lead-to-higher-turnout/">statistics on turnout in PR countries</a> without any rigorous causal identification strategy. That’s a shame, because there is good evidence that PR boosts turnout and lowers inequality, evidence which by design rules out “contingent party system dynamics” or “historical circumstances”.</p>
<p>In <a href="https://andy.egge.rs/papers/Eggers_ProportionalityTurnoutFrance.pdf">France</a> and <a href="https://doi.org/10.4135/9781529716764">Poland</a>, researchers have used regression discontinuity designs to show that local elections held under proportional rules have higher turnout than local elections held under plurality rules. We know that this higher turnout is a consequence of the electoral rule, because the electoral rule is stipulated by a population threshold, and because local councils which just fall short of the population threshold don’t have different characteristics or histories to local councils which narrowly exceed the population threshold. PR boosts turnout by either 1.5 percentage points (France) or 4 percentage points (Poland).</p>
<p>This is high quality evidence. The evidence base for the positive effect of PR on turnout is, in my judgement, stronger than the evidence base for the negative effect of voter ID requirements on turnout. You can say that effects of one or four percentage points aren’t large: they are certainly small compared to the effects of David’s preferred solution of <a href="https://consoc.org.uk/publications/universal-suffrage/">compulsory voting</a>. But small does not mean negligible, and meaningful improvements in turnout can be achieved by many marginal gains.</p>
<p>Similarly, there are multiple studies which identify the effect of the adoption of PR upon inequality. Terminally online Britons may be used to the synthetic control method, since this is the method most commonly used to estimate the negative impact of Brexit on the UK economy. That same method has been used to estimate that New Zealand’s adoption of PR <a href="https://doi.org/10.1177/00104140231169018">meaningfully increased the amount of redistribution</a>. Other studies have used historical transitions to PR, finding that Norwegian councils which were required to use PR <a href="https://doi.org/10.1016/j.electstud.2022.102494">redistributed more</a> and that Swiss cantons which switched to PR started spending more on public health programmes [reducing child mortality](https://docs.iza.org/dp12729.pdf.</p>
</section>
<section id="does-this-proposal-match-whats-happening-in-french-politics" class="level2">
<h2 class="anchored" data-anchor-id="does-this-proposal-match-whats-happening-in-french-politics">Does this proposal match what’s happening in French politics?</h2>
<p>David writes:</p>
<blockquote class="blockquote">
<p>“The French system… accommodates multi-partyism while letting electorates make clear and decisive choices. It allows smaller parties to use their bargaining power to secure parliamentary representation, while working against extremist forces (who are both likely to struggle to form alliances, and against whom voters for other parties can unite in the second round)”</p>
</blockquote>
<p>The two-round system is not unique to France, but France has held more democratic elections under the two-round system than any other country. According to <a href="https://mattgolder.com/elections">Bormann and Golder</a>, between 1919 and 2020 France held seventeen democratic legislative elections under the two-round system. No other country using that system held as many, and many of the remaining countries are either very small (Comoros: six elections 1992-2020; Kiribati: 12 elections 1982-2020) or have since ceased to be democracies (Mali: seven elections 1992-2020). If French politics has a strongly “decisionist” character, that would be <em>prima facie</em> evidence that the two-round system is conducive to “decisionism”.</p>
<p>Unfortunately for David’s argument, contemporary French politics doesn’t demonstrate much evidence of “decisionism”, and the description given above would cause even a Dr.&nbsp;Pangloss to shrink back. The <a href="https://en.wikipedia.org/wiki/2024_French_legislative_election">most recent legislative election</a> created a tripolar legislature where a governing “centrist” block is opposed by groupings on the far left and far right. It yielded the <a href="https://en.wikipedia.org/wiki/First_Lecornu_government">shortest-lived French government ever</a> – quite an achievement for those of us required, willing or not, to study the record of the Fourth Republic – and the <a href="https://en.wikipedia.org/wiki/S%C3%A9bastien_Lecornu">current Prime Minister</a> (the same guy as the previous Prime Minister) lurches from no-confidence motion to no-confidence motion</p>
<p>One might be generous, and describe the current period of ongoing crisis as an anomaly resulting from Macron’s decision to call a snap election in 2024. But this generosity benefits the giver more than the receiver: if we can say that some negative effects only appeared under the two round system due to the President, then we can also say that any positive effects under a two round system might also be due to the presidency. Legislative elections held shortly after presidential elections benefit from <a href="https://doi.org/10.1017/9781108261128.013">presidential coat-tails or a honeymoon effect</a>. French legislative elections are almost always held shortly after presidential elections. It seems <em>at least possible</em> that the presidential election shapes the legislative election and makes any <a href="https://doi.org/10.1111/1475-6765.12227">government formation process much simpler</a>.</p>
<p>In summary: the most obvious example of politics under a two-round system doesn’t display lots of decisionism, and the decisionism it does display might be a result of a directly elected president rather than the electoral system.</p>
<p>More generally, I have a visceral negative aesthetic reaction to the two-round system and the fragmentation it creates relative to either first-past-the-post or the alternative vote. I have spent enough time creating placeholder categories for <a href="https://en.wikipedia.org/wiki/Miscellaneous_left">“divers gauche”</a> and “divers droit”: I do not need any more of it.</p>
</section>
<section id="this-block-can-fit-so-many-parties" class="level2">
<h2 class="anchored" data-anchor-id="this-block-can-fit-so-many-parties">This block can fit so many parties</h2>
<p>One starting point for the proposal is the claim that British electoral politics is becoming “block politics”, with greater attachment to “left” or “right” than the parties which make up those blocks. Nothing is new under the sun, and <a href="https://books.google.co.uk/books/about/Identity_Competition_and_Electoral_Avail.html?id=uoVvQgAACAAJ&amp;redir_esc=y">block politics has always been with us</a>. What does seem new is the absence of a clearly dominant party within each block. It’s this feature which threatens to cause chaos in the translation of votes to seats.</p>
<p>Although I dislike first-past-the-post, I think it’s wrong to hold the current high effective number of vote-winning parties as an argument against it. We might be in an out-of-equilibrium position because no party is dominant within its block. But out-of-equilibrium positions can return to equilibrium if the system is allowed to continue in operation. If we have an election with a very high effective number of parties, it’s very hard for the distribution of seats <em>within each bloc</em> to be proportional: it would require a very particular electoral geography. Each block would likely find its dominant party through the crushing operation of the plurality rule. I’d like electoral reform to be based on the general statement that SMDP treats some voters much better than others.</p>
<p>The converse of this is that it’s probably <em>not</em> a good idea to pick an electoral system based on a pattern of vote shares found in contemporary opinion polls three years out from the most likely date of the next general election. The current distribution of vote intention <em>is a product of the electoral system</em>; if we were to have a different electoral system, we’d have a difference distribution of vote intention, and possibly a different set of relevant parties. If people were like sticks of Blackpool rock marked “left block” or “right block”, then a two-round system would be a good choice. But most of what people think is structured by <a href="https://doi.org/10.1093/9780198955245.001.0001">idiosyncratic and instability, rather than ideology</a>.</p>
</section>
<section id="conclusion" class="level2">
<h2 class="anchored" data-anchor-id="conclusion">Conclusion</h2>
<p>I don’t know what electoral system is best for the UK. If I could decide unilaterally, I’d choose closed list proportional representation with district magnitude of between three and five. I’d accept most other systems of proportional representation, up to and including mixed systems which are <a href="https://ballotbox.scot/snp-didnt-break-2011-but-might-2026/">sometimes not so proportional</a>. But the two round system is one of the few systems I think is worse than first-past-the-post. If anyone wants to come out in favour of multimember plurality, you could troll me worse than David has, but the game might not be worth the candle.</p>


</section>


<div id="quarto-appendix" class="default"><section id="footnotes" class="footnotes footnotes-end-of-document"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>

<ol>
<li id="fn1"><p>I don’t like to call this system first-past-the-post, because it implies the existence of a set finishing line.↩︎</p></li>
</ol>
</section></div> ]]></description>
  <category>elections</category>
  <category>proportionality</category>
  <guid>http://www.chrishanretty.co.uk/posts/french_lessons/</guid>
  <pubDate>Thu, 12 Mar 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Critical comment on ‘Does Rent Control Turn Tenants Into NIMBYs?’</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/rent_controls/</link>
  <description><![CDATA[ 





<p>In a <a href="https://doi.org/10.1086/738581">recent Journal of Politics paper</a>, Hanno Hilbig, Robert Vief and Anselm Hager argue that rent control makes tenants more likely to support development in their area.</p>
<p>They base this on a survey of Berlin tenants. They argue that they are able to identify the causal effect of “being in a rent controlled apartment” by exploiting a discontinuity in the rent control legislation. “Rent control only applied in apartments built before 2014”, and so they “use [a] regression discontinuity design for the main effects”. This design is suitable where the probability of being treated jumps suddenly at a value of a running variable. In this case, the running variable is “year of construction”, and the probability of “being in a rent controlled apartment” jumps down for buildings built in 2014 or later.</p>
<p>Their outcome variable is an index of NIMBYism, created by averaging respondents’ agreement to two statements:</p>
<ul>
<li>“There should be more housing construction in my neighborhood”</li>
<li>“I would like to see more people moving to my neighborhood”</li>
</ul>
<p>Their main result is that “being in a rent controlled apartment” causes a <em>decrease</em> of 0.8 standard deviations in NIMBYism. This is the opposite of what the authors expected in their <a href="https://files.osf.io/v1/resources/kwjem/providers/osfstorage/6359791529357f0123f32319">pre-registered analysis plan</a>. It is to their credit that they have published something which goes against their pre-registered analysis plan.</p>
<p>This effect is <em>surprising</em> in two senses. First, it is in the opposite direction to the effect the authors expected. Whilst many people, upon being told that rent control decreases NIMBYism, find somehow to make sense of this, the best test of what is surprising is what people thought before they had a result. Second, the effect size is absolutely huge. An effect of 0.8 standard deviations is roughly equivalent to the <a href="https://bsky.app/profile/dingdingpeng.the100.ci/post/3m7kbfnx3vc2s">decline in sleep satisfaction for new mothers</a>.</p>
<p>For better or worse, surprising findings attract greater scrutiny at all stages of the publication process, whether those stages come before or after publication. After publication, interested parties are often able to look at replication data, something which is not always true at the stage of peer review.<sup>1</sup> Because in this case the replication materials are <a href="https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/CV8I6N">available online</a>, I was able to replicate the author’s findings. I’ll start by repeating the main finding, before noting some issues with the analysis that I think indicate an error.</p>
<p>I’ll load some libraries that I will use throughout.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">suppressPackageStartupMessages</span>({</span>
<span id="cb1-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse) <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## for data manipulation</span></span>
<span id="cb1-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(rdrobust) <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## for the regression discontinuity</span></span>
<span id="cb1-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(here) <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## so I don't get lost in directories</span></span>
<span id="cb1-5">})</span>
<span id="cb1-6">here<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">i_am</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"index.qmd"</span>)</span></code></pre></div></div>
<div class="cell-output cell-output-stderr">
<pre><code>here() starts at /home/chanret/Dropbox/website/posts/rent_controls</code></pre>
</div>
</div>
<p>I load in the data, which is conveniently stored as an R dataset, and filter to those for whom we have information on treatment.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readRDS</span>(here<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">here</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"data_main.rds"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(treated_rd_relative))</span></code></pre></div></div>
</div>
<p>Although the authors’ code goes through several subsets of the data, with several sets of control covariates (more on that later), I will replicate what I take to be the main specification. This includes information on:</p>
<ul>
<li>all tenants</li>
<li>respondents’ education and sex</li>
<li>apartments’ interior_quality, and post code</li>
</ul>
<p>We set up the outcome variable as a standardized variable.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.vector</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>index_nimbyism))</span></code></pre></div></div>
</div>
<p>We set up the running variable.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>years_rel_2013</span></code></pre></div></div>
</div>
<p>and finally the matrix containing the covariates, without any intercept, and dropping the reference category on the first listed variable.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">Z <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">model.matrix</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>educ <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> sex <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> interior_quality <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> post_code <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb6-2">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat)[,<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span></code></pre></div></div>
</div>
<p>We can now estimate the model in <code>rdrobust</code></p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">m1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rdrobust</span>(y, x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">c =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">h =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">b =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>,</span>
<span id="cb7-2">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">covs =</span> Z, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">all =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb7-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(m1)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>Covariate-adjusted Sharp RD estimates using local polynomial regression.

Number of Obs.                  608
BW type                      Manual
Kernel                   Triangular
VCE method                       NN

Number of Obs.                  446          162
Eff. Number of Obs.             446          162
Order est. (p)                    1            1
Order bias  (q)                   2            2
BW est. (h)                   5.000        5.000
BW bias (b)                   5.000        5.000
rho (h/b)                     1.000        1.000
Unique Obs.                     446          162

=======================================================================================
        Method     Coef. Std. Err.         z     P&gt;|z|      [ 95% C.I. ]       
=======================================================================================
  Conventional    -0.640     0.146    -4.385     0.000    [-0.927 , -0.354]    
Bias-Corrected    -0.805     0.146    -5.511     0.000    [-1.091 , -0.519]    
        Robust    -0.805     0.260    -3.099     0.002    [-1.314 , -0.296]    
=======================================================================================</code></pre>
</div>
</div>
<p>The authors’ main finding is the “robust” estimate reported in the third row.</p>
<p>I’ve therefore been able to achieve “reproducibility”: I can follow the same steps as the authors to achieve the same results. The next step is asking whether the analytic choices made by the authors make sense.</p>
<p>The first thing to note is that this regression discontinuity design depends on covariates. If one ignores the covariates, one finds a much smaller effect which is no longer statistically significant. The authors report as much in Table A.10 of their appendix.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">m2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rdrobust</span>(y, x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">c =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">h =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">b =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">all =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb9-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(m2)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>Sharp RD estimates using local polynomial regression.

Number of Obs.                  608
BW type                      Manual
Kernel                   Triangular
VCE method                       NN

Number of Obs.                  446          162
Eff. Number of Obs.             446          162
Order est. (p)                    1            1
Order bias  (q)                   2            2
BW est. (h)                   5.000        5.000
BW bias (b)                   5.000        5.000
rho (h/b)                     1.000        1.000
Unique Obs.                     446          162

=======================================================================================
        Method     Coef. Std. Err.         z     P&gt;|z|      [ 95% C.I. ]       
=======================================================================================
  Conventional    -0.191     0.178    -1.073     0.283    [-0.540 , 0.158]     
Bias-Corrected    -0.314     0.178    -1.764     0.078    [-0.663 , 0.035]     
        Robust    -0.314     0.314    -1.000     0.317    [-0.929 , 0.301]     
=======================================================================================</code></pre>
</div>
</div>
<p>Is it reasonable to control on covariates in general, and is it reasonable to condition on the particular covariates chosen by the authors?</p>
<p>The starting point for any RDD must be the Cambridge Element by Cattaneo, Idrobo and Titiunik, available <a href="https://arxiv.org/abs/1911.09511">here at Arxiv</a>. They write</p>
<blockquote class="blockquote">
<p>“A very important question is whether the covariate-adjusted [RDD estimator] estimates the same parameter as the unadjusted estimator… It can be shown that under mild regularity conditions, a sufficient condition is that the RD treatment effect on the covariates is zero, that is, that the averages of the covariates under treatment and control at the cutoff are equal to each other. This condition is analogous to the “covariate balance” requirement in randomized experiments, and will hold naturally when the covariates are truly predetermined… analogously to the case of randomized experiments, the generally valid justification for including covariates in RD analysis is the potential for efficiency gains, not the promise to fix implausible identification assumptions”</p>
</blockquote>
<p>In this case, the covariates are pre-determined. No respondent’s level of education or their sex depends on whether they live in a rent-controlled apartment. The respondent’s postcode in some senses doesn’t depend on the rent control – the <em>building</em> would have the same post-code, but the respondent might have moved to a different building. (That’s the reason why the authors remove one possible control variable, party, because they think that people might switch parties based on reactions to rent control).</p>
<p>The authors accept the general argument of Cattaneo, Idrobo and Titiunik that coefficients are their for precision. In their pre-analysis plan, they write:</p>
<blockquote class="blockquote">
<p>“the survey also elicited a number of covariates… which we use <em>to improve the efficiency of the statistical models</em>” (emphasis added)</p>
</blockquote>
<p>In the appendix to their article, they also demonstrate (Appendix Figure A.7) that many of their covariates are mostly balanced. It’s true that there seem to be proportionally more non-binary people in the treatment group, and proportionally more AfD supporters, but they do report twenty-one balance statistics, so we would expect one or two to be significant by chance alone without some multiple comparison correction.</p>
<p>The stated rationale for including covariates therefore seems reasonable, and the covariates for which the authors report balance are… balanced.</p>
<p>The problem comes with the inclusion of a covariate which is not discussed, and for which no balance statistics are provided. That’s the post-code. This distribution of this variable is very uneven. There is one post-code which features 38 times, and thirty post-codes which only ever appear once.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">hist</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">table</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>post_code),</span>
<span id="cb11-2">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>,</span>
<span id="cb11-3">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">main =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb11-4">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xlab =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Number of times the postcode appears"</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div id="fig-hist" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-hist-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/rent_controls/index_files/figure-html/fig-hist-1.png" class="img-fluid figure-img" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-hist-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: Histogram of postcode frequencies in the data
</figcaption>
</figure>
</div>
</div>
</div>
<p>The analysis depends crucially on the inclusion of this variable. Here I report an analysis which includes education, sex and interior quality, but omits postcode.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1">Z2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">model.matrix</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>educ <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> sex <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> interior_quality <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb12-2">                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat)[,<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb12-3">m3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rdrobust</span>(y, x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">c =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">h =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">b =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>,</span>
<span id="cb12-4">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">covs =</span> Z2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">all =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb12-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(m3)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>Covariate-adjusted Sharp RD estimates using local polynomial regression.

Number of Obs.                  608
BW type                      Manual
Kernel                   Triangular
VCE method                       NN

Number of Obs.                  446          162
Eff. Number of Obs.             446          162
Order est. (p)                    1            1
Order bias  (q)                   2            2
BW est. (h)                   5.000        5.000
BW bias (b)                   5.000        5.000
rho (h/b)                     1.000        1.000
Unique Obs.                     446          162

=======================================================================================
        Method     Coef. Std. Err.         z     P&gt;|z|      [ 95% C.I. ]       
=======================================================================================
  Conventional    -0.205     0.176    -1.170     0.242    [-0.550 , 0.139]     
Bias-Corrected    -0.353     0.176    -2.013     0.044    [-0.698 , -0.009]    
        Robust    -0.353     0.309    -1.143     0.253    [-0.960 , 0.253]     
=======================================================================================</code></pre>
</div>
</div>
<p>Here, the conventional effect is smaller (-0.2) and no longer statistically significant. The “robust” effect is also not statistically significant. Only the “bias-corrected” effect is statistically significant.</p>
<p>The dependence is specifically a dependence on post-code. When we replaced post-code with the identity of the <em>borough</em> [bezirk], then we don’t get a statistically significant effect either.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### New matrix with `bezname`</span></span>
<span id="cb14-2">Z3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">model.matrix</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>educ <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> sex <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> interior_quality <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> bezname <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, </span>
<span id="cb14-3">                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat)[,<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb14-4">m4 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rdrobust</span>(y, x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">c =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">h =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">b =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>,</span>
<span id="cb14-5">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">covs =</span> Z3, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">all =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb14-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(m4)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>Covariate-adjusted Sharp RD estimates using local polynomial regression.

Number of Obs.                  608
BW type                      Manual
Kernel                   Triangular
VCE method                       NN

Number of Obs.                  446          162
Eff. Number of Obs.             446          162
Order est. (p)                    1            1
Order bias  (q)                   2            2
BW est. (h)                   5.000        5.000
BW bias (b)                   5.000        5.000
rho (h/b)                     1.000        1.000
Unique Obs.                     446          162

=======================================================================================
        Method     Coef. Std. Err.         z     P&gt;|z|      [ 95% C.I. ]       
=======================================================================================
  Conventional    -0.190     0.171    -1.111     0.267    [-0.526 , 0.145]     
Bias-Corrected    -0.351     0.171    -2.046     0.041    [-0.686 , -0.015]    
        Robust    -0.351     0.307    -1.143     0.253    [-0.952 , 0.250]     
=======================================================================================</code></pre>
</div>
</div>
<p>I’ve found it difficult to identify the <em>specific</em> dependence on post-code. When I drop a single post-code at a time, the “robust” results are still significant. The difference between the results cannot therefore be explained as the result of one anomalous post-code.</p>
<p>However, it’s not necessary to identify the specific dependence on post-code to assess the appropriateness of including post-code. As Cattaneo, Idrobo and Titiunik write, to use a RDD with covariates, we need to assume that “the averages of the covariates under treatment and control at the cutoff are equal to each other”; to the extent that that assumption is not met, the design is inappropriate.</p>
<p>Given the distribution of post-codes shown in Figure&nbsp;1, it should be clear that we can’t demonstrate that the averages of the post-code related covariates are equal to each other at the cut-off. There are thirty post-codes which, because they have only a single value, are necessarily only ever included in the treatment or the control group. There are a further <strong>forty-two</strong> post-codes which are either all in the treatment condition or all in the control condition. To take the most extreme example: there are 23 respondents from post-code <a href="https://de.wikipedia.org/wiki/Berlin-Niedersch%C3%B6neweide">12439</a>, all of whom are in the control condition.</p>
<p>We can, if we wish, proceed to a formal balance check, using the same code that the authors themselves use for their balance figure, Figure A.7 in the appendix. This moves through different outcomes (respondent’s education, apartment quality) and performs a regression discontinuity design using that outcome. If we find a significant treatment effect on that new outcome, we know that there’s imbalance.</p>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Define a helper function</span></span>
<span id="cb16-2">tidy_rd <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(model, se_nr) {</span>
<span id="cb16-3">    est <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>coef[se_nr]</span>
<span id="cb16-4">    se <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>se[se_nr]</span>
<span id="cb16-5">    low <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>ci[se_nr, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb16-6">    high <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>ci[se_nr, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]</span>
<span id="cb16-7">    zstat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>z[se_nr]</span>
<span id="cb16-8">    pval <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pv[se_nr]</span>
<span id="cb16-9">    h_left <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bws[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb16-10">    h_right <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bws[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]</span>
<span id="cb16-11">    b_left <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bws[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb16-12">    b_right <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bws[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]</span>
<span id="cb16-13">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p</span>
<span id="cb16-14">    n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(model<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>N_h)</span>
<span id="cb16-15">    smry <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(</span>
<span id="cb16-16">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">estimate =</span> est, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std.error =</span> se, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">statistic =</span> zstat,</span>
<span id="cb16-17">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p.value =</span> pval, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conf.low =</span> low, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conf.high =</span> high, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p =</span> p,</span>
<span id="cb16-18">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> n, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bw_left_h =</span> h_left, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bw_right_h =</span> h_right, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bw_left_b =</span> b_left,</span>
<span id="cb16-19">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bw_right_b =</span> b_right</span>
<span id="cb16-20">    )</span>
<span id="cb16-21">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(smry)</span>
<span id="cb16-22">}</span>
<span id="cb16-23"></span>
<span id="cb16-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Define covariates</span></span>
<span id="cb16-25">outcomes <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>post_code)</span>
<span id="cb16-26">res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(outcomes, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(o) {</span>
<span id="cb16-27">    x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pull</span>(years_rel_2013)</span>
<span id="cb16-28">    y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>post_code <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> o)</span>
<span id="cb16-29">    rd <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rdrobust</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">c =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">h =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">b =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb16-30">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidy_rd</span>(rd, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb16-31">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outcome =</span> o)</span>
<span id="cb16-32">})</span>
<span id="cb16-33">res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(res)</span>
<span id="cb16-34"></span>
<span id="cb16-35">res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> res <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb16-36">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(estimate) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb16-37">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outcome =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fct_inorder</span>(outcome))</span>
<span id="cb16-38"></span>
<span id="cb16-39"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(res, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> outcome, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> estimate,</span>
<span id="cb16-40">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> conf.low,</span>
<span id="cb16-41">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> conf.high,</span>
<span id="cb16-42">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> p.value <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">05</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb16-43">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Effect of discontinuity upon covariate"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb16-44">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_discrete</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb16-45">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_pointrange</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb16-46">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"p-value less than 0.05?"</span>,</span>
<span id="cb16-47">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"darkgrey"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"darkred"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb16-48">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_flip</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb16-49">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb16-50">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>) </span>
<span id="cb16-51"></span>
<span id="cb16-52">res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> res <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb16-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p.adj =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">p.adjust</span>(p.value, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"holm"</span>))</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div id="fig-balance" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-balance-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/rent_controls/index_files/figure-html/fig-balance-1.png" class="img-fluid figure-img" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-balance-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;2: Balance tests for post-codes
</figcaption>
</figure>
</div>
</div>
</div>
<p>As you can see, the discontinuity has significant effects on nine post-codes, of which the largest is the negative effect on 10243 (part of Friedrichshain). What this means is that survey respondents living in buildings built just before 2014, to which the rent control applied, were much less likely to be living in Friedrichshain than survey respondents living in buildings built just after. Yes, this is an odd way of phrasing things.</p>
<p>Obviously one would need to know a lot more either about the history of residential development in Friedrichshain or the survey incentives to give a satisfying account of why this might be. It should be noted, though, that these imbalances are not minor, and achieving a significant imbalance is very hard given the small number of observations for some post-codes. If someone had come to me and said that they were going to run a regression discontinuity on a binary outcome with only 18 positive cases, I would have told them, “go away, your design is hopelessly underpowered”. To give one example: the effect of the previously mentioned post-code 12439, where all 23 respondents are all in the control condition, is not significant.</p>
<p>This suggests to me that although the authors have demonstrated balance with respect to the other categorical covariates included in the model, they have not achieved balance on postcode, and that any model which includes postcode is unsafe.</p>
<p>This criticism comes from inside the regression discontinuity framework, and even more narrowly from the “continuity” approach to regression discontinuity rather than the “local randomization” approach. The continuity approach relies on extrapolation from trends before and after the cut-off. The better we can approximate those trends using a rich and detailed trend line, the better the quality of our inferences. That doesn’t really apply when you have four unique values before your cut-off. It’s hard to draw any trend other that a straight line. Our fancy regression-discontinuity design turns out to be a linear regression in drag. There are alternative approaches to regression discontinuity, such as local randomization, but they typically involve dropping a lot of data.</p>
<p>This ties in to general reservations I have about the use of regression discontinuities where the running variable is a discrete variable which takes on a limited set of values. I think it’s a red flag that <code>rdrobust</code> chokes if you ask it for the “optimal” bandwidth: there’s just not enough data for it to work with. Similarly, <code>RDHonest</code> chokes unless you specify manually the “bound on second derivative of the conditional mean function”.</p>
<p>These software pathologies happen whether or not you control for covariates. Controlling for covariates seems innocuous when it’s presented in textbook treatments – typically applications which rely on huge quantities of administrative data. In these settings, where the data is generally opaque to the people whose outcomes are being modelled, I have no problem with the idea that certain covariates to be pre-treatment. In the survey case, things become slightly more awkward, because people move around. The authors included certain covariates in their pre-analysis plan but removed them from their final analysis because (for example) people might change their party or their apartment size <em>in response to</em> the rent control legislation. If that’s true, why isn’t that true of survey response generally? Would any factor which affects survey response end up being post-treatment? If that’s true, then survey-based regression discontinuity designs with covariates seem like a non-starter.</p>




<div id="quarto-appendix" class="default"><section id="footnotes" class="footnotes footnotes-end-of-document"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>

<ol>
<li id="fn1"><p>I don’t know whether reviewers had access to the replication materials.↩︎</p></li>
</ol>
</section></div> ]]></description>
  <category>code</category>
  <category>R</category>
  <category>housing</category>
  <guid>http://www.chrishanretty.co.uk/posts/rent_controls/</guid>
  <pubDate>Mon, 15 Dec 2025 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Notional results for the 2021 Scottish Parliament Election</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/sp2026_notionals/</link>
  <description><![CDATA[ 





<section id="executive-summary" class="level1 unnumbered">
<h1 class="unnumbered">Executive summary</h1>
<p>In this report I describe how I generated a set of notional results for the 2021 Scottish Parliament election.</p>
<p>These notional results give the count of constituency and list votes that would have been won by the six largest parties had the election been fought on the boundaries proposed by Boundaries Scotland.</p>
<p>These notional results were produced in part by <strong>multilevel regression and post-stratification</strong> (MRP). MRP is a technique which uses large national samples to generate estimates of opinion at the local level. It does this by combining sample information with information from the census on how many people of different demographic types live in different local areas.</p>
<p>The estimates have been scaled so that the notional results match exactly the 2021 results if the constituencies are unchanged. The estimates also preserve the total count of votes across constituencies. To give a simple example: if there are two constituencies A and B which exchange parcels of land, the sum of each party’s votes in A and B under the notional results is the same as the sum of those votes in the actual 2021 results.</p>
<p>The main conclusion is that under the proposed boundaries the Green party would have won one more seat, and the Labour party one fewer seat, than they did in fact win in 2021.</p>
<p>This report is divided into six parts.</p>
<ul>
<li>I begin by describing the building blocks of the exercise: census data for output areas and the Scottish Election Study.</li>
<li>Second, I describe the <em>post-stratification frame</em>, which stores how many people of different types live in different areas.</li>
<li>Third, I use the post-stratification frame to show the <em>index of change</em> between old and new constituencies.</li>
<li>Fourth, I describe the model I estimate, and show how some of the demographic characteristics are associated with the probability of voting for different parties (or not at all).</li>
<li>Fifth, I describe the notional results and the aggregate pattern of seats.</li>
<li>Finally, I compare these notional results to alternative notional results from Ballot Box Scotland.</li>
</ul>
</section>
<section id="building-blocks" class="level1">
<h1>Building blocks</h1>
<section id="output-areas" class="level2">
<h2 class="anchored" data-anchor-id="output-areas">Output areas</h2>
<p>The modelling I do is based on output areas.</p>
<p>Output areas are the smallest areas for which Scotland’s Census produces statistics.</p>
<p>There are over 46,000 output areas, with an average population of around 120 people.</p>
<p>Output areas don’t have names, only codes.</p>
<p>An example output area is S00145472, which is plotted in Figure&nbsp;1.</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-eg-oa" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-eg-oa-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/sp2026_notionals/index_files/figure-html/fig-eg-oa-1.png" class="img-fluid figure-img" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-eg-oa-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: Plot showing the boundaries of output area S00145472 (dashed red line) and the population weighted centroid (red star)
</figcaption>
</figure>
</div>
</div>
</div>
<p>This output area is a residential area in Gilmerton, in the south of Edinburgh. The houses there are recently built. At the time of the 2022 Census, the population was 153 individuals, of which 122 were of voting age.</p>
<p>Output areas are characterised by two things: their <strong>boundaries</strong>, and their <strong>population weighted centroid</strong>.</p>
<p>The boundary of an output area is not hard to understand. It shows where and how far the area extends. There are complications to do with shorelines, and how detailed these boundary lines can be, but they’re not relevant here.</p>
<p>The <em>centroid</em> of any flat shape is the point upon which the shape would balance perfectly, if the weight of the shape were the same at all points.</p>
<p>The <em>population weighted centroid</em> is the point at which the shape would balance perfectly if we located each person on the shape and give them equal weight.</p>
<p>The population weighted centroid for S00145472 is shown in the plot with a star. This is the best information we have about where most people in that output area are. There is no lower level source of official information about where people in this area live.</p>
<p>For this reason, I’ll be mapping output areas to existing and proposed parliamentary constituencies on the basis of their population weighted centroids. Some output areas might technically intersect constituency boundaries, but</p>
<ul>
<li>any intersections might be the result of coarsely drawn boundaries;</li>
<li>the proportion of people living in those intersections is likely to be negligible; and</li>
<li>there is no better official source which could resolve this issue.</li>
</ul>
</section>
<section id="scottish-election-study" class="level2">
<h2 class="anchored" data-anchor-id="scottish-election-study">Scottish Election Study</h2>
<p>The <a href="https://scottishelections.ac.uk/">Scottish Election Study</a> (SES) is an academic study of voting behaviour in Scottish elections. It has different components: an election study with a panel element, surveying people before and after elections, and a periodic opinion monitor, which samples a cross-section of people at irregular points through the year.</p>
<p>The 2021 election study was fielded in two waves. The pre-election wave was fielded between 8th April and 5th May; the post-election wave, between 13th and 28th May.</p>
<p>Because I am modelling how people voted, I focus on the 3,355 individuals who responded to the second wave, and in particularly the 3,254 individuals who reported either a list vote or a constituency vote, and for whom we know their Scottish Parliamentary constituency.</p>
<p>There are lots of variables in the SES which could potentially be used to model individuals’ voting behaviour. In this report, I model voting behaviour using the following individual characteristics:</p>
<ul>
<li>age</li>
<li>sex</li>
<li>whether or not they have a degree;</li>
<li>whether or not they belong to an ethnic minority;</li>
<li>whether the house in which they live is owned or rented;</li>
<li>whether they are religious</li>
<li>whether their national identity is Scottish above all other national identities</li>
</ul>
<p>I chose these individual characteristics because:</p>
<ul>
<li>they feature in the SES and in the Census in roughly similar form;</li>
<li>they feature in the 2011 census microdata which I use (see below);</li>
<li>they are predictive of voting behaviour;</li>
<li>they describe broad categories of people</li>
</ul>
<p>There are variables which I could have included which would ordinarily be useful in modelling voting behaviour but which don’t meet some of the criteria above.</p>
<p>One variable which is not present in the SES and the Census in the same form is social grade. The SES contains information on approximated social grade (whether the respondent belongs to grades AB, C1, C2 or DE). Whilst the 2011 census included information on approximated social grade, no such calculation has been performed for the 2022 census. The census does include information on standard occupational codings, which can be used to construct a class measurement, but I’ve not done so. In any case, approximated social grade is built upon other variables I do use in the analysis, such as housing tenure and educational qualifications.</p>
<p>One variable which is present in the SES and in the Census, but which is not present in the 2011 census microdata is sexual orientation. Sexual orientation is an important predictor of vote choice, but there was no question on sexual orientation in the 2011 census, and so it’s difficult to know how reports of sexual orientation are associated with other demographic variables.</p>
<p>Finally, there are some variables – or versions of variables – which are potentially predictive, but where the numbers of individuals involved are too small to make reliable inferences. Whilst it would be possible to investigate whether individuals from different ethnic minority backgrounds vote differently, only a small proportion of the Scottish population comes from an ethnic minority background, and the numbers involved are smaller when we disaggregate by specific ethnic minority group. I’ve therefore collapsed some variables like ethnicity and religion into dichotomies.</p>
<div style="page-break-after: always;"></div>
</section>
</section>
<section id="post-stratification-frame" class="level1">
<h1>Post-stratification frame</h1>
<p>The reason I described output areas is because information on these output areas allows me to create a <em>post-stratification frame</em>.</p>
<p>You can think of a post-stratification frame as a spreadsheet with a row for each combination of person characteristics, which records how many people with that set of characteristics live in each area.</p>
<p>For example: a post-stratification frame might record how many (i) men are (ii) aged between 60 and 64, are (iii) from an ethnic minority, (iv) have a university degree, are (v) religious, (vi) don’t identify primarily as Scottish, and (vii) live in rented accommodation.</p>
<p>Obviously, the smaller the areas and the more numerous and variegated the characteristics, the smaller these counts will be.</p>
<p>Constructing a post-stratification frame is an involved process. Although the Census tells us how many people in a given area are religious, and how many people in a given area live in rented accommodation, it doesn’t tell us how many people are religious renters. To use terms from statistics: the Census (generally) tells us about marginal distributions, but not the joint distribution.</p>
<p>To create a joint distribution, I use microdata from the 2011 census. This gives information on a five percent sample of 2011 census returns, or just over a quarter of a million individuals. With such a large volume of individual returns, we can work out the association between being religious and being a renter.</p>
<p>I use this data to create initial weights for each combination of characteristics. I then repeatedly multiply or divide these weights so that the sum of weights for each characteristic, taken one at a time, matches the marginal distribution reported in the Census. For example: I might have four proportions:</p>
<ul>
<li>religious renters;</li>
<li>religious owners;</li>
<li>irreligious renters;</li>
<li>irreligious owners;</li>
</ul>
<p>and I might multiply or divide the weights in first two categories to match the Census reported proportion of religious people in the relevant area. I might also multiply or divide the weights in the first and third categories to match the Census reported proportion of renters in the relevant area. Through repeated processes of multiplication and division – in statistical terms, “iterative proportional fitting” or “raking” – I can start with an arbitrary joint distribution and get something that matches what I know about each particular area.</p>
<p>Additionally, where the Census does report associations – as they do when they release tables like “Religion by sex by age” or “Ethnic group by age”, I can ensure that the combination of those characteristics is matched almost exactly at the local level.</p>
<p>In describing post-stratification frames, I have spoken about areas generically. For this report, I’ve constructed a post-stratification frame defined on intersections between old and new constituencies. There are 114 such intersections. This means that the post-stratification frame is defined by:</p>
<ul>
<li>area [114 intersections of old and new constituencies]</li>
<li>age [14 distinct categories]</li>
<li>sex [2 distinct categories]</li>
<li>membership of an ethnic minority [2 distinct categories]</li>
<li>university degree [2 distinct categories]</li>
<li>religiosity [2 distinct categories]</li>
<li>national identity [2 distinct categories]</li>
<li>housing tenure [2 distinct categories]</li>
</ul>
<p>This means that the post-stratification frame has just over 80,000 non-zero rows in it. After removing combinations with absolutely no people, the average (median) count in each cell / unique combination of attributes is fourteen.</p>
<p>This post-stratification frame covers the voting age population rather than the voting eligible population. There are individuals in the voting age population who are not eligible to vote because they are imprisoned for sentences longer than twelve months or because they are not a citizen of a qualifying country. The difference between the voting age population and the voting eligible population is much smaller in Scotland than in England because of less restrictive rules on the franchise.</p>
<p>In my opinion, this is the most granular post-stratification frame that can reasonably be constructed for this purpose. Whilst it would be desirable to model voting behaviour at a lower level, the SES only records information on respondent’s 2022 parliamentary constituency. Although it records information on postcode sector, postcode sectors can correspond to multiple output areas and can span (current and proposed) constituencies.</p>
<div style="page-break-after: always;"></div>
</section>
<section id="the-degree-of-change-between-old-and-new-constituencies" class="level1">
<h1>The degree of change between old and new constituencies</h1>
<p>Because we need to count how many people live in the intersections between old and new constituencies, we can calculate how much each new constituency has changed relative to its closest predecessor.</p>
<p>I define an index of change as one minus the proportion of the new constituency’s population which lived in the old constituency with the greatest population overlap, divided by the new constituency’s population.</p>
<p>I illustrate this with Edinburgh Southern. Figure&nbsp;2 shows the proposed boundary for Edinburgh Southern and the boundaries of its four predecessor constituencies.</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-edins" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-edins-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/sp2026_notionals/index_files/figure-html/fig-edins-1.png" class="img-fluid figure-img" width="864">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-edins-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;2: Plot showing the proposed boundary for Edinburgh Southern and boundaries of predecessor constituencies.
</figcaption>
</figure>
</div>
</div>
</div>
<p>The figure shows thart the new Edinburgh Southern has shifted southwards, taking in the eastmost part of Edinburgh Pentlands, and the southern fringe of Edinburgh Eastern, which had previously snaked round to include the Gilmeron area. The new Edinburgh Southern includes a tiny portion of Edinburgh central, although this may be due to inaccuracies in the map data.</p>
<div class="cell">
<div id="tbl-edins" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-edins-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;1: Proportion in the new Edinburgh Southern coming from four old constituencies
</figcaption>
<div aria-describedby="tbl-edins-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_uonoibvvgxhhpn4tmug8(i, j, css_id) {
          var table = document.getElementById("tinytable_uonoibvvgxhhpn4tmug8");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_uonoibvvgxhhpn4tmug8(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_uonoibvvgxhhpn4tmug8");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '4', j: 1 }, { i: '4', j: 2 },  ], css_id: 'tinytable_css_rusir9hma0mzk7r5krnn',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_82jmly7d9rr1gnsh775m',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_2dch896l8hubiy31kyyj',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 },  ], css_id: 'tinytable_css_4spjx9xs5n4sq7ga40ka',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_n4p7kmqwzxfs65ys6bct',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_uonoibvvgxhhpn4tmug8(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_rusir9hma0mzk7r5krnn, .table th.tinytable_css_rusir9hma0mzk7r5krnn { border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_82jmly7d9rr1gnsh775m, .table th.tinytable_css_82jmly7d9rr1gnsh775m { border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_2dch896l8hubiy31kyyj, .table th.tinytable_css_2dch896l8hubiy31kyyj { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_4spjx9xs5n4sq7ga40ka, .table th.tinytable_css_4spjx9xs5n4sq7ga40ka { text-align: left; }
      .table td.tinytable_css_n4p7kmqwzxfs65ys6bct, .table th.tinytable_css_n4p7kmqwzxfs65ys6bct { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_uonoibvvgxhhpn4tmug8" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col" data-row="0" data-col="0">Old constituency</th>
                <th scope="col" data-row="0" data-col="1">Population from this constituency</th>
                <th scope="col" data-row="0" data-col="2">Proportion</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td data-row="1" data-col="0">Edinburgh Central</td>
                  <td data-row="1" data-col="1">138</td>
                  <td data-row="1" data-col="2">0.2</td>
                </tr>
                <tr>
                  <td data-row="2" data-col="0">Edinburgh Eastern</td>
                  <td data-row="2" data-col="1">24657</td>
                  <td data-row="2" data-col="2">37.9</td>
                </tr>
                <tr>
                  <td data-row="3" data-col="0">Edinburgh Pentlands</td>
                  <td data-row="3" data-col="1">7765</td>
                  <td data-row="3" data-col="2">11.9</td>
                </tr>
                <tr>
                  <td data-row="4" data-col="0">Edinburgh Southern</td>
                  <td data-row="4" data-col="1">32485</td>
                  <td data-row="4" data-col="2">49.9</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
<p>Table&nbsp;1 shows the count of individuals coming from each of the four predecessor constituencies. The largest single contributor is the <em>old</em> Edinburgh Southern constituency, which contributes almost half of the <em>new</em> constituency population. The index of change is therefore <img src="https://latex.codecogs.com/png.latex?1%20-%20%5Cfrac%7B49.9%7D%7B100%7D%20=%20.501">.</p>
<div class="cell">
<div id="tbl-ioc" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-ioc-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;2: Index of change in the ten constituencies with the largest change
</figcaption>
<div aria-describedby="tbl-ioc-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_224fryo6ku3y8eh2agwg(i, j, css_id) {
          var table = document.getElementById("tinytable_224fryo6ku3y8eh2agwg");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_224fryo6ku3y8eh2agwg(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_224fryo6ku3y8eh2agwg");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '10', j: 1 }, { i: '10', j: 2 },  ], css_id: 'tinytable_css_zidild08sqvmm68bds0m',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_jfl1quewglwguxgizfwt',}, 
          { positions: [ { i: '10', j: 0 },  ], css_id: 'tinytable_css_acqpju2fqczr7ovwy4ka',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 },  ], css_id: 'tinytable_css_o8al4fkvmnnok9p6t4tg',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_6vdyszertrlmpt9ri5wt',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_224fryo6ku3y8eh2agwg(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_zidild08sqvmm68bds0m, .table th.tinytable_css_zidild08sqvmm68bds0m { border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_jfl1quewglwguxgizfwt, .table th.tinytable_css_jfl1quewglwguxgizfwt { border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_acqpju2fqczr7ovwy4ka, .table th.tinytable_css_acqpju2fqczr7ovwy4ka { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_o8al4fkvmnnok9p6t4tg, .table th.tinytable_css_o8al4fkvmnnok9p6t4tg { text-align: left; }
      .table td.tinytable_css_6vdyszertrlmpt9ri5wt, .table th.tinytable_css_6vdyszertrlmpt9ri5wt { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_224fryo6ku3y8eh2agwg" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col" data-row="0" data-col="0">New constituency</th>
                <th scope="col" data-row="0" data-col="1">New constituency code</th>
                <th scope="col" data-row="0" data-col="2">Index of change</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td data-row="1" data-col="0">Glasgow Central</td>
                  <td data-row="1" data-col="1">47</td>
                  <td data-row="1" data-col="2">58.74355</td>
                </tr>
                <tr>
                  <td data-row="2" data-col="0">Edinburgh Eastern, Musselburgh and Tranent</td>
                  <td data-row="2" data-col="1">33</td>
                  <td data-row="2" data-col="2">55.74137</td>
                </tr>
                <tr>
                  <td data-row="3" data-col="0">Edinburgh Southern</td>
                  <td data-row="3" data-col="1">38</td>
                  <td data-row="3" data-col="2">50.05765</td>
                </tr>
                <tr>
                  <td data-row="4" data-col="0">Edinburgh Northern</td>
                  <td data-row="4" data-col="1">36</td>
                  <td data-row="4" data-col="2">46.75669</td>
                </tr>
                <tr>
                  <td data-row="5" data-col="0">Glasgow Kelvin and Maryhill</td>
                  <td data-row="5" data-col="1">49</td>
                  <td data-row="5" data-col="2">44.89727</td>
                </tr>
                <tr>
                  <td data-row="6" data-col="0">Glasgow Cathcart and Pollok</td>
                  <td data-row="6" data-col="1">46</td>
                  <td data-row="6" data-col="2">41.12151</td>
                </tr>
                <tr>
                  <td data-row="7" data-col="0">Glasgow Easterhouse and Springburn</td>
                  <td data-row="7" data-col="1">48</td>
                  <td data-row="7" data-col="2">40.07663</td>
                </tr>
                <tr>
                  <td data-row="8" data-col="0">Edinburgh North Eastern and Leith</td>
                  <td data-row="8" data-col="1">34</td>
                  <td data-row="8" data-col="2">35.39741</td>
                </tr>
                <tr>
                  <td data-row="9" data-col="0">Glasgow Baillieston and Shettleston</td>
                  <td data-row="9" data-col="1">45</td>
                  <td data-row="9" data-col="2">35.34289</td>
                </tr>
                <tr>
                  <td data-row="10" data-col="0">Renfrewshire North and Cardonald</td>
                  <td data-row="10" data-col="1">66</td>
                  <td data-row="10" data-col="2">35.25863</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
<p>We can calculate this for all new constituencies. Table&nbsp;2 shows the value of this index for the ten constituencies which have seen the greatest change by this metric. Although it is natural to focus on areas which have seen the most change, 46 constituencies have seen negligible change (index values less than one percent).</p>
<div style="page-break-after: always;"></div>
</section>
<section id="modelling" class="level1">
<h1>Modelling</h1>
<p>I estimate two models: one model of list vote, and one model of constituency vote.</p>
<p>In the model of list votes, the outcome variable is a categorical variable with eight possible values (in alphabetical order: Alba, Conservative, Did not vote, Green, Labour, Liberal Democrat, SNP, Other).</p>
<p>In the model of constituency vote, the outcome variable is the same, except that there are seven possible values because Alba did not stand constituency candidates.</p>
<p>I model these options because these were the only parties that won more than one percent of the vote, and because these are the only parties chosen by more than a dozen respondents in the Scottish Election Study.</p>
<p>I model these outcomes using different predictor variables. I include all of the demographic variables which feature in the post-stratification frame. These variables are modelled as fixed effects, except that age is modelled as though it were a continuous variable using a spline. I also include constituency random intercepts and constituency level predictors. The constituency level predictors for the model of list votes includes the shares of the voting age population who voted for the Conservative, Labour, Liberal Democrats and Greens. The constituency level predictors for the model of constituency vote also includes dummy variables which record whether a Green candidate or any other candidates stood for election in that constituency.</p>
<p>The statistical model I use is a multinomial logit model estimated using Bayesian methods using the <code>brms</code> package.</p>
<p>Although the primary purpose of the model is to generate predictions, it is helpful to understand the predictions implied by the model when we change respondent characteristics. For example: we might “give” a respondent a degree and ask how that changes the predicted probability of voting for the SNP.</p>
<div id="fig-mfx" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-mfx-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/sp2026_notionals/fig-mfx-1.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-mfx-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;3: Plot showing changes in the probability of voting for different parties with respondent’s list vote. Changes in probabilities need not sum to zero because abstention is omitted.
</figcaption>
</figure>
</div>
<p>Figure&nbsp;3 shows the changes in the predicted probabilities for discrete changes in respondent characteristics. People with degrees are much more likely to vote for the Greens. Ethnic minorities are less likely to vote for Labour or the Conservatives. Scottish identifiers are much more likely to vote for the SNP. Men are more likely to vote for the Conservatives, and less likely to vote for the SNP. Respondents who are religious are more likely to vote for the Conservatives, but renters are much less so.</p>
<section id="post-stratification-of-model-predictions" class="level2">
<h2 class="anchored" data-anchor-id="post-stratification-of-model-predictions">Post-stratification of model predictions</h2>
<p>With the two models estimated in the previous section, we can make predictions for each intersection. We can add these predictions up for each of the 115 intersections. We can adjust these predictions so that when we aggregate from intersections to <em>old</em> constituencies, the results match exactly. Then we reaggregate from intersections to <em>new</em> constituencies to get notional results.</p>
<p>I adjust these predictions in two ways. First, I add on shifts on the logit scale. This reduces, but does not eliminate the difference between predicted and actual results. I then re-weight by multiplying so that the predicted and actual results match almost exactly given rounding error.</p>
</section>
<section id="adjusting-the-results-for-reform" class="level2">
<h2 class="anchored" data-anchor-id="adjusting-the-results-for-reform">Adjusting the results for Reform</h2>
<p>The above procedure gives estimates for seven parties, but not Reform. In the 2021 election, Reform won a fifth of one percent in the list vote. In the 2026 election, Reform is likely to do much better. I therefore proportionally reallocate reform votes between new constituencies. For each intersection, I divide the “Other” vote between “Reform” and “all others” on the basis of the Reform share of the “Other” vote in the parent 2021 constituency. I subtract this from the “Other” tally. I then reaggregate to the 2026 constituency level. This assumes that the ratio between Reform and all other parties is preserved across all parts of “old” constituencies. Reform can be more popular in some parts of a constituency, but only if all other parties are also more popular. This implicit assumption is neither intuitive nor particularly plausible, but there is no better way of allocating Reform votes between constituencies.</p>
<div style="page-break-after: always;"></div>
</section>
</section>
<section id="results" class="level1">
<h1>Results</h1>
<p>The output of this procedure is a set of notional results for (i) the constituency vote and (ii) the list vote for the seven largest parties. Table&nbsp;3 shows the result for Renfrewshire North and Cardonald.</p>
<div class="cell">
<div id="tbl-renfrewn" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-renfrewn-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;3: Notional results for Renfrewshire North and Cardonald
</figcaption>
<div aria-describedby="tbl-renfrewn-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_k1gngy1ny75t4s9go546(i, j, css_id) {
          var table = document.getElementById("tinytable_k1gngy1ny75t4s9go546");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_k1gngy1ny75t4s9go546(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_k1gngy1ny75t4s9go546");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '2', j: 0 }, { i: '2', j: 1 }, { i: '2', j: 2 }, { i: '2', j: 3 }, { i: '2', j: 4 }, { i: '2', j: 5 }, { i: '2', j: 6 }, { i: '2', j: 7 }, { i: '2', j: 8 }, { i: '2', j: 9 },  ], css_id: 'tinytable_css_zprzf7bqw2xfkajuqz31',}, 
          { positions: [ { i: '0', j: 0 }, { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 }, { i: '0', j: 4 }, { i: '0', j: 5 }, { i: '0', j: 6 }, { i: '0', j: 7 }, { i: '0', j: 8 }, { i: '0', j: 9 },  ], css_id: 'tinytable_css_rzx283ay610cbysyza20',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_k1gngy1ny75t4s9go546(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_zprzf7bqw2xfkajuqz31, .table th.tinytable_css_zprzf7bqw2xfkajuqz31 { border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_rzx283ay610cbysyza20, .table th.tinytable_css_rzx283ay610cbysyza20 { border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_k1gngy1ny75t4s9go546" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col" data-row="0" data-col="0">Contest</th>
                <th scope="col" data-row="0" data-col="1">Alba</th>
                <th scope="col" data-row="0" data-col="2">Cons</th>
                <th scope="col" data-row="0" data-col="3">Greens</th>
                <th scope="col" data-row="0" data-col="4">Lab</th>
                <th scope="col" data-row="0" data-col="5">LDem</th>
                <th scope="col" data-row="0" data-col="6">Other</th>
                <th scope="col" data-row="0" data-col="7">Reform</th>
                <th scope="col" data-row="0" data-col="8">SNP</th>
                <th scope="col" data-row="0" data-col="9">DNV</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td data-row="1" data-col="0">List</td>
                  <td data-row="1" data-col="1">768</td>
                  <td data-row="1" data-col="2">8419</td>
                  <td data-row="1" data-col="3">2582</td>
                  <td data-row="1" data-col="4">9201</td>
                  <td data-row="1" data-col="5">858</td>
                  <td data-row="1" data-col="6">1273</td>
                  <td data-row="1" data-col="7">54</td>
                  <td data-row="1" data-col="8">17159</td>
                  <td data-row="1" data-col="9">26647</td>
                </tr>
                <tr>
                  <td data-row="2" data-col="0">Constituency</td>
                  <td data-row="2" data-col="1">NA</td>
                  <td data-row="2" data-col="2">7108</td>
                  <td data-row="2" data-col="3">630</td>
                  <td data-row="2" data-col="4">11230</td>
                  <td data-row="2" data-col="5">878</td>
                  <td data-row="2" data-col="6">456</td>
                  <td data-row="2" data-col="7">NA</td>
                  <td data-row="2" data-col="8">19794</td>
                  <td data-row="2" data-col="9">26860</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
<p>We see a slight discrepancy in the numbers who did not vote, implying that some individuals only cast a valid vote in the constituency contest. That’s possible, and the discrepancy is just within the range of invalid votes.</p>
<div class="cell">
<div id="tbl-overalls" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-overalls-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;4: Notional results for each party
</figcaption>
<div aria-describedby="tbl-overalls-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_ebpoeepktvjb5tppc9cg(i, j, css_id) {
          var table = document.getElementById("tinytable_ebpoeepktvjb5tppc9cg");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_ebpoeepktvjb5tppc9cg(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_ebpoeepktvjb5tppc9cg");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '8', j: 0 }, { i: '8', j: 1 }, { i: '8', j: 2 }, { i: '8', j: 3 }, { i: '8', j: 4 }, { i: '8', j: 5 }, { i: '8', j: 6 },  ], css_id: 'tinytable_css_wl4gr37i4cch5oksu2bp',}, 
          { positions: [ { i: '0', j: 0 }, { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 }, { i: '0', j: 4 }, { i: '0', j: 5 }, { i: '0', j: 6 },  ], css_id: 'tinytable_css_4eohpc1p2dx7dbxm2ofd',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_ebpoeepktvjb5tppc9cg(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_wl4gr37i4cch5oksu2bp, .table th.tinytable_css_wl4gr37i4cch5oksu2bp { border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_4eohpc1p2dx7dbxm2ofd, .table th.tinytable_css_4eohpc1p2dx7dbxm2ofd { border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_ebpoeepktvjb5tppc9cg" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col" data-row="0" data-col="0">Party</th>
                <th scope="col" data-row="0" data-col="1">Constituency</th>
                <th scope="col" data-row="0" data-col="2">(chg.)</th>
                <th scope="col" data-row="0" data-col="3">Regional</th>
                <th scope="col" data-row="0" data-col="4">(chg.) </th>
                <th scope="col" data-row="0" data-col="5">Total</th>
                <th scope="col" data-row="0" data-col="6">(chg.)  </th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td data-row="1" data-col="0">SNP</td>
                  <td data-row="1" data-col="1">63</td>
                  <td data-row="1" data-col="2">(+1)</td>
                  <td data-row="1" data-col="3">1</td>
                  <td data-row="1" data-col="4">(-1)</td>
                  <td data-row="1" data-col="5">64</td>
                  <td data-row="1" data-col="6">(+0)</td>
                </tr>
                <tr>
                  <td data-row="2" data-col="0">Cons</td>
                  <td data-row="2" data-col="1">5</td>
                  <td data-row="2" data-col="2">(+0)</td>
                  <td data-row="2" data-col="3">26</td>
                  <td data-row="2" data-col="4">(+0)</td>
                  <td data-row="2" data-col="5">31</td>
                  <td data-row="2" data-col="6">(+0)</td>
                </tr>
                <tr>
                  <td data-row="3" data-col="0">Lab</td>
                  <td data-row="3" data-col="1">1</td>
                  <td data-row="3" data-col="2">(-1)</td>
                  <td data-row="3" data-col="3">20</td>
                  <td data-row="3" data-col="4">(+0)</td>
                  <td data-row="3" data-col="5">21</td>
                  <td data-row="3" data-col="6">(-1)</td>
                </tr>
                <tr>
                  <td data-row="4" data-col="0">Greens</td>
                  <td data-row="4" data-col="1">0</td>
                  <td data-row="4" data-col="2">(+0)</td>
                  <td data-row="4" data-col="3">9</td>
                  <td data-row="4" data-col="4">(+1)</td>
                  <td data-row="4" data-col="5">9</td>
                  <td data-row="4" data-col="6">(+1)</td>
                </tr>
                <tr>
                  <td data-row="5" data-col="0">LDem</td>
                  <td data-row="5" data-col="1">4</td>
                  <td data-row="5" data-col="2">(+0)</td>
                  <td data-row="5" data-col="3">0</td>
                  <td data-row="5" data-col="4">(+0)</td>
                  <td data-row="5" data-col="5">4</td>
                  <td data-row="5" data-col="6">(+0)</td>
                </tr>
                <tr>
                  <td data-row="6" data-col="0">Alba</td>
                  <td data-row="6" data-col="1">0</td>
                  <td data-row="6" data-col="2">(+0)</td>
                  <td data-row="6" data-col="3">0</td>
                  <td data-row="6" data-col="4">(+0)</td>
                  <td data-row="6" data-col="5">0</td>
                  <td data-row="6" data-col="6">(+0)</td>
                </tr>
                <tr>
                  <td data-row="7" data-col="0">Other</td>
                  <td data-row="7" data-col="1">0</td>
                  <td data-row="7" data-col="2">(+0)</td>
                  <td data-row="7" data-col="3">0</td>
                  <td data-row="7" data-col="4">(+0)</td>
                  <td data-row="7" data-col="5">0</td>
                  <td data-row="7" data-col="6">(+0)</td>
                </tr>
                <tr>
                  <td data-row="8" data-col="0">Reform</td>
                  <td data-row="8" data-col="1">0</td>
                  <td data-row="8" data-col="2">(+0)</td>
                  <td data-row="8" data-col="3">0</td>
                  <td data-row="8" data-col="4">(+0)</td>
                  <td data-row="8" data-col="5">0</td>
                  <td data-row="8" data-col="6">(+0)</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
<p>The main point of comparison, however, must be the overall seat tallies (i) on the actual results, and (ii) with these notional results. These are shown in Table&nbsp;4. Labour “lose” one seat, failing to win the redrawn Edinburgh Southern. The Greens win a list seat in the South of Scotland. Further detail is given in Table&nbsp;5, which breaks down seat allocations by region.</p>
<div class="cell">
<div id="tbl-regionals" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-regionals-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;5: Notional seat entitlements for each party by region. Figure before the plus mark gives constituency seats won; figure after the plus mark gives list seats won.
</figcaption>
<div aria-describedby="tbl-regionals-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_v059rbx78w9f9lv5avp4(i, j, css_id) {
          var table = document.getElementById("tinytable_v059rbx78w9f9lv5avp4");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_v059rbx78w9f9lv5avp4(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_v059rbx78w9f9lv5avp4");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '8', j: 0 }, { i: '8', j: 1 }, { i: '8', j: 2 }, { i: '8', j: 3 }, { i: '8', j: 4 }, { i: '8', j: 5 },  ], css_id: 'tinytable_css_ydvtm3ldlj1n0h4hcttg',}, 
          { positions: [ { i: '0', j: 0 }, { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 }, { i: '0', j: 4 }, { i: '0', j: 5 },  ], css_id: 'tinytable_css_ocan7gg6q41q1qm4iod7',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_v059rbx78w9f9lv5avp4(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_ydvtm3ldlj1n0h4hcttg, .table th.tinytable_css_ydvtm3ldlj1n0h4hcttg { border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_ocan7gg6q41q1qm4iod7, .table th.tinytable_css_ocan7gg6q41q1qm4iod7 { border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_v059rbx78w9f9lv5avp4" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col" data-row="0" data-col="0">Region</th>
                <th scope="col" data-row="0" data-col="1">Cons</th>
                <th scope="col" data-row="0" data-col="2">Greens</th>
                <th scope="col" data-row="0" data-col="3">LDem</th>
                <th scope="col" data-row="0" data-col="4">Lab</th>
                <th scope="col" data-row="0" data-col="5">SNP</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td data-row="1" data-col="0">Central and Lothians West</td>
                  <td data-row="1" data-col="1">0 + 3</td>
                  <td data-row="1" data-col="2">0 + 1</td>
                  <td data-row="1" data-col="3">0 + 0</td>
                  <td data-row="1" data-col="4">0 + 3</td>
                  <td data-row="1" data-col="5">9 + 0</td>
                </tr>
                <tr>
                  <td data-row="2" data-col="0">Edinburgh and Lothians East</td>
                  <td data-row="2" data-col="1">0 + 3</td>
                  <td data-row="2" data-col="2">0 + 2</td>
                  <td data-row="2" data-col="3">1 + 0</td>
                  <td data-row="2" data-col="4">0 + 2</td>
                  <td data-row="2" data-col="5">8 + 0</td>
                </tr>
                <tr>
                  <td data-row="3" data-col="0">Glasgow</td>
                  <td data-row="3" data-col="1">0 + 2</td>
                  <td data-row="3" data-col="2">0 + 1</td>
                  <td data-row="3" data-col="3">0 + 0</td>
                  <td data-row="3" data-col="4">0 + 4</td>
                  <td data-row="3" data-col="5">8 + 0</td>
                </tr>
                <tr>
                  <td data-row="4" data-col="0">Highlands and Islands</td>
                  <td data-row="4" data-col="1">0 + 4</td>
                  <td data-row="4" data-col="2">0 + 1</td>
                  <td data-row="4" data-col="3">2 + 0</td>
                  <td data-row="4" data-col="4">0 + 1</td>
                  <td data-row="4" data-col="5">6 + 1</td>
                </tr>
                <tr>
                  <td data-row="5" data-col="0">Mid Scotland and Fife</td>
                  <td data-row="5" data-col="1">0 + 4</td>
                  <td data-row="5" data-col="2">0 + 1</td>
                  <td data-row="5" data-col="3">1 + 0</td>
                  <td data-row="5" data-col="4">0 + 2</td>
                  <td data-row="5" data-col="5">8 + 0</td>
                </tr>
                <tr>
                  <td data-row="6" data-col="0">North East Scotland</td>
                  <td data-row="6" data-col="1">1 + 4</td>
                  <td data-row="6" data-col="2">0 + 1</td>
                  <td data-row="6" data-col="3">0 + 0</td>
                  <td data-row="6" data-col="4">0 + 2</td>
                  <td data-row="6" data-col="5">9 + 0</td>
                </tr>
                <tr>
                  <td data-row="7" data-col="0">South Scotland</td>
                  <td data-row="7" data-col="1">3 + 3</td>
                  <td data-row="7" data-col="2">0 + 1</td>
                  <td data-row="7" data-col="3">0 + 0</td>
                  <td data-row="7" data-col="4">0 + 3</td>
                  <td data-row="7" data-col="5">7 + 0</td>
                </tr>
                <tr>
                  <td data-row="8" data-col="0">West Scotland</td>
                  <td data-row="8" data-col="1">1 + 3</td>
                  <td data-row="8" data-col="2">0 + 1</td>
                  <td data-row="8" data-col="3">0 + 0</td>
                  <td data-row="8" data-col="4">1 + 3</td>
                  <td data-row="8" data-col="5">8 + 0</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
<div style="page-break-after: always;"></div>
</section>
<section id="comparison-with-alternative-estimates" class="level1">
<h1>Comparison with alternative estimates</h1>
<p>I have based these notional estimates on a model of voter behaviour estimated on individual responses to a survey taken shortly after the 2021 Scottish Parliament election. This is not the only way to create notional constituency results, and indeed it has not been the dominant way. Most notional results have been put together using information from local elections, since results from local elections are compiled at a more granular level than are results at parliament level.</p>
<p>For the new Scottish Parliament boundaries, Ballot Box Scotland has produced <a href="https://ballotbox.scot/scottish-parliament/sp-21-new-boundaries-notionals/">notional results</a> which are based on polling district level results collected directly from local councils.</p>
<p>Creating notional results based on local election results makes a great deal of sense. Local elections often show similar patterns of party support to national elections. Working with local election data also has the advantage that analysts are working with counts of actual behaviour rather than counts of reported behaviour. In the specific case of local election results collated at the polling district, this data is very granular.</p>
<p>Having said that, I think there are several reasons why working from individual level data is preferable.</p>
<p>First, local elections are held under a different electoral system. It seems plausible that the distribution of party support might be similar when comparing the distribution of first preferences under the single transferable vote and list votes. However, this is a big and unverifiable assumption. It’s also much less plausible that the distribution of party support is similar when comparing the distribution of first preferences under the single transferable vote and <em>constituency votes</em>.</p>
<p>Second, many local elections didn’t feature Alba, which means that they’re uninformative about the distribution of Alba support. Modelling Alba support correctly isn’t consequential for Alba’s seat tally, which remains at zero under any plausible redistricting, but is important insofar as Alba may draw votes away from other parties.</p>
<p>Third, local elections do feature relevant independent candidates, which can’t be said of the Scottish Parliament elections. What is worse, these independent candidates do not draw evenly from other parties, but are disproportionately likely to appear and win votes in areas which are more Conservative, as judged by the results of Scottish Parliament elections. This means that in some cases areas will appear as though they were void of Conservative support, when actually that support is masked by strong support for independents.</p>
<p>Fourth, local elections were held a year after the Scottish Parliament election. Whilst geographic patterns of party support are unlikely to have changed within the course of a year, it seems preferable to use 2021 data to work out what would have happened if the 2021 election had been held on 2026 boundaries.</p>
<p>These are reasons why <em>in principle</em> we should prefer notional results based on contemporaneous individual data from the election rather than notional results based on data from separate elections held a year later under a different electoral system. <em>In practice</em>, sets of notional results are extremely similar.</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-bbscomp" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-bbscomp-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/sp2026_notionals/index_files/figure-html/fig-bbscomp-1.png" class="img-fluid figure-img" width="864">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-bbscomp-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;4: Comparison of notional results between this report (horizontal axis) and Ballot Box Scotland (vertical axis). Values plotted are counts of votes cast; solid lines give the best fitting linear regression line.
</figcaption>
</figure>
</div>
</div>
</div>
<p>Figure&nbsp;4 plots counts from this report against notional counts from Ballot Box Scotland for the five largest parties. The dashed line shows the results of the best fitting linear regression line, the equation for which is reported at the top of each panel. There is, to two significant figures, a one to one correspondence between the two sets of notionals. The high association is artificial in the sense that the association is based on all constituencies, including constituencies with minimal change. However, when we remove these constituencies the correlation across parties’ list votes ranges between 0.939 (Greens) and 0.971 (Conservatives), and the mean absolute difference in list votes ranges between 261 votes (Liberal Democrats) and 542 (Conservatives).</p>
<p>High associations can be consistent with differences in seat tallies if a small number of seats are decided by a handful of votes, but there is only one constituency where the two sets of notional results disagree regarding the constituency winner. On the basis of my notional results, the SNP would have won Edinburgh Southern rather than Labour. This is because, as shown in Figure&nbsp;2 and Table&nbsp;1, the new Edinburgh Southern seat draws upon Edinburgh Eastern. In Edinburgh Eastern a majority of voters (52%) cast their constituency vote for the SNP’s candidate, Ash Regan. Whilst both these notional estimates and the nationals from Ballot Box Scotland show that the notional constituency race in Edinburgh Southern would have been closer as a result of the influx of voters from Edinburgh Eastern, in my model this influx is sufficient to tip the seat.</p>
<!-- what about the disparity in Glasgow? BBS has them picking up an
extra seat -->
<p>Although the constituency winners are almost everywhere the same, there is one further difference in the list seats. Ballot Box Scotland have the Greens winning two list seats in Glasgow, whereas I have them at just one list seat. This is not driven by differences in the estimates of the Green vote: my estimates have the Greens winning 94 more votes than in the Ballot Box Scotland estimates. Rather, the difference in seats is caused by the votes won by Labour. In my notional results, Labour wins more votes, and crucially wins enough votes that its vote share is <em>twice</em> that of the Conservatives or the Greens. This means that when seats are allocated proportionally, Labour gets two bites at the cake for every one bite taken by either the Conservatives or Labour. Although systems of proportional representation <em>reduce</em> the incidence of sharp discontinuities, they do not remove them – and if Labour, across all of Glasgow, had won 368 fewer votes the Greens would have won an extra seat.</p>
</section>
<section id="conclusions" class="level1 unnumbered">
<h1 class="unnumbered">Conclusions</h1>
<p>The full set of notional results is set out in two accompanying CSV files, which contain the full counts for constituencies as recorded by their name and number in the original Boundary Commission shapefiles.</p>
<p>The constituency results are <a href="https://github.com/chrishanretty/sp2026_notionals/blob/main/outputs/consty_notionals.csv">here</a></p>
<p>The list results are <a href="https://github.com/chrishanretty/sp2026_notionals/blob/main/outputs/list_notionals.csv">here</a></p>
<p>The code used to generate these estimates will be made publicly available on <a href="https://github.com/chrishanretty/sp2026_notionals/">Github</a>.</p>


</section>

 ]]></description>
  <category>R</category>
  <category>Scotland</category>
  <category>elections</category>
  <guid>http://www.chrishanretty.co.uk/posts/sp2026_notionals/</guid>
  <pubDate>Thu, 09 Oct 2025 23:00:00 GMT</pubDate>
</item>
<item>
  <title>Mother of god, that’s a lot of parties</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/madre_de_dios/</link>
  <description><![CDATA[ 





<p>Political scientists are used to the idea that the number of legislators elected in a district shapes voting behaviour.</p>
<p>If there are only <img src="https://latex.codecogs.com/png.latex?m"> seats available, then voters have reason to switch towards the top <img src="https://latex.codecogs.com/png.latex?m"> + 1 parties rather than vote for a party which is unlikely to win.</p>
<p>This is a good first order heuristic, but it’s not a complete account of voter responses to institutional features. A district with a low magnitude works very differently in a system with many much larger districts compared to a system with other similarly small districts.</p>
<p>The best example I’ve seen of this comes from the Department of Madre de Dios in Peru. Madre de Dios is the smallest department in Peru by population, but one of the largest by area. If you follow the river after which the department is named, you eventually run into the Amazon and from there out into the Atlantic after a short 6,000 kilometres.</p>
<p>Because Madre de Dios is so small, it only elects one member of the Congress. That might lead us to expect that only a small number of parties would be competitive in Madre de Dios. That expectation turns out to be flat wrong. In 2006, fourteen parties ran for the single seat in Madre de Dios, and the largest party (Restauracion Nacional) won just over 20% of the vote. The <a href="https://en.wikipedia.org/wiki/Effective_number_of_parties">effective number</a> of vote-winning parties is 6.86, only slightly smaller than the effective number for Peru as a whole in that year (7.2).</p>
<p>I was so shocked by this figure that I first assumed that there was an error in <a href="https://electiondataarchive.org/">the data source I was using</a>, and so I confirmed it with <a href="https://portal.jne.gob.pe/portal_documentos/files/informacionelectoral/estadisticaelectoral/1_1.pdf">official results</a>. The result must have been shocking to some in Madre de Dios, because the effective number of parties fell substantially in the following (2011) election, to just 3.44.</p>
<p>This is an extreme example, but it shows that we can’t work out what happens at district level just with reference to local features. As they don’t say: “all politics is national”.</p>



 ]]></description>
  <category>elections</category>
  <guid>http://www.chrishanretty.co.uk/posts/madre_de_dios/</guid>
  <pubDate>Tue, 23 Sep 2025 23:00:00 GMT</pubDate>
</item>
<item>
  <title>Efficiently calculating the distance to the nearest party</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/dist2nearest/</link>
  <description><![CDATA[ 





<p>Recently I had to simulate the expected absolute distance between citizens and their nearest political party, under the assumptions that both citizen and party positions are drawn from a standard normal distribution.</p>
<p>I have to simulate this quantity because there’s no closed form solution outside of the single party case.</p>
<section id="initial-code" class="level1">
<h1>Initial code</h1>
<p>Here’s some set up that’s common to all simulations. I set a seed, draw 10,000 voters, and say that I want one hundred simulations for each batch, or each size of party system. One hundred simulations is not a lot, but it helps illustrate the point without making this document too slow to render.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tictoc)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">236435</span>)</span>
<span id="cb1-3">n_voters <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e4</span></span>
<span id="cb1-4">voters <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(n_voters)</span>
<span id="cb1-5">n_sims <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span></span></code></pre></div></div>
</div>
<p>Here’s my first implementation.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tic</span>()</span>
<span id="cb2-2">out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(n_parties) {</span>
<span id="cb2-3">    res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>n_sims, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i) {</span>
<span id="cb2-4">        parties <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(n_parties, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb2-5">        d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">outer</span>(voters, parties, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>)</span>
<span id="cb2-6">        d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(d)</span>
<span id="cb2-7">        min_d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">apply</span>(d, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, min)</span>
<span id="cb2-8">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(min_d))</span>
<span id="cb2-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Create all the distances</span></span>
<span id="cb2-10">    })</span>
<span id="cb2-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(res)</span>
<span id="cb2-12">})</span>
<span id="cb2-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toc</span>()</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>8.293 sec elapsed</code></pre>
</div>
</div>
<p>In this code, the outer loop works over the number of parties in the system. The inner loop works over the simulations. Within each iteration in the inner loop, I simulate positions for <code>n_parties</code> parties. I then calculate all the pairwise distances between the vector of parties and the vector of voters using the <code>outer</code> function. I convert these differences into distances by using the absolute value function. This gives me a matrix with <code>n_voters</code> rows and <code>n_parties</code> columns. In order to get the “nearest” party, I apply the <code>min</code> function over the rows of this matrix.</p>
<p>As you can see from the calls to <code>tic()</code> and <code>toc()</code>, I’ve timed the execution time using the <code>tictoc</code> library. I remember being disappointed by how slow this was. What if I wanted 1,000 simulations for each size of party system? Sure, I could parallelize this, but since it involves tailoring code to different machines with different numbers of cores, parallelization is almost always my last resort.</p>
</section>
<section id="profiling" class="level1">
<h1>Profiling</h1>
<p>In an effort to improve the code, I used the built-in R profiler. Here’s the code and the output I got.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Rprof</span>()</span>
<span id="cb4-2">out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(n_parties) {</span>
<span id="cb4-3">    res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>n_sims, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i) {</span>
<span id="cb4-4">        parties <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(n_parties, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb4-5">        d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">outer</span>(voters, parties, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>)</span>
<span id="cb4-6">        d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(d)</span>
<span id="cb4-7">        min_d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">apply</span>(d, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, min)</span>
<span id="cb4-8">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(min_d))</span>
<span id="cb4-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Create all the distances</span></span>
<span id="cb4-10">    })</span>
<span id="cb4-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(res)</span>
<span id="cb4-12">})</span>
<span id="cb4-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Rprof</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span>
<span id="cb4-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summaryRprof</span>()<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>by.self</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>                self.time self.pct total.time total.pct
"apply"              7.68    72.05      10.52     98.69
"FUN"                2.12    19.89      10.66    100.00
"unlist"             0.36     3.38       0.36      3.38
"lengths"            0.22     2.06       0.22      2.06
"aperm.default"      0.12     1.13       0.12      1.13
"outer"              0.08     0.75       0.10      0.94
"aperm"              0.02     0.19       0.14      1.31
"abs"                0.02     0.19       0.02      0.19
"mean.default"       0.02     0.19       0.02      0.19
"rep.int"            0.02     0.19       0.02      0.19</code></pre>
</div>
</div>
<p>Let’s focus on the first two lines of the output. The second line talks about <code>FUN</code>, which is R’s way of talking about an anonymous function. It would be better if I had written out my functions in separate function declarations like a proper programmer. I’m sure there must be an R style guide out there which deprecates anonymous functions longer than two lines.</p>
<p>It’s the first line, however, which is key. Calls to <code>apply</code> are taking up the lion’s share of the compute time. It turns out that using the general function <code>apply</code> is overkill, and that more specialized functions can get row minima more quickly. Here’s a rewrite which replaces <code>min_d &lt;- apply(d, 1, min)</code> with <code>min_d &lt;- rowMins(d)</code>, where <code>rowMins()</code> comes from the <code>matrixStats</code> package.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(matrixStats)</span>
<span id="cb6-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tic</span>()</span>
<span id="cb6-3">out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(n_parties) {</span>
<span id="cb6-4">    res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>n_sims, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i) {</span>
<span id="cb6-5">        parties <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(n_parties, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb6-6">        d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">outer</span>(voters, parties, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>)</span>
<span id="cb6-7">        d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(d)</span>
<span id="cb6-8">        min_d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rowMins</span>(d)</span>
<span id="cb6-9">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(min_d))</span>
<span id="cb6-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Create all the distances</span></span>
<span id="cb6-11">    })</span>
<span id="cb6-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(res)</span>
<span id="cb6-13">})</span>
<span id="cb6-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toc</span>()</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>0.316 sec elapsed</code></pre>
</div>
</div>
<p>As you can see, there’s a substantial improvement. Using <code>rowMins</code> is faster by a factor of twenty-five. If we look at the result of <code>summaryRprof()</code> below, we can see that the <code>rowMins</code> and <code>outer</code> function are the two big functions that are taking up most of the time.</p>
<div class="cell">
<div class="cell-output cell-output-stdout">
<pre><code>               self.time self.pct total.time total.pct
"rowMins"           0.18    60.00       0.18     60.00
"mean.default"      0.06    20.00       0.06     20.00
"outer"             0.04    13.33       0.04     13.33
"abs"               0.02     6.67       0.02      6.67</code></pre>
</div>
</div>
</section>
<section id="make-it-go-faster" class="level1">
<h1>Make it go faster</h1>
<p>Is there any scope for speeding up further? Since we were able to speed things up by using a specialised function from a separate package, maybe we should use a specialized function from a specialised package, one which delights in making things go faster? Such a package is the <code>Rfast</code> package. I don’t know anything about the authors, but the package loads with such a ridiculous <code>l33t</code> startup message that it feels like they might have been interested in the demo coding scene in the 1990s.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(Rfast)</span></code></pre></div></div>
<div class="cell-output cell-output-stderr">
<pre><code>Loading required package: Rcpp</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>Loading required package: zigg</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>Loading required package: RcppParallel</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>
Attaching package: 'RcppParallel'</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>The following object is masked from 'package:Rcpp':

    LdFlags</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>
Rfast: 2.1.5.1</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code> ___ __ __ __ __    __ __ __ __ __ _             _               __ __ __ __ __     __ __ __ __ __ __   
|  __ __ __ __  |  |  __ __ __ __ _/            / \             |  __ __ __ __ /   /__ __ _   _ __ __\  
| |           | |  | |                         / _ \            | |                        / /          
| |           | |  | |                        / / \ \           | |                       / /          
| |           | |  | |                       / /   \ \          | |                      / /          
| |__ __ __ __| |  | |__ __ __ __           / /     \ \         | |__ __ __ __ _        / /__/\          
|    __ __ __ __|  |  __ __ __ __|         / /__ _ __\ \        |_ __ __ __ _   |      / ___  /           
|   \              | |                    / _ _ _ _ _ _ \                     | |      \/  / /       
| |\ \             | |                   / /           \ \                    | |         / /          
| | \ \            | |                  / /             \ \                   | |        / /          
| |  \ \           | |                 / /               \ \                  | |       / /          
| |   \ \__ __ _   | |                / /                 \ \     _ __ __ __ _| |      / /          
|_|    \__ __ __\  |_|               /_/                   \_\   /_ __ __ __ ___|      \/             team</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>
Attaching package: 'Rfast'</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>The following objects are masked from 'package:matrixStats':

    colMads, colMaxs, colMedians, colMins, colRanks, colVars, rowMads,
    rowMaxs, rowMedians, rowMins, rowRanks, rowVars</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>The following object is masked from 'package:tictoc':

    Stack</code></pre>
</div>
</div>
<p>Let’s try their implementation of <code>rowMins</code>.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tic</span>()</span>
<span id="cb20-2">out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(n_parties) {</span>
<span id="cb20-3">    res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>n_sims, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i) {</span>
<span id="cb20-4">        parties <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(n_parties, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb20-5">        d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">outer</span>(voters, parties, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>)</span>
<span id="cb20-6">        d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(d)</span>
<span id="cb20-7">        min_d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> Rfast<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rowMins</span>(d)</span>
<span id="cb20-8">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(min_d))</span>
<span id="cb20-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Create all the distances</span></span>
<span id="cb20-10">    })</span>
<span id="cb20-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(res)</span>
<span id="cb20-12">})</span>
<span id="cb20-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toc</span>()</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>0.22 sec elapsed</code></pre>
</div>
</div>
<p>Once again, we’ve shaved some time off. It may not appear like a lot of time, but this implementation is now 1.5 times quicker.</p>
</section>
<section id="what-doesnt-work-1" class="level1">
<h1>What doesn’t work (1)</h1>
<p>This reliance on sampling might seem strange. Why, if we are postulating that voter distributions follow a normal distribution, and if we are setting the number of voters to A Big Number, don’t we aim for an exact solution?</p>
<p>You can, if you like, write out a function that will take a vector of party positions, calculate midpoints between them, and integrate areas between these midpoints – but it’s incredibly slow. R likes matrix operations; it doesn’t like integration.</p>
</section>
<section id="what-doesnt-work-2" class="level1">
<h1>What doesn’t work (2)</h1>
<p>In this code, I’ve used two loops. R programmers are often told that loops should be avoided, if at all possible. One way of avoiding an outer loop is to endogenize the number of parties – to simply sample a number of parties per iteration. This involves a certain loss of control – we never get exactly 100 simulations per party system size – but does it help speed things up?</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb22" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tic</span>()</span>
<span id="cb22-2">sf <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>() { </span>
<span id="cb22-3">    n_parties <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sample.int</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb22-4">    parties <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(n_parties, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb22-5">    d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">outer</span>(voters, parties, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>)</span>
<span id="cb22-6">    d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(d)</span>
<span id="cb22-7">    min_d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> Rfast<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rowMins</span>(d)</span>
<span id="cb22-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(n_parties, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(min_d)))</span>
<span id="cb22-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Create all the distances</span></span>
<span id="cb22-10">}</span>
<span id="cb22-11">out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replicate</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> n_sims, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sf</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">simplify =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'array'</span>)</span>
<span id="cb22-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toc</span>()</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>0.261 sec elapsed</code></pre>
</div>
</div>
<p>This loss of control doesn’t give an increase in speed. It seems that the overhead of the outer loop – which only runs over six elements – simply isn’t significant.</p>
</section>
<section id="conclusions" class="level1">
<h1>Conclusions</h1>
<p>The meta level conclusion is that it’s always important to time things and check that your intuitions about what works or doesn’t work are correct.</p>
<p>The only-slightly-less-meta-level conclusion is that some “natural” R programming patterns aren’t always that quick. Although base R functions have been optimized a lot, they are generic tools, and some tools with a narrower remit can do the job quicker.</p>


</section>

 ]]></description>
  <category>code</category>
  <category>R</category>
  <category>coalitions</category>
  <guid>http://www.chrishanretty.co.uk/posts/dist2nearest/</guid>
  <pubDate>Fri, 20 Jun 2025 23:00:00 GMT</pubDate>
</item>
<item>
  <title>Fitting fixed exponent laws in political science</title>
  <dc:creator>CJH </dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/power_laws/</link>
  <description><![CDATA[ 





<p>Some relationships are linear. If I work eight hours and make eight widgets, then an extra hour’s work will probably give me one more widget.</p>
<p>We could pick apart this example. You might suggest that I’ll be tired at the end of a working day, and will be lucky to squeeze out that extra widget. You might be right. You might also challenge the fascination with widgets found in economics texts. Here too you would also be right. Permit me the example.</p>
<p>Other relationships are nonlinear. This includes lots of relationships involving growth. A particular technology might expand from 25,000 to 50,000 users in the course of a month, and then expand from 50,000 to 100,000 users in the course of the next month. “One extra month” yields a different number of additional users depending where we are on the growth curve.</p>
<p>In the social sciences, we tend to think of relationships as linear. This in part is because many of the tools we use to model relationships are linear, or linear in parameters. Most regression models are (generalized) <em>linear</em> models.</p>
<p>Even when we predict nonlinear relationships, we often transform them so that they become linear. In the subfield I know best, one “basic law” from the Seat Product Model is that the effective number of seat-winning parties is equal to the seat product <img src="https://latex.codecogs.com/png.latex?MS"> raised to the power of one-sixth:</p>
<p><span id="eq-nonlinear"><img src="https://latex.codecogs.com/png.latex?%0AN_S%20=%20(MS)%5E%7B%5Ctfrac%7B1%7D%7B6%7D%7D%0A%5Ctag%7B1%7D"></span></p>
<p>However, the regression model that is used to test this relationship is a linear model:</p>
<p><span id="eq-linearreg"><img src="https://latex.codecogs.com/png.latex?%0Alog(N_S)%20=%20a%20+%20k%20%5Ccdot%20%5Clog(MS)%0A%5Ctag%7B2%7D"></span></p>
<p>which takes advantage of the way logarithms turn multiplication into addition. If Equation&nbsp;1 is correct, then we would expect <img src="https://latex.codecogs.com/png.latex?a%20=%200,%20k%0A=%20%5Ctfrac%7B1%7D%7B6%7D">.</p>
<p>Social scientists are not alone in turning nonlinear relationships into linear relationships for the purposes of statistical testing. Allometry is a subfield of biology which deals with relationships between sizes (and sometimes rates) of animals. Lots of allometric relations follow Equation&nbsp;1, but are tested using Equation&nbsp;2. <span class="citation" data-cites="packard2014use">Packard (2014)</span> describes this as the “traditional method” of estimating such relationships.</p>
<section id="what-is-wrong-with-linearizing-relationships" class="level1">
<h1>What is wrong with linearizing relationships?</h1>
<p>Sweet summer children might believe that linearizing relationships cannot have any harmful consequences if it is so widely used. However, whenever we take logarithms we’re changing the type of mean we predict. In an ordinarily least squares regression, we’re predicting an average <em>arithmetic</em> mean. If we’re working on the log transformed scale, we’re still predicting an average arithmetic mean, but on the log scale. That means that when we reverse the log operation, the mean we get back will be smaller than the mean of the original, un-transformed data.</p>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(kableExtra)</span>
<span id="cb1-2">x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10000</span>)</span>
<span id="cb1-3">y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log10</span>(x)</span>
<span id="cb1-4">tab <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Original data</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> x,</span>
<span id="cb1-5">                  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Base 10 log transformed data</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> y,</span>
<span id="cb1-6">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">check.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb1-7">tab <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rbind</span>(tab, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colMeans</span>(tab))</span>
<span id="cb1-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rownames</span>(tab) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(tab)), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i) {</span>
<span id="cb1-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" "</span>, i), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb1-10">    })</span>
<span id="cb1-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rownames</span>(tab)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean"</span></span>
<span id="cb1-12">             </span>
<span id="cb1-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kbl</span>(tab)</span></code></pre></div></div>
</details>
<div id="tbl-smitheg" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-smitheg-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;1: Example of transformation bias taken from <span class="citation" data-cites="smith1993logarithmic">Smith (1993)</span>
</figcaption>
<div aria-describedby="tbl-smitheg-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<table class="cell caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;" data-quarto-table-cell-role="th"></th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Original data</th>
<th style="text-align: right;" data-quarto-table-cell-role="th">Base 10 log transformed data</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"></td>
<td style="text-align: right;">1.0</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: left;"></td>
<td style="text-align: right;">10.0</td>
<td style="text-align: right;">1</td>
</tr>
<tr class="odd">
<td style="text-align: left;"></td>
<td style="text-align: right;">100.0</td>
<td style="text-align: right;">2</td>
</tr>
<tr class="even">
<td style="text-align: left;"></td>
<td style="text-align: right;">1000.0</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Mean</td>
<td style="text-align: right;">10000.0</td>
<td style="text-align: right;">4</td>
</tr>
<tr class="even">
<td style="text-align: left;"></td>
<td style="text-align: right;">2222.2</td>
<td style="text-align: right;">2</td>
</tr>
</tbody>
</table>
</div>
</div>
</figure>
</div>
</div>
<p>Table&nbsp;1 an example from <span class="citation" data-cites="smith1993logarithmic">Smith (1993)</span>. We have a set of numbers which range from one to ten thousand. Their average is a little over two thousand. Because these numbers are all positive, and span a couple of orders of magnitude, we might think to log-transform them. Here I’ll use log to the base 10 to keep the numbers simple. We might then estimate an intercept-only regression on the log-transformed values to get a mean. The mean of the log-transformed values is just 2, and when we back-transform we get <img src="https://latex.codecogs.com/png.latex?(10%5E2%20=)%20100">, far less than the mean we “ought” to get.</p>
<p>The response to this “transformation bias” is very much to suggest that this theoretical problem is not a practical problem. <span class="citation" data-cites="xiao2011use">Xiao et al. (2011)</span> collect a large number of allometric datasets and fit models to them using the traditional method of log transformation and by using nonlinear least squares fits. The conclusion is that, for two thirds of data-sets, the fit between the model and data was better with a log-transformed model than with a nonlinear least squares model.</p>
</section>
<section id="additive-and-multiplicative-error" class="level1">
<h1>Additive and multiplicative error</h1>
<p>Not everyone is convinced that the old ways are best. <a href="https://www.natsci.colostate.edu/emeritus/gary-packard/">Gary Packard</a>, who as far as I can tell has been waging a one-man battle against logarithmic transformations for allometry, argues that <span class="citation" data-cites="xiao2011use">Xiao et al. (2011)</span> make nonlinear regression look bad, because they assume that nonlinear regression modelling uses <em>additive</em> error, and that when nonlinear regression uses multiplicative error it looks much better.</p>
<p>What do I mean by additive or multiplicative error? I can explain it best by starting with the log transformed equation</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Clog(y)%20=%20a%20+%20k%20%5Clog(x)%20+%20%5Cepsilon%0A"></p>
<p>where the error terms epsilon come from some normal distribution with a mean of zero and an estimated standard deviation <img src="https://latex.codecogs.com/png.latex?%5Csigma">.</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cepsilon%20%5Csim%20N(0,%20%5Csigma%5E2)%0A"></p>
<p>In this equation, the error term <img src="https://latex.codecogs.com/png.latex?%5Cepsilon"> is <em>additive on the log-transformed scale</em>. By additive, I just mean, “we add it on”, even though when we add on negative errors it is more natural to talk of subtraction.</p>
<p>However, when the error on log-transformed scale is additive, the error is <em>multiplicative on the original scale</em>. In order to show this, we exponentiate everything in the above equation to get</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ay%20=%20ax%20%5E%20k%20%5Cexp(%5Cepsilon)%0A"></p>
<p>Here, any positive or negative values of <img src="https://latex.codecogs.com/png.latex?%5Cepsilon"> are exponentiated, and <em>multiply</em> the term <img src="https://latex.codecogs.com/png.latex?ax%20%5E%20k">. Instead of adding or subtracting some error from our prediction, we scale it up or down by some factor.</p>
<p>Multiplicative error seems more appropriate when dealing with outcomes than span several orders of magnitude. Suppose we were dealing with deaths in wars. In some wars dozens of people die; in other wars millions of people die. Being able to predict war deaths “plus or minus a thousand” would be ridiculous in the case of a conflict which we predicted to involve a dozen deaths, and spuriously precise in cases where we predict millions of deaths.</p>
<p>Unfortunately, most nonlinear regression routines in statistical software don’t estimate multiplicative error. The variance structure recommended by Packard, and which <em>is</em> implemented in some R routines, is to set error proportional to the predicted value, raised to some power:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ay%20%5Csim%20N(a%20x%5Ek,%0A%20%20%5Csigma%5E2%20%5Ccdot%20(a%20x%20%5E%20k)%5E%7B2%5Cdelta%7D)%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?%5Cdelta"> is a parameter to be estimated, and where values greater than zero indicate that variance increases proportionate to the predicted value. A value of zero for <img src="https://latex.codecogs.com/png.latex?%5Cdelta"> implies constant additive variance on the original scale. Packard refers to this as additive heteroscedastic error, which is true in the sense that the error is added on, but confusing in the sense that the <img src="https://latex.codecogs.com/png.latex?%5Csigma"> term here is clearly multiplying <img src="https://latex.codecogs.com/png.latex?ax%5Ek">.</p>
</section>
<section id="worked-example-1" class="level1">
<h1>Worked example (1)</h1>
<p>Let’s see how this might work in practice. I’m going to work with data from electoral studies, and specifically the <a href="https://doi.org/10.7910/DVN/ME2W6U">National and District Level Party System Datasets</a> described in <span class="citation" data-cites="struthers2018introducing">Struthers et al. (2018)</span>. I’ll use this data to test some claims made by the Seat Product Model, as set out in <span class="citation" data-cites="shugart2017votes">Shugart and Taagepera (2017)</span>.</p>
<p>I begin by loading the libraries I need – <code>haven</code> for file import, <code>modelsummary</code> to show the results of my regressions, and <code>nlme</code> for the modelling.</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse)</span>
<span id="cb2-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(haven)</span>
<span id="cb2-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(nlme)</span>
<span id="cb2-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(modelsummary)</span>
<span id="cb2-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggthemes)</span></code></pre></div></div>
</details>
</div>
<p>I’ll then load in the data, and filter only to simple (i.e., single ballot, single tier, non-preferential) electoral systems where we know the seat product, or the average district magnitude times the assembly size.</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read_dta</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NLPS_v1_10-2018.dta"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(simple <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(compens <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(parallel <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(basictier1)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(tier1_avemag)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(Ns)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(Ns0)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seat_product =</span> basictier1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> tier1_avemag) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-10">    dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(Ns, Ns0, seat_product) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>()</span></code></pre></div></div>
</details>
</div>
<p>I’m going to begin with an example where three different methods reach the same conclusion. That is, I’m going to test the claim that the effective number of seat-winning parties is equal to the seat product, raised to the power of one sixth.</p>
<p>Let’s test the most basic claim, that the effective number of seat-winning parties is related to the seat product. We can (and should!) visualize these variables before we do anything else. Here I’ll use log-transformed axes, without by this implying any commitment to log transforming the variables in the regressions I’ll run shortly.</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(dat, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> seat_product,</span>
<span id="cb4-2">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> Ns)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_continuous</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Seat product"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Effective no. seat-winning parties"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_trans</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"log10"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"log10"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_solarized_2</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">light =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div id="fig-sp" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-sp-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/power_laws/index_files/figure-html/fig-sp-1.png" class="img-fluid figure-img" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-sp-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: Scatterplot
</figcaption>
</figure>
</div>
</div>
</div>
<p>The outlier to the right is Ukraine between 2006 and 2007, where the effective number of parties is low but where there were a tonne of independents.</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">m <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(Ns) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(seat_product), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat)</span>
<span id="cb5-2"></span>
<span id="cb5-3">my_cm <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(Intercept)"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Constant"</span>,</span>
<span id="cb5-4">           <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"log(seat_product)"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"log(Seat product)"</span>)</span>
<span id="cb5-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">modelsummary</span>(m,</span>
<span id="cb5-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">coef_map =</span> my_cm,</span>
<span id="cb5-7">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">statistic =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"conf.int"</span>,</span>
<span id="cb5-8">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">gof_map =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nobs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"r.squared"</span>))</span></code></pre></div></div>
</details>
<div id="tbl-loglin" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-loglin-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;2: Log log regression of the effective number of parties on the seat product.
</figcaption>
<div aria-describedby="tbl-loglin-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_5rsey4dllhrcr3dr0hwn(i, j, css_id) {
          var table = document.getElementById("tinytable_5rsey4dllhrcr3dr0hwn");
          var cell = table.rows[i]?.cells[j];  // Safe navigation to avoid errors
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function insertSpanRow(i, colspan, content) {
        var table = document.getElementById('tinytable_5rsey4dllhrcr3dr0hwn');
        var newRow = table.insertRow(i);
        var newCell = newRow.insertCell(0);
        newCell.setAttribute("colspan", colspan);
        // newCell.innerText = content;
        // this may be unsafe, but innerText does not interpret <br>
        newCell.innerHTML = content;
      }
      function spanCell_5rsey4dllhrcr3dr0hwn(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_5rsey4dllhrcr3dr0hwn");
        const targetRow = table.rows[i];
        const targetCell = targetRow.cells[j];
        for (let r = 0; r < rowspan; r++) {
          // Only start deleting cells to the right for the first row (r == 0)
          if (r === 0) {
            // Delete cells to the right of the target cell in the first row
            for (let c = colspan - 1; c > 0; c--) {
              if (table.rows[i + r].cells[j + c]) {
                table.rows[i + r].deleteCell(j + c);
              }
            }
          }
          // For rows below the first, delete starting from the target column
          if (r > 0) {
            for (let c = colspan - 1; c >= 0; c--) {
              if (table.rows[i + r] && table.rows[i + r].cells[j]) {
                table.rows[i + r].deleteCell(j);
              }
            }
          }
        }
        // Set rowspan and colspan of the target cell
        targetCell.rowSpan = rowspan;
        targetCell.colSpan = colspan;
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: 6, j: 1 },  ], css_id: 'tinytable_css_1mg5247u69ry2r6h0o00',}, 
          { positions: [ { i: 4, j: 1 },  ], css_id: 'tinytable_css_dkdzsl26fgizmmde1jfe',}, 
          { positions: [ { i: 1, j: 1 }, { i: 2, j: 1 }, { i: 3, j: 1 }, { i: 5, j: 1 },  ], css_id: 'tinytable_css_c4frb823u8xd2wg547d9',}, 
          { positions: [ { i: 0, j: 1 },  ], css_id: 'tinytable_css_2jxnl7rxdtk4xki8g1cm',}, 
          { positions: [ { i: 6, j: 0 },  ], css_id: 'tinytable_css_0hseu18m72f6zza1idlu',}, 
          { positions: [ { i: 4, j: 0 },  ], css_id: 'tinytable_css_ze8jcfrsvdfpk3l91tnq',}, 
          { positions: [ { i: 1, j: 0 }, { i: 2, j: 0 }, { i: 3, j: 0 }, { i: 5, j: 0 },  ], css_id: 'tinytable_css_hasj5dznn9fvqg4j2z4p',}, 
          { positions: [ { i: 0, j: 0 },  ], css_id: 'tinytable_css_6o1tppxjenu9c8wcdrcn',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_5rsey4dllhrcr3dr0hwn(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_1mg5247u69ry2r6h0o00, .table th.tinytable_css_1mg5247u69ry2r6h0o00 { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_dkdzsl26fgizmmde1jfe, .table th.tinytable_css_dkdzsl26fgizmmde1jfe { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_c4frb823u8xd2wg547d9, .table th.tinytable_css_c4frb823u8xd2wg547d9 { text-align: center; }
      .table td.tinytable_css_2jxnl7rxdtk4xki8g1cm, .table th.tinytable_css_2jxnl7rxdtk4xki8g1cm { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_0hseu18m72f6zza1idlu, .table th.tinytable_css_0hseu18m72f6zza1idlu { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_ze8jcfrsvdfpk3l91tnq, .table th.tinytable_css_ze8jcfrsvdfpk3l91tnq { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_hasj5dznn9fvqg4j2z4p, .table th.tinytable_css_hasj5dznn9fvqg4j2z4p { text-align: left; }
      .table td.tinytable_css_6o1tppxjenu9c8wcdrcn, .table th.tinytable_css_6o1tppxjenu9c8wcdrcn { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_5rsey4dllhrcr3dr0hwn" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col"> </th>
                <th scope="col">(1)</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td>Constant</td>
                  <td>-0.012</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[-0.112, 0.087]</td>
                </tr>
                <tr>
                  <td>log(Seat product)</td>
                  <td>0.165</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[0.150, 0.180]</td>
                </tr>
                <tr>
                  <td>Num.Obs.</td>
                  <td>403</td>
                </tr>
                <tr>
                  <td>R2</td>
                  <td>0.538</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
<p>We find that everything works – the confidence interval for our constant includes zero, and the confidence interval on the logged seat product includes one-sixth. We seem to be in the world described by <span class="citation" data-cites="xiao2011use">Xiao et al. (2011)</span>, where log transforming “just works”.</p>
<p>We can now try modelling things in <code>nls</code>, R’s default routine for nonlinear least squares. This uses additive error, and so wouldn’t be recommended by Packard. As with all invocations of <code>nls</code>, we have to provide some starting values for the parameters, but with a relatively simple model these are innocuous.</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">m2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nls</span>(Ns <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> seat_product <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> k,</span>
<span id="cb6-2">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat,</span>
<span id="cb6-3">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">start =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))</span>
<span id="cb6-4">m2b <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nls</span>(Ns <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> a <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> seat_product <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> k,</span>
<span id="cb6-5">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat,</span>
<span id="cb6-6">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">start =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">a =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))</span>
<span id="cb6-7"></span>
<span id="cb6-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">modelsummary</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(m2, m2b),</span>
<span id="cb6-9">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">statistic =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"conf.int"</span>,</span>
<span id="cb6-10">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">gof_map =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nobs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"r.squared"</span>))</span></code></pre></div></div>
</details>
<div id="tbl-nls1" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-nls1-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;3: Nonlinear least squares regression of the effective number of parties, additive error.
</figcaption>
<div aria-describedby="tbl-nls1-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_wbwiasgh7xelqiog8kb2(i, j, css_id) {
          var table = document.getElementById("tinytable_wbwiasgh7xelqiog8kb2");
          var cell = table.rows[i]?.cells[j];  // Safe navigation to avoid errors
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function insertSpanRow(i, colspan, content) {
        var table = document.getElementById('tinytable_wbwiasgh7xelqiog8kb2');
        var newRow = table.insertRow(i);
        var newCell = newRow.insertCell(0);
        newCell.setAttribute("colspan", colspan);
        // newCell.innerText = content;
        // this may be unsafe, but innerText does not interpret <br>
        newCell.innerHTML = content;
      }
      function spanCell_wbwiasgh7xelqiog8kb2(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_wbwiasgh7xelqiog8kb2");
        const targetRow = table.rows[i];
        const targetCell = targetRow.cells[j];
        for (let r = 0; r < rowspan; r++) {
          // Only start deleting cells to the right for the first row (r == 0)
          if (r === 0) {
            // Delete cells to the right of the target cell in the first row
            for (let c = colspan - 1; c > 0; c--) {
              if (table.rows[i + r].cells[j + c]) {
                table.rows[i + r].deleteCell(j + c);
              }
            }
          }
          // For rows below the first, delete starting from the target column
          if (r > 0) {
            for (let c = colspan - 1; c >= 0; c--) {
              if (table.rows[i + r] && table.rows[i + r].cells[j]) {
                table.rows[i + r].deleteCell(j);
              }
            }
          }
        }
        // Set rowspan and colspan of the target cell
        targetCell.rowSpan = rowspan;
        targetCell.colSpan = colspan;
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: 5, j: 1 }, { i: 5, j: 2 },  ], css_id: 'tinytable_css_78q6g8fmeb71g3iru8yj',}, 
          { positions: [ { i: 4, j: 1 }, { i: 4, j: 2 },  ], css_id: 'tinytable_css_o6d5z1za6j9am8ff39rt',}, 
          { positions: [ { i: 1, j: 1 }, { i: 3, j: 1 }, { i: 2, j: 2 }, { i: 3, j: 2 }, { i: 2, j: 1 }, { i: 1, j: 2 },  ], css_id: 'tinytable_css_iwshofnlcm1eoqm30ecm',}, 
          { positions: [ { i: 0, j: 1 }, { i: 0, j: 2 },  ], css_id: 'tinytable_css_9n59u0r3ydum8lvhtgkb',}, 
          { positions: [ { i: 5, j: 0 },  ], css_id: 'tinytable_css_hmtjx5o634ai8t33v24s',}, 
          { positions: [ { i: 4, j: 0 },  ], css_id: 'tinytable_css_fmjz0jhdmd3q67xj2zz7',}, 
          { positions: [ { i: 1, j: 0 }, { i: 2, j: 0 }, { i: 3, j: 0 },  ], css_id: 'tinytable_css_ti3y03y6y6fkip33idsm',}, 
          { positions: [ { i: 0, j: 0 },  ], css_id: 'tinytable_css_dfxylxxlec1m7m7ny5gt',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_wbwiasgh7xelqiog8kb2(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_78q6g8fmeb71g3iru8yj, .table th.tinytable_css_78q6g8fmeb71g3iru8yj { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_o6d5z1za6j9am8ff39rt, .table th.tinytable_css_o6d5z1za6j9am8ff39rt { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_iwshofnlcm1eoqm30ecm, .table th.tinytable_css_iwshofnlcm1eoqm30ecm { text-align: center; }
      .table td.tinytable_css_9n59u0r3ydum8lvhtgkb, .table th.tinytable_css_9n59u0r3ydum8lvhtgkb { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_hmtjx5o634ai8t33v24s, .table th.tinytable_css_hmtjx5o634ai8t33v24s { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_fmjz0jhdmd3q67xj2zz7, .table th.tinytable_css_fmjz0jhdmd3q67xj2zz7 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_ti3y03y6y6fkip33idsm, .table th.tinytable_css_ti3y03y6y6fkip33idsm { text-align: left; }
      .table td.tinytable_css_dfxylxxlec1m7m7ny5gt, .table th.tinytable_css_dfxylxxlec1m7m7ny5gt { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_wbwiasgh7xelqiog8kb2" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col"> </th>
                <th scope="col">(1)</th>
                <th scope="col">(2)</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td>k</td>
                  <td>0.170</td>
                  <td>0.158</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[0.165, 0.174]</td>
                  <td>[0.140, 0.177]</td>
                </tr>
                <tr>
                  <td>a</td>
                  <td></td>
                  <td>1.097</td>
                </tr>
                <tr>
                  <td></td>
                  <td></td>
                  <td>[0.937, 1.257]</td>
                </tr>
                <tr>
                  <td>Num.Obs.</td>
                  <td>403</td>
                  <td>403</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
<p>Despite the (probably incorrect) use of additive error , everything seems to work as it did before. In the first model, which uses just the exponent <img src="https://latex.codecogs.com/png.latex?k">, the confidence interval includes one-sixth, even though it’s somewhat on the high side. In the second model, which includes an additional term to match the two term log log models just discussed, the confidence interval on the extra term includes <img src="https://latex.codecogs.com/png.latex?%5Cexp(0)%0A=%201">, which is as it should be.</p>
<p>Finally, let’s try modelling it in <code>nlme</code>, with variance proportional to a power of the predicted value.</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">m3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gnls</span>(Ns <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> seat_product <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> k, </span>
<span id="cb7-2">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat,</span>
<span id="cb7-3">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">start =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb7-4">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weights =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">varPower</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">form =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fitted</span>(.)))</span>
<span id="cb7-5"></span>
<span id="cb7-6">m3b <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gnls</span>(Ns <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> a <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> seat_product <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> k, </span>
<span id="cb7-7">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat,</span>
<span id="cb7-8">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">start =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">a =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb7-9">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weights =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">varPower</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">form =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fitted</span>(.)))</span>
<span id="cb7-10"></span>
<span id="cb7-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">modelsummary</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(m3, m3b),</span>
<span id="cb7-12">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">statistic =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"conf.int"</span>,</span>
<span id="cb7-13">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">gof_map =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nobs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"r.squared"</span>))</span></code></pre></div></div>
</details>
<div id="tbl-nls2" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-nls2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;4: Nonlinear least squares regression of the effective number of parties, error proportional to predicted value.
</figcaption>
<div aria-describedby="tbl-nls2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_gi8izug5t84qv7j6x1by(i, j, css_id) {
          var table = document.getElementById("tinytable_gi8izug5t84qv7j6x1by");
          var cell = table.rows[i]?.cells[j];  // Safe navigation to avoid errors
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function insertSpanRow(i, colspan, content) {
        var table = document.getElementById('tinytable_gi8izug5t84qv7j6x1by');
        var newRow = table.insertRow(i);
        var newCell = newRow.insertCell(0);
        newCell.setAttribute("colspan", colspan);
        // newCell.innerText = content;
        // this may be unsafe, but innerText does not interpret <br>
        newCell.innerHTML = content;
      }
      function spanCell_gi8izug5t84qv7j6x1by(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_gi8izug5t84qv7j6x1by");
        const targetRow = table.rows[i];
        const targetCell = targetRow.cells[j];
        for (let r = 0; r < rowspan; r++) {
          // Only start deleting cells to the right for the first row (r == 0)
          if (r === 0) {
            // Delete cells to the right of the target cell in the first row
            for (let c = colspan - 1; c > 0; c--) {
              if (table.rows[i + r].cells[j + c]) {
                table.rows[i + r].deleteCell(j + c);
              }
            }
          }
          // For rows below the first, delete starting from the target column
          if (r > 0) {
            for (let c = colspan - 1; c >= 0; c--) {
              if (table.rows[i + r] && table.rows[i + r].cells[j]) {
                table.rows[i + r].deleteCell(j);
              }
            }
          }
        }
        // Set rowspan and colspan of the target cell
        targetCell.rowSpan = rowspan;
        targetCell.colSpan = colspan;
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: 6, j: 1 }, { i: 6, j: 2 },  ], css_id: 'tinytable_css_ke7797b7403d4fgq2vrx',}, 
          { positions: [ { i: 4, j: 2 }, { i: 4, j: 1 },  ], css_id: 'tinytable_css_ursca3fgig5zotjqmj32',}, 
          { positions: [ { i: 1, j: 1 }, { i: 2, j: 1 }, { i: 1, j: 2 }, { i: 5, j: 1 }, { i: 3, j: 2 }, { i: 3, j: 1 }, { i: 5, j: 2 }, { i: 2, j: 2 },  ], css_id: 'tinytable_css_9a46xi51ay4x6efhibkv',}, 
          { positions: [ { i: 0, j: 1 }, { i: 0, j: 2 },  ], css_id: 'tinytable_css_3zcg6la3ku48dwgrb91l',}, 
          { positions: [ { i: 6, j: 0 },  ], css_id: 'tinytable_css_hmilunbg4mmn4cp8enf7',}, 
          { positions: [ { i: 4, j: 0 },  ], css_id: 'tinytable_css_uhg5hh6ymm1qnh3yefz6',}, 
          { positions: [ { i: 1, j: 0 }, { i: 2, j: 0 }, { i: 3, j: 0 }, { i: 5, j: 0 },  ], css_id: 'tinytable_css_s3o8709jsdnx8uecdiv1',}, 
          { positions: [ { i: 0, j: 0 },  ], css_id: 'tinytable_css_hx50cmtxlzp1u6axfn2l',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_gi8izug5t84qv7j6x1by(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_ke7797b7403d4fgq2vrx, .table th.tinytable_css_ke7797b7403d4fgq2vrx { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_ursca3fgig5zotjqmj32, .table th.tinytable_css_ursca3fgig5zotjqmj32 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_9a46xi51ay4x6efhibkv, .table th.tinytable_css_9a46xi51ay4x6efhibkv { text-align: center; }
      .table td.tinytable_css_3zcg6la3ku48dwgrb91l, .table th.tinytable_css_3zcg6la3ku48dwgrb91l { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_hmilunbg4mmn4cp8enf7, .table th.tinytable_css_hmilunbg4mmn4cp8enf7 { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_uhg5hh6ymm1qnh3yefz6, .table th.tinytable_css_uhg5hh6ymm1qnh3yefz6 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_s3o8709jsdnx8uecdiv1, .table th.tinytable_css_s3o8709jsdnx8uecdiv1 { text-align: left; }
      .table td.tinytable_css_hx50cmtxlzp1u6axfn2l, .table th.tinytable_css_hx50cmtxlzp1u6axfn2l { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_gi8izug5t84qv7j6x1by" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col"> </th>
                <th scope="col">(1)</th>
                <th scope="col">(2)</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td>k</td>
                  <td>0.171</td>
                  <td>0.166</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[0.165, 0.176]</td>
                  <td>[0.149, 0.183]</td>
                </tr>
                <tr>
                  <td>a</td>
                  <td></td>
                  <td>1.033</td>
                </tr>
                <tr>
                  <td></td>
                  <td></td>
                  <td>[0.925, 1.141]</td>
                </tr>
                <tr>
                  <td>Num.Obs.</td>
                  <td>403</td>
                  <td>403</td>
                </tr>
                <tr>
                  <td>R2</td>
                  <td>0.429</td>
                  <td>0.431</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
<p>Now in the two parameter model the exponent <img src="https://latex.codecogs.com/png.latex?k"> is exactly what it was predicted to be, to three decimal places. What the <code>modelsummary</code> output doesn’t show is the parameter <img src="https://latex.codecogs.com/png.latex?%5Cdelta">, which is estimated to be somewhat greater than one, suggesting that error is slightly greater when we reach higher values of the seat product.</p>
</section>
<section id="worked-example-2" class="level1">
<h1>Worked example (2)</h1>
<p>So far, so boring – modelling the relationship in three different ways gives substantially the same results. That might be a signal that we’ve found a robust relationship, but equally it might be sign that we are spending time on modelling details that don’t matter. What about an example where the three methods give different results?</p>
<p>We can stick with the same data-set, and model not the effective number of seat-winning parties but rather the raw number. The claim made by <span class="citation" data-cites="shugart2017votes">Shugart and Taagepera (2017)</span> is that the raw number of seat-winning parties should be equal to the seat product to the power of one quarter. Taagepera and Shugart actually make their prediction about the effective number only after making a prediction for the raw number – so if these worked examples recapitulated the theoretical order of the claims, we should have started here with the raw number.</p>
<p>Let’s start with taking logs on both sides.</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1">m <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">update</span>(m, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(Ns0) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> .)</span>
<span id="cb8-2"></span>
<span id="cb8-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">modelsummary</span>(m,</span>
<span id="cb8-4">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">coef_map =</span> my_cm,</span>
<span id="cb8-5">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">statistic =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"conf.int"</span>,</span>
<span id="cb8-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">gof_map =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nobs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"r.squared"</span>))</span></code></pre></div></div>
</details>
<div id="tbl-loglin2" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-loglin2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;5: Log log regression of the effective number of parties on the seat product.
</figcaption>
<div aria-describedby="tbl-loglin2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_fzjbb3bk7uwienxcdcjw(i, j, css_id) {
          var table = document.getElementById("tinytable_fzjbb3bk7uwienxcdcjw");
          var cell = table.rows[i]?.cells[j];  // Safe navigation to avoid errors
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function insertSpanRow(i, colspan, content) {
        var table = document.getElementById('tinytable_fzjbb3bk7uwienxcdcjw');
        var newRow = table.insertRow(i);
        var newCell = newRow.insertCell(0);
        newCell.setAttribute("colspan", colspan);
        // newCell.innerText = content;
        // this may be unsafe, but innerText does not interpret <br>
        newCell.innerHTML = content;
      }
      function spanCell_fzjbb3bk7uwienxcdcjw(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_fzjbb3bk7uwienxcdcjw");
        const targetRow = table.rows[i];
        const targetCell = targetRow.cells[j];
        for (let r = 0; r < rowspan; r++) {
          // Only start deleting cells to the right for the first row (r == 0)
          if (r === 0) {
            // Delete cells to the right of the target cell in the first row
            for (let c = colspan - 1; c > 0; c--) {
              if (table.rows[i + r].cells[j + c]) {
                table.rows[i + r].deleteCell(j + c);
              }
            }
          }
          // For rows below the first, delete starting from the target column
          if (r > 0) {
            for (let c = colspan - 1; c >= 0; c--) {
              if (table.rows[i + r] && table.rows[i + r].cells[j]) {
                table.rows[i + r].deleteCell(j);
              }
            }
          }
        }
        // Set rowspan and colspan of the target cell
        targetCell.rowSpan = rowspan;
        targetCell.colSpan = colspan;
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: 6, j: 1 },  ], css_id: 'tinytable_css_chuz1hs4zuetfiodm3zy',}, 
          { positions: [ { i: 4, j: 1 },  ], css_id: 'tinytable_css_pl8j7vv9bqho5q2zs5az',}, 
          { positions: [ { i: 1, j: 1 }, { i: 2, j: 1 }, { i: 3, j: 1 }, { i: 5, j: 1 },  ], css_id: 'tinytable_css_6s1i4xm04z72qdeb9lo8',}, 
          { positions: [ { i: 0, j: 1 },  ], css_id: 'tinytable_css_wx22l9o0c13urp967l1l',}, 
          { positions: [ { i: 6, j: 0 },  ], css_id: 'tinytable_css_qrku4el0f2iqdvzbsuyo',}, 
          { positions: [ { i: 4, j: 0 },  ], css_id: 'tinytable_css_xrbxger6eboy47y8s0eu',}, 
          { positions: [ { i: 1, j: 0 }, { i: 2, j: 0 }, { i: 3, j: 0 }, { i: 5, j: 0 },  ], css_id: 'tinytable_css_zb8sm8h0gfjpkhd9prwb',}, 
          { positions: [ { i: 0, j: 0 },  ], css_id: 'tinytable_css_ybhp3xf5bp6oebu303th',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_fzjbb3bk7uwienxcdcjw(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_chuz1hs4zuetfiodm3zy, .table th.tinytable_css_chuz1hs4zuetfiodm3zy { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_pl8j7vv9bqho5q2zs5az, .table th.tinytable_css_pl8j7vv9bqho5q2zs5az { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_6s1i4xm04z72qdeb9lo8, .table th.tinytable_css_6s1i4xm04z72qdeb9lo8 { text-align: center; }
      .table td.tinytable_css_wx22l9o0c13urp967l1l, .table th.tinytable_css_wx22l9o0c13urp967l1l { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_qrku4el0f2iqdvzbsuyo, .table th.tinytable_css_qrku4el0f2iqdvzbsuyo { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_xrbxger6eboy47y8s0eu, .table th.tinytable_css_xrbxger6eboy47y8s0eu { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_zb8sm8h0gfjpkhd9prwb, .table th.tinytable_css_zb8sm8h0gfjpkhd9prwb { text-align: left; }
      .table td.tinytable_css_ybhp3xf5bp6oebu303th, .table th.tinytable_css_ybhp3xf5bp6oebu303th { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_fzjbb3bk7uwienxcdcjw" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col"> </th>
                <th scope="col">(1)</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td>Constant</td>
                  <td>0.114</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[-0.058, 0.286]</td>
                </tr>
                <tr>
                  <td>log(Seat product)</td>
                  <td>0.238</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[0.212, 0.264]</td>
                </tr>
                <tr>
                  <td>Num.Obs.</td>
                  <td>403</td>
                </tr>
                <tr>
                  <td>R2</td>
                  <td>0.448</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
<p>So far so good – we have an intercept which could be zero, and a coefficient which could be one quarter, as predicted.</p>
<p>What about nonlinear least squares with additive error?</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">m2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nls</span>(Ns0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> seat_product <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> k,</span>
<span id="cb9-2">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat,</span>
<span id="cb9-3">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">start =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))</span>
<span id="cb9-4">m2b <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nls</span>(Ns0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> a <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> seat_product <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> k,</span>
<span id="cb9-5">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat,</span>
<span id="cb9-6">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">start =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">a =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))</span>
<span id="cb9-7"></span>
<span id="cb9-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">modelsummary</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(m2, m2b),</span>
<span id="cb9-9">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">statistic =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"conf.int"</span>,</span>
<span id="cb9-10">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">gof_map =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nobs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"r.squared"</span>))</span></code></pre></div></div>
</details>
<div id="tbl-nls3" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-nls3-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;6: Nonlinear least squares regression of the raw number of parties, additive error.
</figcaption>
<div aria-describedby="tbl-nls3-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_fbdvrgj6xc8asa1251n9(i, j, css_id) {
          var table = document.getElementById("tinytable_fbdvrgj6xc8asa1251n9");
          var cell = table.rows[i]?.cells[j];  // Safe navigation to avoid errors
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function insertSpanRow(i, colspan, content) {
        var table = document.getElementById('tinytable_fbdvrgj6xc8asa1251n9');
        var newRow = table.insertRow(i);
        var newCell = newRow.insertCell(0);
        newCell.setAttribute("colspan", colspan);
        // newCell.innerText = content;
        // this may be unsafe, but innerText does not interpret <br>
        newCell.innerHTML = content;
      }
      function spanCell_fbdvrgj6xc8asa1251n9(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_fbdvrgj6xc8asa1251n9");
        const targetRow = table.rows[i];
        const targetCell = targetRow.cells[j];
        for (let r = 0; r < rowspan; r++) {
          // Only start deleting cells to the right for the first row (r == 0)
          if (r === 0) {
            // Delete cells to the right of the target cell in the first row
            for (let c = colspan - 1; c > 0; c--) {
              if (table.rows[i + r].cells[j + c]) {
                table.rows[i + r].deleteCell(j + c);
              }
            }
          }
          // For rows below the first, delete starting from the target column
          if (r > 0) {
            for (let c = colspan - 1; c >= 0; c--) {
              if (table.rows[i + r] && table.rows[i + r].cells[j]) {
                table.rows[i + r].deleteCell(j);
              }
            }
          }
        }
        // Set rowspan and colspan of the target cell
        targetCell.rowSpan = rowspan;
        targetCell.colSpan = colspan;
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: 5, j: 1 }, { i: 5, j: 2 },  ], css_id: 'tinytable_css_gmvic4xx2tnk3452hcxf',}, 
          { positions: [ { i: 4, j: 1 }, { i: 4, j: 2 },  ], css_id: 'tinytable_css_lp1o0unzu2o3ws9z9e98',}, 
          { positions: [ { i: 1, j: 1 }, { i: 3, j: 1 }, { i: 2, j: 2 }, { i: 3, j: 2 }, { i: 2, j: 1 }, { i: 1, j: 2 },  ], css_id: 'tinytable_css_piu6zsf620lqrg74xjw0',}, 
          { positions: [ { i: 0, j: 1 }, { i: 0, j: 2 },  ], css_id: 'tinytable_css_yquiup5t547g9wgjwu0h',}, 
          { positions: [ { i: 5, j: 0 },  ], css_id: 'tinytable_css_n3ubcpq3quspax1jdyas',}, 
          { positions: [ { i: 4, j: 0 },  ], css_id: 'tinytable_css_owq71lfqbm2a5pkfiic0',}, 
          { positions: [ { i: 1, j: 0 }, { i: 2, j: 0 }, { i: 3, j: 0 },  ], css_id: 'tinytable_css_ubk84av4yi73hk53gmjz',}, 
          { positions: [ { i: 0, j: 0 },  ], css_id: 'tinytable_css_j84dq2qrvo0e0gs89xlf',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_fbdvrgj6xc8asa1251n9(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_gmvic4xx2tnk3452hcxf, .table th.tinytable_css_gmvic4xx2tnk3452hcxf { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_lp1o0unzu2o3ws9z9e98, .table th.tinytable_css_lp1o0unzu2o3ws9z9e98 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_piu6zsf620lqrg74xjw0, .table th.tinytable_css_piu6zsf620lqrg74xjw0 { text-align: center; }
      .table td.tinytable_css_yquiup5t547g9wgjwu0h, .table th.tinytable_css_yquiup5t547g9wgjwu0h { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_n3ubcpq3quspax1jdyas, .table th.tinytable_css_n3ubcpq3quspax1jdyas { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_owq71lfqbm2a5pkfiic0, .table th.tinytable_css_owq71lfqbm2a5pkfiic0 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_ubk84av4yi73hk53gmjz, .table th.tinytable_css_ubk84av4yi73hk53gmjz { text-align: left; }
      .table td.tinytable_css_j84dq2qrvo0e0gs89xlf, .table th.tinytable_css_j84dq2qrvo0e0gs89xlf { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_fbdvrgj6xc8asa1251n9" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col"> </th>
                <th scope="col">(1)</th>
                <th scope="col">(2)</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td>k</td>
                  <td>0.258</td>
                  <td>0.159</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[0.247, 0.268]</td>
                  <td>[0.119, 0.200]</td>
                </tr>
                <tr>
                  <td>a</td>
                  <td></td>
                  <td>2.373</td>
                </tr>
                <tr>
                  <td></td>
                  <td></td>
                  <td>[1.610, 3.137]</td>
                </tr>
                <tr>
                  <td>Num.Obs.</td>
                  <td>403</td>
                  <td>403</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
<p>Here something seems to have come off the rails. Although the single parameter model conforms to expectations, in the sense that the value of <img src="https://latex.codecogs.com/png.latex?k"> could be one quarter, the two parameter model has a value of <img src="https://latex.codecogs.com/png.latex?k"> that is far too low.</p>
<p>Can we rescue this – and nonlinear least squares – by incorporating error that is proportionate to the predicted value?</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1">m3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gnls</span>(Ns0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> seat_product <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> k, </span>
<span id="cb10-2">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat,</span>
<span id="cb10-3">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">start =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb10-4">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weights =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">varPower</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">form =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fitted</span>(.)))</span>
<span id="cb10-5"></span>
<span id="cb10-6">m3b <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gnls</span>(Ns0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> a <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> seat_product <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> k, </span>
<span id="cb10-7">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat,</span>
<span id="cb10-8">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">start =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">a =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb10-9">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weights =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">varPower</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">form =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fitted</span>(.)))</span>
<span id="cb10-10"></span>
<span id="cb10-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">modelsummary</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(m3, m3b),</span>
<span id="cb10-12">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">statistic =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"conf.int"</span>,</span>
<span id="cb10-13">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">gof_map =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nobs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"r.squared"</span>))</span>
<span id="cb10-14">m3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gnls</span>(Ns0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> seat_product <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> k, </span>
<span id="cb10-15">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(seat_product <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e5</span>),</span>
<span id="cb10-16">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">start =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb10-17">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weights =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">varPower</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">form =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fitted</span>(.)))</span>
<span id="cb10-18"></span>
<span id="cb10-19">m3b <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gnls</span>(Ns0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> a <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> seat_product <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> k, </span>
<span id="cb10-20">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(seat_product <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e5</span>),</span>
<span id="cb10-21">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">start =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">a =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb10-22">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weights =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">varPower</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">form =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fitted</span>(.)))</span>
<span id="cb10-23"></span>
<span id="cb10-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">modelsummary</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(m3, m3b),</span>
<span id="cb10-25">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">statistic =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"conf.int"</span>,</span>
<span id="cb10-26">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">gof_map =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"nobs"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"r.squared"</span>))</span></code></pre></div></div>
</details>
<div id="tbl-nls4" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-nls4-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;7: Nonlinear least squares regression of the raw number of parties, error proportional to prediction.
</figcaption>
<div aria-describedby="tbl-nls4-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_7ijdfqv5wqbvszd9ngi9(i, j, css_id) {
          var table = document.getElementById("tinytable_7ijdfqv5wqbvszd9ngi9");
          var cell = table.rows[i]?.cells[j];  // Safe navigation to avoid errors
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function insertSpanRow(i, colspan, content) {
        var table = document.getElementById('tinytable_7ijdfqv5wqbvszd9ngi9');
        var newRow = table.insertRow(i);
        var newCell = newRow.insertCell(0);
        newCell.setAttribute("colspan", colspan);
        // newCell.innerText = content;
        // this may be unsafe, but innerText does not interpret <br>
        newCell.innerHTML = content;
      }
      function spanCell_7ijdfqv5wqbvszd9ngi9(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_7ijdfqv5wqbvszd9ngi9");
        const targetRow = table.rows[i];
        const targetCell = targetRow.cells[j];
        for (let r = 0; r < rowspan; r++) {
          // Only start deleting cells to the right for the first row (r == 0)
          if (r === 0) {
            // Delete cells to the right of the target cell in the first row
            for (let c = colspan - 1; c > 0; c--) {
              if (table.rows[i + r].cells[j + c]) {
                table.rows[i + r].deleteCell(j + c);
              }
            }
          }
          // For rows below the first, delete starting from the target column
          if (r > 0) {
            for (let c = colspan - 1; c >= 0; c--) {
              if (table.rows[i + r] && table.rows[i + r].cells[j]) {
                table.rows[i + r].deleteCell(j);
              }
            }
          }
        }
        // Set rowspan and colspan of the target cell
        targetCell.rowSpan = rowspan;
        targetCell.colSpan = colspan;
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: 6, j: 1 }, { i: 6, j: 2 },  ], css_id: 'tinytable_css_2l7vyc37sqhl5ou7aq3p',}, 
          { positions: [ { i: 4, j: 2 }, { i: 4, j: 1 },  ], css_id: 'tinytable_css_hzq80frk47tp402nk6gs',}, 
          { positions: [ { i: 1, j: 1 }, { i: 2, j: 1 }, { i: 1, j: 2 }, { i: 5, j: 1 }, { i: 3, j: 2 }, { i: 3, j: 1 }, { i: 5, j: 2 }, { i: 2, j: 2 },  ], css_id: 'tinytable_css_jrr0rt55uym5f49hj55t',}, 
          { positions: [ { i: 0, j: 1 }, { i: 0, j: 2 },  ], css_id: 'tinytable_css_59bifxs0tdkdi6c2nrqa',}, 
          { positions: [ { i: 6, j: 0 },  ], css_id: 'tinytable_css_g9vxzqckf3158z11bf7z',}, 
          { positions: [ { i: 4, j: 0 },  ], css_id: 'tinytable_css_o7m341tjtplyddiugzua',}, 
          { positions: [ { i: 1, j: 0 }, { i: 2, j: 0 }, { i: 3, j: 0 }, { i: 5, j: 0 },  ], css_id: 'tinytable_css_l7lajoclu4ftz7gu4x3t',}, 
          { positions: [ { i: 0, j: 0 },  ], css_id: 'tinytable_css_vh28w034ddc7b981qh2k',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_7ijdfqv5wqbvszd9ngi9(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_2l7vyc37sqhl5ou7aq3p, .table th.tinytable_css_2l7vyc37sqhl5ou7aq3p { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_hzq80frk47tp402nk6gs, .table th.tinytable_css_hzq80frk47tp402nk6gs { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_jrr0rt55uym5f49hj55t, .table th.tinytable_css_jrr0rt55uym5f49hj55t { text-align: center; }
      .table td.tinytable_css_59bifxs0tdkdi6c2nrqa, .table th.tinytable_css_59bifxs0tdkdi6c2nrqa { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_g9vxzqckf3158z11bf7z, .table th.tinytable_css_g9vxzqckf3158z11bf7z { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_o7m341tjtplyddiugzua, .table th.tinytable_css_o7m341tjtplyddiugzua { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_l7lajoclu4ftz7gu4x3t, .table th.tinytable_css_l7lajoclu4ftz7gu4x3t { text-align: left; }
      .table td.tinytable_css_vh28w034ddc7b981qh2k, .table th.tinytable_css_vh28w034ddc7b981qh2k { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_7ijdfqv5wqbvszd9ngi9" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col"> </th>
                <th scope="col">(1)</th>
                <th scope="col">(2)</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td>k</td>
                  <td>0.282</td>
                  <td>0.237</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[0.268, 0.296]</td>
                  <td>[0.192, 0.281]</td>
                </tr>
                <tr>
                  <td>a</td>
                  <td></td>
                  <td>1.373</td>
                </tr>
                <tr>
                  <td></td>
                  <td></td>
                  <td>[0.963, 1.784]</td>
                </tr>
                <tr>
                  <td>Num.Obs.</td>
                  <td>403</td>
                  <td>403</td>
                </tr>
                <tr>
                  <td>R2</td>
                  <td>0.033</td>
                  <td>0.109</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_wriz4cf8tr52xrl42x2z(i, j, css_id) {
          var table = document.getElementById("tinytable_wriz4cf8tr52xrl42x2z");
          var cell = table.rows[i]?.cells[j];  // Safe navigation to avoid errors
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function insertSpanRow(i, colspan, content) {
        var table = document.getElementById('tinytable_wriz4cf8tr52xrl42x2z');
        var newRow = table.insertRow(i);
        var newCell = newRow.insertCell(0);
        newCell.setAttribute("colspan", colspan);
        // newCell.innerText = content;
        // this may be unsafe, but innerText does not interpret <br>
        newCell.innerHTML = content;
      }
      function spanCell_wriz4cf8tr52xrl42x2z(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_wriz4cf8tr52xrl42x2z");
        const targetRow = table.rows[i];
        const targetCell = targetRow.cells[j];
        for (let r = 0; r < rowspan; r++) {
          // Only start deleting cells to the right for the first row (r == 0)
          if (r === 0) {
            // Delete cells to the right of the target cell in the first row
            for (let c = colspan - 1; c > 0; c--) {
              if (table.rows[i + r].cells[j + c]) {
                table.rows[i + r].deleteCell(j + c);
              }
            }
          }
          // For rows below the first, delete starting from the target column
          if (r > 0) {
            for (let c = colspan - 1; c >= 0; c--) {
              if (table.rows[i + r] && table.rows[i + r].cells[j]) {
                table.rows[i + r].deleteCell(j);
              }
            }
          }
        }
        // Set rowspan and colspan of the target cell
        targetCell.rowSpan = rowspan;
        targetCell.colSpan = colspan;
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: 6, j: 1 }, { i: 6, j: 2 },  ], css_id: 'tinytable_css_9wn92sdjp9eweo9l7yvu',}, 
          { positions: [ { i: 4, j: 2 }, { i: 4, j: 1 },  ], css_id: 'tinytable_css_6i9ig06ohu43igyu1820',}, 
          { positions: [ { i: 1, j: 1 }, { i: 2, j: 1 }, { i: 1, j: 2 }, { i: 5, j: 1 }, { i: 3, j: 2 }, { i: 3, j: 1 }, { i: 5, j: 2 }, { i: 2, j: 2 },  ], css_id: 'tinytable_css_purmkofhobcvm2s72d5v',}, 
          { positions: [ { i: 0, j: 1 }, { i: 0, j: 2 },  ], css_id: 'tinytable_css_zjow1es6v3qe55gqk0ts',}, 
          { positions: [ { i: 6, j: 0 },  ], css_id: 'tinytable_css_2h2d2r8mboj7rdme6l1a',}, 
          { positions: [ { i: 4, j: 0 },  ], css_id: 'tinytable_css_39t4tvqxai7eephemdhh',}, 
          { positions: [ { i: 1, j: 0 }, { i: 2, j: 0 }, { i: 3, j: 0 }, { i: 5, j: 0 },  ], css_id: 'tinytable_css_vkc2cnw04cxs2f8k5sql',}, 
          { positions: [ { i: 0, j: 0 },  ], css_id: 'tinytable_css_y1ae1grguceo8gs0vixa',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_wriz4cf8tr52xrl42x2z(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_9wn92sdjp9eweo9l7yvu, .table th.tinytable_css_9wn92sdjp9eweo9l7yvu { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_6i9ig06ohu43igyu1820, .table th.tinytable_css_6i9ig06ohu43igyu1820 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_purmkofhobcvm2s72d5v, .table th.tinytable_css_purmkofhobcvm2s72d5v { text-align: center; }
      .table td.tinytable_css_zjow1es6v3qe55gqk0ts, .table th.tinytable_css_zjow1es6v3qe55gqk0ts { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_2h2d2r8mboj7rdme6l1a, .table th.tinytable_css_2h2d2r8mboj7rdme6l1a { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_39t4tvqxai7eephemdhh, .table th.tinytable_css_39t4tvqxai7eephemdhh { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_vkc2cnw04cxs2f8k5sql, .table th.tinytable_css_vkc2cnw04cxs2f8k5sql { text-align: left; }
      .table td.tinytable_css_y1ae1grguceo8gs0vixa, .table th.tinytable_css_y1ae1grguceo8gs0vixa { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_wriz4cf8tr52xrl42x2z" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col"> </th>
                <th scope="col">(1)</th>
                <th scope="col">(2)</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td>k</td>
                  <td>0.283</td>
                  <td>0.245</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[0.269, 0.297]</td>
                  <td>[0.199, 0.290]</td>
                </tr>
                <tr>
                  <td>a</td>
                  <td></td>
                  <td>1.311</td>
                </tr>
                <tr>
                  <td></td>
                  <td></td>
                  <td>[0.916, 1.706]</td>
                </tr>
                <tr>
                  <td>Num.Obs.</td>
                  <td>401</td>
                  <td>401</td>
                </tr>
                <tr>
                  <td>R2</td>
                  <td>0.109</td>
                  <td>0.149</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
<p>In model (2), the value of <img src="https://latex.codecogs.com/png.latex?k"> is once against consistent with the predicted value of one quarter, and the value of <img src="https://latex.codecogs.com/png.latex?a"> is (just) consistent with a value of one. Thus, although a log log regression gave the “right” answer, and <em>one</em> nonlinear regression gave the “wrong” answer, that was because when we estimate a nonlinear regression we have to get our error structure right.</p>
</section>
<section id="conclusions" class="level1">
<h1>Conclusions</h1>
<p>In the worked examples I’ve set out, I was modelling numbers of parties, something that doesn’t vary over more than one order of magnitude.</p>
<p>The issues with fixed exponent relationships of the form <img src="https://latex.codecogs.com/png.latex?y%20=%20a%20x%20%5E%20k"> are likely to be more severe when dealing with data like conflict deaths which do range over orders of magnitude.</p>
<p>As always, we need to think carefully about our errors, and use the appropriate tools for the job. Generally, social scientists don’t think enough about variance <span class="citation" data-cites="braumoeller2006explaining">(Braumoeller 2006)</span>, but that’s something that we’re forced to do when we step into nonlinear modelling.</p>



</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent">
<div id="ref-braumoeller2006explaining" class="csl-entry">
Braumoeller, Bear F. 2006. <span>“Explaining Variance; or, Stuck in a Moment We Can’t Get Out Of.”</span> <em>Political Analysis</em> 14 (3): 268–90.
</div>
<div id="ref-packard2014use" class="csl-entry">
Packard, Gary C. 2014. <span>“On the Use of Log-Transformation Versus Nonlinear Regression for Analyzing Biological Power Laws.”</span> <em>Biological Journal of the Linnean Society</em> 113 (4): 1167–78.
</div>
<div id="ref-shugart2017votes" class="csl-entry">
Shugart, Matthew S, and Rein Taagepera. 2017. <em>Votes from Seats: Logical Models of Electoral Systems</em>. Cambridge University Press.
</div>
<div id="ref-smith1993logarithmic" class="csl-entry">
Smith, Richard J. 1993. <span>“Logarithmic Transformation Bias in Allometry.”</span> <em>American Journal of Physical Anthropology</em> 90 (2): 215–28.
</div>
<div id="ref-struthers2018introducing" class="csl-entry">
Struthers, Cory L, Yuhui Li, and Matthew S Shugart. 2018. <span>“Introducing New Multilevel Datasets: Party Systems at the District and National Levels.”</span> <em>Research &amp; Politics</em> 5 (4): 2053168018813508.
</div>
<div id="ref-xiao2011use" class="csl-entry">
Xiao, Xiao, Ethan P White, Mevin B Hooten, and Susan L Durham. 2011. <span>“On the Use of Log-Transformation Vs. Nonlinear Regression for Analyzing Biological Power Laws.”</span> <em>Ecology</em> 92 (10): 1887–94.
</div>
</div></section></div> ]]></description>
  <category>elections</category>
  <category>code</category>
  <guid>http://www.chrishanretty.co.uk/posts/power_laws/</guid>
  <pubDate>Wed, 04 Jun 2025 23:00:00 GMT</pubDate>
</item>
<item>
  <title>The effective number of parties given the share of the largest component</title>
  <dc:creator>CJH </dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/effnum_given_s1/</link>
  <description><![CDATA[ 





<p>In the Seat Product Model, the Seat Product is used to bound the number of seat-winning parties, which in turn is used to formulate an expectation regarding the seat share of the largest party. This in turn is used to formulate an expectation regarding the effective number of seat-winning parties: <img src="https://latex.codecogs.com/png.latex?N_S%20=%20s_1%5E%7B-4/3%7D">. However, the link between the largest share and the effective number is approximate, and it would be good to set it on a firmer footing.</p>
<p>Because I have been reading <a href="https://jack-bailey.co.uk/#category=Information%20Theory">Jack Bailey’s notes</a> on relationships between effective numbers and Renyi entropy, I got very excited to find a paper bounding Renyi entropies <span class="citation" data-cites="gress2024mathematical">(Gress and Rosenberg 2024)</span> as a function of the size of the largest component. That paper is interested in homozygosity and allele frequency, but maths is maths, right!</p>
<p>In this blog post I show that the bounds in that paper are the same as those identified by Taagepera some years previously, and indeed before any work from <a href="https://web.stanford.edu/group/rosenberglab/theory.html">Noah Rosenberg</a> on this topic <span class="citation" data-cites="rosenberg2008relationship">(Rosenberg and Jakobsson 2008)</span>. Although these papers are mathematically sophisticated, and are able to construct proofs using majorization, Taagepera got there first (informally, and until some other priority claim <a href="https://en.wikipedia.org/wiki/List_of_scientific_priority_disputes">rolls in</a>).</p>
<section id="taagepera2007predicting" class="level1">
<h1><span class="citation" data-cites="taagepera2007predicting">Taagepera (2007)</span></h1>
<p>A derivation of the approximation is given in <span class="citation" data-cites="taagepera2007predicting">Taagepera (2007)</span>, pp.&nbsp;163–164. I reproduce this here, discussing the upper limit and lower limit separately.</p>
<section id="upper-limit" class="level2">
<h2 class="anchored" data-anchor-id="upper-limit">Upper limit</h2>
<p>Taagepera writes:</p>
<blockquote class="blockquote">
<p>“For a given largest share (<img src="https://latex.codecogs.com/png.latex?s_1">) and number of seat-winning parties (<img src="https://latex.codecogs.com/png.latex?N_0">), the largest possible value of the effective number of parties (<img src="https://latex.codecogs.com/png.latex?N">) corresponds to the other (<img src="https://latex.codecogs.com/png.latex?N_0%20-%201">) parties having equal shares <img src="https://latex.codecogs.com/png.latex?%5Ctfrac%7B(1%20-%20s_1)%7D%7B(N_0%20%E2%88%92%201)%7D">:”</p>
</blockquote>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmax%20N%20=%20%5Cfrac%7B1%7D%7Bs_1%5E2%20+%20(N_0%20-%201)(1%20-%20s_1)%5E2%20/%20(N_0%20-%201)%5E%202%7D%20=%20%5Cfrac%7B1%7D%7Bs_1%5E2%20+%20(1%20-%20s_1)%5E2%20/%20(N_0%20-%201)%7D%0A"></p>
<blockquote class="blockquote">
<p>“As long as <img src="https://latex.codecogs.com/png.latex?N_0%20=%201/s_1%5E2"> applies, this expression simplifies into:”</p>
</blockquote>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmax%20N%20=%20%5Cfrac%7B1%20+%20s_1%7D%7B2%20s_1%5E2%7D%0A"></p>
</section>
<section id="lower-limit" class="level2">
<h2 class="anchored" data-anchor-id="lower-limit">Lower limit</h2>
<p>Taagepera writes:</p>
<blockquote class="blockquote">
<p>“When <img src="https://latex.codecogs.com/png.latex?s_1%20=%201/2,%201/3,%201/4">, etc., we can have all shares equal and hence <img src="https://latex.codecogs.com/png.latex?N%20=%201/s_1">. For intervening values of the largest share, making as many shares as possible equal to the largest minimizes <img src="https://latex.codecogs.com/png.latex?N">, leaving the remainder as a smaller party.”</p>
</blockquote>
<p>Taagepera then presents a set of case-based minima. These minima are expressed solely as a function of <img src="https://latex.codecogs.com/png.latex?s_1">, and do not incorporate information about <img src="https://latex.codecogs.com/png.latex?N_0"> explicitly (although they may do so implicitly).</p>
<p>Case 1:</p>
<blockquote class="blockquote">
<p>“For <img src="https://latex.codecogs.com/png.latex?1%20%3C%20s_1%20%3C%201/2">, no other party can match the largest. The effective number is lowest when the second-largest party is as large as possible, meaning <img src="https://latex.codecogs.com/png.latex?s_2%20=%201%20-%20s_1">. The resulting minimal effective number is”</p>
</blockquote>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmin%20N%20=%20%5Cfrac%7B1%7D%7B1%20-%202s_1%20+%202s_1%5E2%7D%0A"></p>
<p>Case 2:</p>
<blockquote class="blockquote">
<p>“For <img src="https://latex.codecogs.com/png.latex?1/2%20%3C%20s_1%20%3C%201/3">, the lowest N corresponds to <img src="https://latex.codecogs.com/png.latex?s_2%20=%20s_1"> and <img src="https://latex.codecogs.com/png.latex?s_3%20=%201%20-%202%20s_1">. Then”</p>
</blockquote>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmin%20N%20=%20%5Cfrac%7B1%7D%7B1%20-%204%20s_1%20+%206%20s_1%5E2%7D%0A"></p>
<p>Cases 3, 4:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Bcases%7D%0A%5Cmin%20N%20=%20%5Cfrac%7B1%7D%7B1%20-%206%20s_1%20+%2012%20s_1%5E2%7D,%20&amp;%20%5B1/3%20%3C%20s_1%20%3C%201/4%5D%20%5C%5C%0A%5Cmin%20N%20=%20%5Cfrac%7B1%7D%7B1%20-%208%20s_1%20+%2020%20s_1%5E2%7D,%20&amp;%20%5B1/4%20%3C%20s_1%20%3C%201/5%5D%20%5C%5C%0A%5Cend%7Bcases%7D%0A"></p>
<p>All remaining cases:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmin%20N%20=%20%5Cfrac%7B1%7D%7Bs_1%7D%0A"></p>
</section>
<section id="geometric-means" class="level2">
<h2 class="anchored" data-anchor-id="geometric-means">Geometric means</h2>
<p>Taagepera apparently calculates the geometric mean of these expressions and tries to approximate it. He writes:</p>
<blockquote class="blockquote">
<p>“We should try to fit the geometric means of these minimum and maximum values with some simple function of <img src="https://latex.codecogs.com/png.latex?s_1">. They can be well fitted with a two-parameter format <img src="https://latex.codecogs.com/png.latex?N%20=%20a/s1b%20%E2%88%92%20a%20+%201">, which correctly predicts <img src="https://latex.codecogs.com/png.latex?N%20=%201"> when <img src="https://latex.codecogs.com/png.latex?s_1%20=%201">. The best fit is close to <img src="https://latex.codecogs.com/png.latex?N%20=%202/s_1%5E%7B0.9%7D%20%E2%88%92%201">. However, we should also try to fit with the simpler one-parameter format <img src="https://latex.codecogs.com/png.latex?N%20=%201/s_1%5En"> , because that form can be easily combined with <img src="https://latex.codecogs.com/png.latex?s_1%20=%20(MS)%5E%7B-1/8%7D"> so as to connect <img src="https://latex.codecogs.com/png.latex?N"> with the seat product <img src="https://latex.codecogs.com/png.latex?MS"> in a simple way. This is possible, indeed. Depending on whether one wishes to emphasize the fit at lower or higher values of the largest share, the exponent <img src="https://latex.codecogs.com/png.latex?n"> could be taken as anywhere between 1.30 and 1.45. The choice of the simple fraction n = 1/3… agrees with the data”</p>
</blockquote>
<p>This implies that if we could find tighter bounds, we could recalculate geometric means, and find some simple approximation. Whether that approximation yielded a better fit would, of course, be an empirical question – but it would be strange if narrower logical bounds yielded worse empirical fit.</p>
</section>
<section id="plot" class="level2">
<h2 class="anchored" data-anchor-id="plot">Plot</h2>
<p>I find understanding these equations hard, so I plot the limits in R.</p>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1">lb <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(s1) {</span>
<span id="cb1-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">suppressPackageStartupMessages</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">require</span>(dplyr))</span>
<span id="cb1-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(s1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> s1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> s1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb1-4">              s1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> s1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> s1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb1-5">              s1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> s1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> s1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb1-6">              s1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> s1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> s1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb1-7">              s1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> s1)</span>
<span id="cb1-8">}</span>
<span id="cb1-9">ub <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(s1) {</span>
<span id="cb1-10">    (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> s1) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> s1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb1-11">}</span>
<span id="cb1-12"></span>
<span id="cb1-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">par</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0f2537"</span>,</span>
<span id="cb1-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.lab =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>,</span>
<span id="cb1-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.axis =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>,</span>
<span id="cb1-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fg =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>)</span>
<span id="cb1-17"></span>
<span id="cb1-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>,</span>
<span id="cb1-19">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xlab =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expression</span>(s[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb1-20">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylab =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expression</span>(N[S]),</span>
<span id="cb1-21">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">log =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y"</span>,</span>
<span id="cb1-22">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>)</span>
<span id="cb1-23"></span>
<span id="cb1-24">inx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">length.out =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span>
<span id="cb1-25">my_lb <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(inx, lb)</span>
<span id="cb1-26">my_ub <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(inx, ub)</span>
<span id="cb1-27">my_gm <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(my_lb <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> my_ub)</span>
<span id="cb1-28"></span>
<span id="cb1-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lines</span>(inx, my_lb, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5cb85c"</span>)</span>
<span id="cb1-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lines</span>(inx, my_ub, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5cb85c"</span>)</span>
<span id="cb1-31"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lines</span>(inx, my_gm, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span>)</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="http://www.chrishanretty.co.uk/posts/effnum_given_s1/index_files/figure-html/unnamed-chunk-1-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</section>
</section>
<section id="gress2024mathematical" class="level1">
<h1><span class="citation" data-cites="gress2024mathematical">Gress and Rosenberg (2024)</span></h1>
<p><span class="citation" data-cites="gress2024mathematical">Gress and Rosenberg (2024)</span> set out expressions for lower and upper bounds on the Hill numbers (=effective numbers) of a composition with largest element <img src="https://latex.codecogs.com/png.latex?M"> and number of elements <img src="https://latex.codecogs.com/png.latex?I">. If we adopt our notation instead, then their expressions are as follows:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AN_S%20%5Cge%20%5Cleft%5B%20%5Cleft%20%5Clfloor%7B1/s_1%7D%20%5Cright%20%5Crfloor%20s_1%20%5E%202%20+%20(1%20-%20%5Cleft%20%5Clfloor%7B1/s_1%7D%5Cright%20%5Crfloor%20s_1)%5E2%20%5Cright%5D%5E%7B-1/2%7D%0A"></p>
<p>and</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AN_S%20%5Cle%20%5Cleft%5B%20s_1%5E2%20+%20(N_%7BS0%7D%20-%201)%20%5Cleft(%20%5Cfrac%7B1%20-%20s_1%7D%7BN_%7BS0%7D%20-%201%7D%5Cright)%5E2%20%5Cright%5D%5E%7B-1/2%7D%0A"></p>
<p>I find it very difficult to look at this formula, and the formulae above, and see whether they’re any different. I’m therefore going to take the dullard’s way, calculating things and then plotting them. I’ll assume <img src="https://latex.codecogs.com/png.latex?N_%7BS0%7D%20=%201%20/%20s_1%5E2">.</p>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">lb2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(s1) {</span>
<span id="cb2-2">    (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">floor</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>s1) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> s1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">floor</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>s1) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> s1)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb2-3">}</span>
<span id="cb2-4">ub2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(s1) {</span>
<span id="cb2-5">    N_S0 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> s1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb2-6">    (s1<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> (N_S0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> ((<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> s1)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>(N_S0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb2-7">}</span>
<span id="cb2-8"></span>
<span id="cb2-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">par</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0f2537"</span>,</span>
<span id="cb2-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.lab =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>,</span>
<span id="cb2-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.axis =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>,</span>
<span id="cb2-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fg =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>)</span>
<span id="cb2-13"></span>
<span id="cb2-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>,</span>
<span id="cb2-15">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xlab =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expression</span>(s[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb2-16">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylab =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expression</span>(N[S]),</span>
<span id="cb2-17">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">log =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y"</span>)</span>
<span id="cb2-18"></span>
<span id="cb2-19">inx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">length.out =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span>
<span id="cb2-20">my_lb2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(inx, lb2)</span>
<span id="cb2-21">my_ub2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(inx, ub2)</span>
<span id="cb2-22">my_gm2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(my_lb2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> my_ub2)</span>
<span id="cb2-23"></span>
<span id="cb2-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lines</span>(inx, my_lb, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5cb85c"</span>)</span>
<span id="cb2-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lines</span>(inx, my_ub, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5cb85c"</span>)</span>
<span id="cb2-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lines</span>(inx, my_gm, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey"</span>)</span>
<span id="cb2-27"></span>
<span id="cb2-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lines</span>(inx, my_lb2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#2b3e50"</span>)</span>
<span id="cb2-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lines</span>(inx, my_ub2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#2b3e50"</span>)</span>
<span id="cb2-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lines</span>(inx, my_gm2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">lty =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span>)</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="http://www.chrishanretty.co.uk/posts/effnum_given_s1/index_files/figure-html/unnamed-chunk-2-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>Here the two sets of bounds overlap perfectly, and so whilst the expression found in <span class="citation" data-cites="gress2024mathematical">Gress and Rosenberg (2024)</span> is neater, it doesn’t help us advance on <span class="citation" data-cites="taagepera2007predicting">Taagepera (2007)</span>.</p>
</section>
<section id="conclusion" class="level1">
<h1>Conclusion</h1>
<p>Sometimes I am easily impressed by papers which look complicated, but which don’t yield advances in knowledge.</p>
<!-- We could, of course, go back to earlier work and see more generous -->
<!-- bounds which don't rely on $N_{S0}$: -->
<!-- $$ -->
<!-- N_S \ge 1/s_1^2 -->
<!-- $$ -->
<!-- and  -->
<!-- $$ -->
<!-- N_S \ge \frac{1}{1 - s_1 \left( \left \lceil{1/s_1} \right \rceil - 1 \right)(2 - \left \lceil{1/s_1} \right \rceil s_1 )} -->
<!-- $$ -->
<!-- ```{r} -->
<!-- lb3 <- function(s1) { -->
<!--     1 / s1^2 -->
<!-- } -->
<!-- ub3 <- function(s1) { -->
<!--     res <- 1 - s1 * (ceiling(1/s1) - 1) * (2 - ceiling(1/s1) * s1) -->
<!--     1 / res -->
<!-- } -->
<!-- plot(c(0, 1), c(1, 20), type = "n", -->
<!--      xlab = expression(s[1]), -->
<!--      ylab = expression(N[S]), -->
<!--      log = "y") -->
<!-- inx <- seq(0.1, 1, length.out = 100) -->
<!-- my_lb3 <- sapply(inx, lb3) -->
<!-- my_ub3 <- sapply(inx, ub3) -->
<!-- my_gm3 <- sqrt(my_lb3 * my_ub3) -->
<!-- lines(inx, my_lb, lty = 2, col = "red") -->
<!-- lines(inx, my_ub, lty = 2, col = "red") -->
<!-- lines(inx, my_gm, lty = 1, col = "grey") -->
<!-- lines(inx, my_lb3, lty = 2, col = "green") -->
<!-- lines(inx, my_ub3, lty = 2, col = "green") -->
<!-- lines(inx, my_gm3, lty = 1, col = "black") -->
<!-- ``` -->
<!-- # Empirical check whether this approximation works better -->
<!-- ```{r} -->
<!-- dat <- read.csv("auc/data/tidy_electoral_data.csv") -->
<!-- dat <- dat |> -->
<!--     mutate(approx_taag = s_1 ^(-4/3), -->
<!--            approx_alt = sqrt((1+s_1) / (2 * s_1^3 * (1 - 0.25 * s_1))), -->
<!--            approx_alt2 = 1 / (s_1^(3/2) * sqrt(1 - 0.25 * s_1))) -->
<!-- panel.cor <- function(x, y, digits = 2, prefix = "", cex.cor, ...) -->
<!-- { -->
<!--     par(usr = c(0, 1, 0, 1)) -->
<!--     r <- abs(cor(x, y)) -->
<!--     txt <- format(c(r, 0.123456789), digits = digits)[1] -->
<!--     txt <- paste0(prefix, txt) -->
<!--     if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt) -->
<!--     text(0.5, 0.5, txt, cex = cex.cor * r) -->
<!-- } -->
<!-- pairs(dat[,c("N_S", "approx_taag", "approx_alt")], -->
<!--       upper.panel = panel.cor) -->
<!-- plot(dat$s_1, dat$N_S,  -->
<!--      xlab = expression(s[1]), -->
<!--      ylab = expression(N[S]), -->
<!--      log = "y") -->
<!-- inx <- seq(0.1, 1, length.out = 100) -->
<!-- my_lb <- sapply(inx, lb) -->
<!-- my_ub <- sapply(inx, ub) -->
<!-- my_gm <- sqrt(my_lb * my_ub) -->
<!-- lines(inx, my_lb3, lty = 2, col = "red") -->
<!-- lines(inx, my_ub3, lty = 2, col = "red") -->
<!-- lines(inx, my_gm3, lty = 1, col = "black") -->
<!-- ### What is the RMSE for different approximations and geometric means? -->
<!-- ### -->
<!-- rmse <- function(x, y) { -->
<!--     sqrt(mean((x - y)^2, na.rm = TRUE)) -->
<!-- } -->
<!-- rmse(dat$N_S, dat$approx_taag) -->
<!-- rmse(dat$N_S, dat$approx_alt) -->
<!-- rmse(dat$N_S, dat$approx_alt2) -->
<!-- ### What is the direction of the error? -->
<!-- mean(dat$N_S - dat$approx_taag) -->
<!-- mean(dat$N_S - dat$approx_alt) -->
<!-- mean(dat$N_S - dat$approx_alt2) -->
<!-- ``` -->



</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent">
<div id="ref-gress2024mathematical" class="csl-entry">
Gress, Theodore D, and Noah A Rosenberg. 2024. <span>“Mathematical Constraints on a Family of Biodiversity Measures via Connections with r<span>é</span>nyi Entropy.”</span> <em>BioSystems</em> 237: 105153.
</div>
<div id="ref-rosenberg2008relationship" class="csl-entry">
Rosenberg, Noah A, and Mattias Jakobsson. 2008. <span>“The Relationship Between Homozygosity and the Frequency of the Most Frequent Allele.”</span> <em>Genetics</em> 179 (4): 2027–36.
</div>
<div id="ref-taagepera2007predicting" class="csl-entry">
Taagepera, Rein. 2007. <em>Predicting Party Sizes: The Logic of Simple Electoral Systems</em>. OUP Oxford.
</div>
</div></section></div> ]]></description>
  <category>elections</category>
  <category>code</category>
  <guid>http://www.chrishanretty.co.uk/posts/effnum_given_s1/</guid>
  <pubDate>Fri, 14 Feb 2025 00:00:00 GMT</pubDate>
</item>
<item>
  <title>How many people, in which countries, can use the left-right scale?</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/who_can_use_leftright_scale/</link>
  <description><![CDATA[ 





<p>The left-right scale is one of the most commonly used scales in political science. It’s one of the few scales that is <em>so</em> well known that we allow respondents to position themselves on a numeric scale, rather than asking them a series of more concrete questions and inferring a position.</p>
<p>In this respect, it’s a bit like satisfaction or pain, where people might ask you to rate <a href="https://www.ons.gov.uk/peoplepopulationandcommunity/wellbeing/methodologies/surveysusingthe4officefornationalstatisticspersonalwellbeingquestions">how satisfied you are with your life overall on a scale from zero to ten</a>, or rate <a href="https://en.wikipedia.org/wiki/Pain_scale#Numeric_rating_scale">how much pain you’re in on a scale from zero to ten</a>.</p>
<p>The left-right scale is unlike happiness or pain scales because it’s possible that some people don’t know how to use it. We would regard a survey respondent as unusual—and possibly a philosopher —if, in response to a question about life satisfaction, they said that they didn’t know what life satisfaction was. We would regard someone as psychotic if they gave a similar response when asked about pain.</p>
<p>For the left-right scale, there are going to be some people who (say they) don’t know what left and right mean. They may:</p>
<ul>
<li>say explicitly that they don’t know what left and right mean, or</li>
<li>be unable to give <em>any</em> response to a question asking them to place themselves on a left-right scale, or</li>
<li>give placements of objects on this scale that are so odd as to call into question their ability successfully to use the scale</li>
</ul>
<p>We can work out the proportion of people in these categories using data from the <a href="https://cses.org/">Comparative Study of Electoral Systems</a> (CSES). For most country-years,<sup>1</sup> the CSES asks respondents to place themselves on a 0-10 left-right scale, and asks them to place parties. For most country-years, survey teams recorded when the respondent volunteered that they hadn’t heard of the left-right scale, or when the respondent volunteered that they couldn’t place themselves.</p>
<p>We can calculate some of these proportions using the CSES integrated data.</p>
<div class="cell">
<details class="code-fold">
<summary>Show the code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggrepel)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(countrycode)</span>
<span id="cb1-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">load</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cses_imd.rdata"</span>)</span>
<span id="cb1-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##</span></span>
<span id="cb1-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Countries where the left-right question wasn't asked</span></span>
<span id="cb1-7">problem_cases <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"JPN_1996"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"JPN_2004"</span>,</span>
<span id="cb1-8">                   <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TWN_2012"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TWN_2016"</span>,</span>
<span id="cb1-9">                   <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TWN_2020"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"THA_2001"</span>,</span>
<span id="cb1-10">                   <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"THA_2011"</span>)</span>
<span id="cb1-11"></span>
<span id="cb1-12">cses_imd <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cses_imd <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.element</span>(IMD1004, problem_cases))</span>
<span id="cb1-14"></span>
<span id="cb1-15">percentages <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cses_imd <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-16">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(IMD1006_UNALPHA3,</span>
<span id="cb1-17">             IMD1008_YEAR) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarize</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pct_havent_heard =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">weighted.mean</span>(IMD3006 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">95</span>,</span>
<span id="cb1-19">                                               IMD1010_3),</span>
<span id="cb1-20">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pct_cantplace =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">weighted.mean</span>(IMD3006 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">98</span>,</span>
<span id="cb1-21">                                            IMD1010_3),</span>
<span id="cb1-22">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pct_missing =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">weighted.mean</span>(IMD3006 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,</span>
<span id="cb1-23">                                          IMD1010_3),</span>
<span id="cb1-24">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb1-25"></span>
<span id="cb1-26">mean_haventheard <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(percentages<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_havent_heard,</span>
<span id="cb1-27">                                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>))</span>
<span id="cb1-28"></span>
<span id="cb1-29">mean_cantplace <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(percentages<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_cantplace,</span>
<span id="cb1-30">                                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>))</span>
<span id="cb1-31"></span>
<span id="cb1-32">mean_cantuse <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(percentages<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_cantplace <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-33">                                 percentages<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_havent_heard,</span>
<span id="cb1-34">                                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>))</span>
<span id="cb1-35">mean_missing <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(percentages<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_missing,</span>
<span id="cb1-36">                                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>))</span></code></pre></div></div>
</details>
</div>
<p>Across almost all election studies conducted by CSES:</p>
<ul>
<li>the average proportion of respondents who volunteered that they hadn’t heard of the left-right scale was 2.</li>
<li>the average proportion of respondents who said that they couldn’t place themselves on the left-right scale was 11</li>
</ul>
<p>The average sum of these two proportions was 14, and the total proportion of responses that were missing, for whatever reason including refusal, was 20.</p>
<p>These proportions set a lower bound on the proportion of people who can use the left-right scale. Some people will give a response to questions about the left-right scale, but use it in ways that suggest they don’t understand it.</p>
<p>At the national level, we can calculate the association between the average placement given to each party, and the placement given by CSES project teams – who presumably do understand the left-right dimension.</p>
<p>(Although in principle it would be possible to calculate the correlation at individual level, awkward issues arise where respondents evaluate different numbers of parties).</p>
<div class="cell">
<details class="code-fold">
<summary>Show the code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">r_placement <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cses_imd <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-2">    dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(IMD1006_UNALPHA3,</span>
<span id="cb2-3">                  IMD1008_YEAR,</span>
<span id="cb2-4">                  IMD1010_3,</span>
<span id="cb2-5">                  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">starts_with</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IMD3007_"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pivot_longer</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cols =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">starts_with</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IMD3007_"</span>)),</span>
<span id="cb2-7">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values_to =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"placement"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placement =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na_if</span>(placement, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">95</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb2-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placement =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na_if</span>(placement, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">96</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placement =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na_if</span>(placement, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">97</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placement =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na_if</span>(placement, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">98</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placement =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na_if</span>(placement, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">99</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(IMD1006_UNALPHA3, IMD1008_YEAR, name) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-14">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarize</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r_placement =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">weighted.mean</span>(placement, IMD1010_3, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb2-15">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-16">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IMD3007_"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Party "</span>, name))</span>
<span id="cb2-17"></span>
<span id="cb2-18">exp_placement <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cses_imd <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-19">    dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(IMD1006_UNALPHA3,</span>
<span id="cb2-20">                  IMD1008_YEAR,</span>
<span id="cb2-21">                  IMD1010_3,</span>
<span id="cb2-22">                  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">starts_with</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IMD5012_"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pivot_longer</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cols =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">starts_with</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IMD5012_"</span>)),</span>
<span id="cb2-24">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values_to =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"placement"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placement =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na_if</span>(placement, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">95</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> </span>
<span id="cb2-26">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placement =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na_if</span>(placement, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">96</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placement =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na_if</span>(placement, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">97</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-28">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placement =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na_if</span>(placement, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">98</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-29">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">placement =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na_if</span>(placement, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">99</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-30">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(IMD1006_UNALPHA3, IMD1008_YEAR, name) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-31">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarize</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">exp_placement =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">weighted.mean</span>(placement, IMD1010_3, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb2-32">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-33">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IMD5012_"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Party "</span>, name))</span>
<span id="cb2-34"></span>
<span id="cb2-35">correls <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(r_placement, exp_placement) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-36">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(IMD1006_UNALPHA3, IMD1008_YEAR) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-37">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarize</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">the_cor =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor</span>(r_placement,</span>
<span id="cb2-38">                            exp_placement,</span>
<span id="cb2-39">                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">use =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pairwise"</span>,</span>
<span id="cb2-40">                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"spearman"</span>))</span>
<span id="cb2-41"></span>
<span id="cb2-42">avg_correl <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(correls<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>the_cor, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> T), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span></code></pre></div></div>
</details>
</div>
<p>Across all studies, the average correlation is fairly healthy, at 0.78. Indeed, given that questions about party placements have made it into a cross-national survey programme, we would expect the question to give roughly sensible answers. But that doesn’t mean it’s sensible in all circumstances.</p>
<div class="cell">
<details class="code-fold">
<summary>Show the code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">plot_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(percentages, correls,</span>
<span id="cb3-2">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">join_by</span>(IMD1006_UNALPHA3, IMD1008_YEAR)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dodgy =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>((pct_cantplace <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> pct_havent_heard) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> .<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb3-4">                             the_cor <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb3-5">                             <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb3-6">                             </span>
<span id="cb3-7">sum_good <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(plot_df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dodgy <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb3-8">tot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(plot_df)</span>
<span id="cb3-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(plot_df,</span>
<span id="cb3-10">       <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> pct_cantplace <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> pct_havent_heard,</span>
<span id="cb3-11">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> the_cor)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> plot_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(dodgy <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text_repel</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> plot_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(dodgy <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb3-14">                    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(IMD1006_UNALPHA3, IMD1008_YEAR)),</span>
<span id="cb3-15">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span>,</span>
<span id="cb3-16">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb3-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ffc61a"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_vline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xintercept =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ffc61a"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb3-19">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_continuous</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Proportion who haven't heard of left-right or</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">can't place themselves"</span>,</span>
<span id="cb3-20">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> scales<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>percent) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-21">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Correlation between average respondent placement and</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">expert placement"</span>,</span>
<span id="cb3-22">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> scales<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>percent) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_dark</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-24">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>,</span>
<span id="cb3-25">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.box =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"vertical"</span>,</span>
<span id="cb3-26">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0f2537"</span>,</span>
<span id="cb3-27">                                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>),</span>
<span id="cb3-28">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#2b3e50"</span>),</span>
<span id="cb3-29">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0f2537"</span>),</span>
<span id="cb3-30">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>),          </span>
<span id="cb3-31">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>),</span>
<span id="cb3-32">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>))</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div id="fig-scatter" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-scatter-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/who_can_use_leftright_scale/index_files/figure-html/fig-scatter-1.png" class="img-fluid figure-img" style="width:100.0%">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-scatter-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: A scatter-plot showing the proportion who either haven’t heard of the left-right scale or who can’t place themselves on it (horizontal axis) against the correlation between average respondent party placements and expert party placements (vertical axis)
</figcaption>
</figure>
</div>
</div>
</div>
<p>In Figure&nbsp;1 I’ve plotted two measures of “how much left-right makes sense”: the proportion who can’t place themselves or haven’t heard of left and right, and the correlation between citizen and expert placements. I’ve divided the plot into four quadrants, choosing a cut-off of 30% on the horizontal axis, and <img src="https://latex.codecogs.com/png.latex?r%20=%200.4"> on the vertical axis.</p>
<p>In the <em>bottom right quadrant</em>, we’ve got country-years where lots of people said they didn’t grok left-right, and where the placements proved that. Costa Rica in 2018 is perhaps the most extreme example, but there’s a pretty good showing from some Brazilian elections here.</p>
<p>In the <em>top right quadrant</em>, we’ve got country-years where lots of people said they didn’t grok left-right, but where those people who did use placements did so accurately. Here we have countries which have other major dimensions of competition (like Taiwan) or countries which in my view should never have been surveyed (like Belarus).</p>
<p>In the <em>bottom left quadrant</em>, we’ve got countries where people talked a good game, but where their performance left a lot to be desired. South Africa is a good case in point – here, the correlation between expert placements and citizen placements is pretty strong, but exactly the wrong way round, with citizens placing Julius Malema’s Economic Freedom Fighters on the right, which doesn’t make a lick of sense.</p>
<p>Finally, in the <em>top left quadrant</em> we’ve got the bulk of studies ( 176 / 219), where few people volunteer that they haven’t heard of left-right, and where people on average seem to be able to use it correctly.</p>
<p>This division into quadrants is partly arbitrary, and based on knowledge of a small number of cases. <em>First,</em> I believe that left and right make sense in UK politics. As a result, the threshold for the proportion of people who either haven’t heard of—or can’t place themselves using—the left right scale is set based on the proportion in the UK in 2005, where a rather surprising 25.5% of respondents said they couldn’t place themselves. <em>Second</em>, I believe that left and right don’t make much sense in Hong Kong politics, where the pro/anti-Beijing cleavage was far more important at the time these surveys were conducted. As a result, the threshold for the correlation between citizen and expert placements is set at above 0.4, the correlation in Hong Kong is 2004, and the maximum correlation amongst the six Hong Kong studies.</p>
<p>This means that if we want to study citizen-elite linkages on the left-right spectrum, we’re presently limited to the analysis of around 176 country-years, and our knowledge grows by around seven country-years per year. Big data might have arrived in other domains, but not here.</p>




<div id="quarto-appendix" class="default"><section id="footnotes" class="footnotes footnotes-end-of-document"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>

<ol>
<li id="fn1"><p>The question wasn’t asked in Japan in 1996 and 2004; in Taiwan in 2012, 2016, and 2020, or in Thailand in 2001 or 2011.↩︎</p></li>
</ol>
</section></div> ]]></description>
  <category>polling</category>
  <category>code</category>
  <category>left-right</category>
  <guid>http://www.chrishanretty.co.uk/posts/who_can_use_leftright_scale/</guid>
  <pubDate>Thu, 16 Jan 2025 00:00:00 GMT</pubDate>
</item>
<item>
  <title>What might a Syrian electoral system look like?</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/syrian_election/</link>
  <description><![CDATA[ 





<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>“too long, didn’t read” summary
</div>
</div>
<div class="callout-body-container callout-body">
<p>Using the existing electoral districts and party list PR would be a reasonable basis for a Syrian election.</p>
</div>
</div>
<div class="callout callout-style-default callout-warning callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Warning
</div>
</div>
<div class="callout-body-container callout-body">
<p>I am not an expert in Syrian politics, and there are lots of issues that I don’t consider here concerning minority representation.</p>
</div>
</div>
<p>It is now <a href="https://www.aljazeera.com/news/2025/1/9/syrians-mark-a-month-since-al-assads-overthrow-with-concert-in-capital">over a month</a> since Bashar al-Assad was overthrown as leader of Syria. The de facto leader of Syria, Ahmed al-Sharaa, has <a href="https://www.bbc.co.uk/news/articles/c4g29e1lejvo">said</a> that it might take a year for Syrians to see improvements to public services, and four years before democratic elections can be held. Al-Sharaa argues that a census must be held before elections can be held. Only then can fair shares of seats be allocated to (new or existing) electoral districts reflecting their population.</p>
<p>The allocation of seats between districts is a sensitive issue, since under Ba’ath party rule the number of seats per electoral district <a href="https://www.idea.int/blog/explainer-syrias-2024-legislative-elections">was set by presidential decree</a>, and those decrees unsurprisingly rewarded pro-regime areas. There are therefore good reasons why democrats might want an accurate census before elections are held, and might therefore want elections to be held <em>later</em> rather than <em>sooner</em>.</p>
<p>Having said this, running an accurate census is neither easy nor quick, and other elections in the region have been run using administrative data to work out the number of people in each region. In Iraq, re-districting following the 2020 electoral reform was <a href="https://www.chathamhouse.org/2021/10/iraqs-electoral-system/two-major-changes">carried out on the basis of counts from the public rationing system</a>. Even without administrative data, it’s possible to estimate populations in defined areas <a href="https://www.nature.com/articles/s41598-022-08935-1">using satellite imagery</a>, and in the UK DfID has <a href="https://www.gov.uk/government/case-studies/how-dfid-used-satellite-images-to-estimate-populations">sponsored such work</a>. Seats could be allocated to electoral districts using reasonably accurate data in a four month period rather than over a four year period.</p>
<p>Of course, in order to allocate seats between districts, we first have to know what districts are to be used. <a href="https://aceproject.org/main/english/es/esg04.htm">District magnitude</a> – the number of legislators elected in each district – is one of two key factors which determine the proportionality of an electoral system. Generally, the <a href="https://doi.org/10.1017/9781108261128">seat share of the largest party is equal to district magnitude, time the total number of legislators, raised to the power of negative one-eighth</a>, at least for “simple” electoral systems.</p>
<p>This rule of thumb means that if district magnitude is small, then a single party might win a legislative majority and use that legislative majority to eliminate political competition. If district magnitude is very large, then forming a government will be a protracted exercise which requires collaboration between many parties, leading to popular unrest or the emergence of non-democratic movements.</p>
<p>Choosing a path between these two risks involves value judgements. Where people with different values disagree, the status quo can often win out. In this case, the status quo is not too bad – at least on paper. The People’s Assembly has 250 members, elected in 15 multimember constituencies, which correspond to the country’s provinces or governorates, except that Aleppo City forms a separate constituency from the rest of Aleppo province. This gives an average of 16.7 members per constituency. Table&nbsp;1 shows the expected number of legislators per district on the basis of <a href="https://en.wikipedia.org/wiki/Governorates_of_Syria">2018 population counts</a>, except that I have split Aleppo province and Aleppo city according to the most recent estimate of the population for Aleppo city.</p>
<div class="cell">
<div id="tbl-seatalloc" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-seatalloc-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;1: Notional allocation of seats between existing districts using 2018 population figures and D’Hondt method of allocation
</figcaption>
<div aria-describedby="tbl-seatalloc-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<table class="cell caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;">District</th>
<th style="text-align: right;">Population (thousands)</th>
<th style="text-align: right;">District size</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Aleppo (City)</td>
<td style="text-align: right;">2098</td>
<td style="text-align: right;">25</td>
</tr>
<tr class="even">
<td style="text-align: left;">Aleppo (province)</td>
<td style="text-align: right;">2502</td>
<td style="text-align: right;">29</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Raqqa</td>
<td style="text-align: right;">919</td>
<td style="text-align: right;">10</td>
</tr>
<tr class="even">
<td style="text-align: left;">Suwayda</td>
<td style="text-align: right;">500</td>
<td style="text-align: right;">5</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Damascus</td>
<td style="text-align: right;">2211</td>
<td style="text-align: right;">26</td>
</tr>
<tr class="even">
<td style="text-align: left;">Daraa</td>
<td style="text-align: right;">998</td>
<td style="text-align: right;">11</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Deir ez-Zor</td>
<td style="text-align: right;">1201</td>
<td style="text-align: right;">14</td>
</tr>
<tr class="even">
<td style="text-align: left;">Hama</td>
<td style="text-align: right;">1593</td>
<td style="text-align: right;">19</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Al-Hasakah</td>
<td style="text-align: right;">1272</td>
<td style="text-align: right;">15</td>
</tr>
<tr class="even">
<td style="text-align: left;">Homs</td>
<td style="text-align: right;">1762</td>
<td style="text-align: right;">21</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Idlib</td>
<td style="text-align: right;">1464</td>
<td style="text-align: right;">17</td>
</tr>
<tr class="even">
<td style="text-align: left;">Latakia</td>
<td style="text-align: right;">1278</td>
<td style="text-align: right;">15</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Quneitra</td>
<td style="text-align: right;">87</td>
<td style="text-align: right;">1</td>
</tr>
<tr class="even">
<td style="text-align: left;">Rif Dimashq</td>
<td style="text-align: right;">2831</td>
<td style="text-align: right;">33</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Tartus</td>
<td style="text-align: right;">785</td>
<td style="text-align: right;">9</td>
</tr>
</tbody>
</table>
</div>
</div>
</figure>
</div>
</div>
<p>If Syria were to use closed or open party lists to allocate seats between competing parties, and if the seat allocation were as I have suggested it might be, we might expect the largest party to win around (16.7 * 250)^(-1/8) = 35% of the seats <em>in equilibrium</em>.</p>
<p>Generally post-war elections are not “in equilibrium”, and elections in the region have seen hyper-fragmentation due to a large number of independents or micro-parties. The actual seat share of the largest party could be lower or indeed higher (if a large number of votes are cast for parties which do not win seats).</p>
<p>Although our knowledge of the consequences of electoral systems is never exact, using the existing number of districts, and allocating seats to those districts before the completion of a national census, would be a reasonable basis for free and fair elections within the next year or eighteen months rather than four years.</p>



 ]]></description>
  <category>elections</category>
  <guid>http://www.chrishanretty.co.uk/posts/syrian_election/</guid>
  <pubDate>Sat, 11 Jan 2025 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Unitarisation and learning to vote without staggering</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/staggered_elections/</link>
  <description><![CDATA[ 





<section id="introduction" class="level1">
<h1>Introduction</h1>
<p>Earlier this month the Labour government published a <a href="https://www.gov.uk/government/publications/english-devolution-white-paper-power-and-partnership-foundations-for-growth/english-devolution-white-paper">white paper on English devolution</a>.</p>
<p>Perhaps fittingly for a White Paper released in December, the government invited turkeys to vote for Christmas. The government announced that it will invite proposals for two-tier areas (areas with a district council and a county council) to become unitary areas (areas with a single council), a process known as “unitarisation”.</p>
<p>“Unitarisation” has implications for local government finances and for local democracy.</p>
<p>As far as finances are concerned, unitary authorities are <a href="https://www.countycouncilsnetwork.org.uk/new-analysis-reveals-that-single-unitary-councils-could-deliver-3bn-saving-over-five-years-and-maximise-the-benefits-of-economic-growth-and-housing-policy/">probably cheaper</a>, but even if you believe PwC this depends on how many unitary authorities are created from each existing two-tier area.</p>
<p>The question as to whether unitarisation is good or bad for local democracy is harder to answer, and depends on some <a href="https://g.co/kgs/x3xKdxp">classic issues in democratic theory</a>.</p>
<p>Take <a href="https://en.wikipedia.org/wiki/North_Yorkshire_Council">North Yorkshire unitary authority</a> as an example. This new unitary authority has 90 councillors. There were formerly 229 district councillors serving this area together with 72 county councillors. Before there was one representative for roughly every two thousand people. Now there is one representative for roughly every seven thousand people.<sup>1</sup></p>
<p>If you live in North Yorkshire, your elected representatives are metaphorically further away from you. Additionally, a majority in your former district council area might now be outvoted by representatives of other areas in the new combined area. I don’t know enough about intra-Yorkshire politics to say whether every other area will gang up on Richmondshire, but it <a href="https://www.itv.com/news/2015-09-11/david-cameron-caught-saying-yorkshire-people-hate-each-other">seems possible</a>.</p>
<p>These issues of access to elected representatives and the risk of becoming a minority within a larger decision-making unit are serious issues. That’s true whether we’re talking about English local government or qualified majority voting in the European Union. Opposition to unitarisation need not be a knee-jerk reaction.</p>
<p>At the same time, however, the degree of local democracy depends not just on the existence of formally democratic tiers, but on the powers that those tiers have and the recognition afforded them. The fact that some areas in England are <a href="https://en.wikipedia.org/wiki/Unparished_area">“unparished areas”</a> and some areas are “parished areas” is not seen as a great source of democratic inequality, because parish councils have limited powers and are not something people pay much attention to.</p>
<p>The White Paper – in what I can only describe as the gamification of local government reform – sets out a tiered set of extra powers that can be “unlocked” by councils at different levels. This might mean that some powers move from Westminster to local authorities. This might provide one response to the argument that unitarisation worsens local democracy. Another response comes from one potentially unforeseen consequence of unitarisation: the end of election by thirds.</p>
</section>
<section id="staggered-elections" class="level1">
<h1>Staggered elections</h1>
<p>In just over a quarter of English councils, councillors are elected in <strong>staggered elections</strong> where (usually) one third of the council is elected every year, with the final year in a four year cycle seeing no elections.</p>
<p>Over the past twenty years, a number of councils have moved from staggered election by thirds to whole council or “all-out” elections. As far as I am aware, only one council has ever moved from whole council elections to election by thirds: in 2004, Castle Point in Essex made the switch, only to <a href="https://consultation.castlepoint.gov.uk/corporate-policy/election-cycle-consultation/">switch back</a> this year.</p>
<p>Castle Point Council, in a consultation document inviting local residents’ views on switching to whole council elections, provided a list of reasons for and against the switch. One of the reasons in favour of switching was that</p>
<blockquote class="blockquote">
<p>“The results from whole-council elections are simpler and more easily understood by the electorate. <em>This may increase turn-out at local elections.</em>” (emphasis added)</p>
</blockquote>
<p>Governments and politicians don’t always internalize the lessons of political science research, but this view is supported by research on the frequency of elections and turnout.</p>
<ul>
<li><a href="https://doi.org/10.1177/00104140231169020">Filip Kostelka, Eva Krejcova, Nicolas Sauger and Alexander Wuttke</a>) have shown that turnout in the general election of 2017 was lower in areas which had held local elections five weeks previously. This finding backs up their main finding (based on cross-national panel data) that the number of elections in a five year window is negatively associated with turnout.</li>
<li><a href="https://doi.org/10.1016/S0261-3794(01)00047-6">Colin Rallings, Michael Thrasher and Galina Borisyuk</a> have shown that turnout in local authority by-elections is lower the less time has elapsed since the main council elections</li>
</ul>
<p>Rallings, Thrasher and Borisyuk in particular treat the frequency of irregular by-elections as an illustration of a general point:</p>
<blockquote class="blockquote">
<p>“One piece of evidence from British elections is the relative level of electoral turnout in the 32 London boroughs, which have whole council elections every four years, compared with that in the 36 metropolitan boroughs covering the major English conurbations outside London, which elect a third of their council membership annually. The two types of authority are responsible for the same local services, but the level of turnout is consistently higher in London. However, when general election turnout is examined the reverse position applies, with participation consistently higher in the metropolitan boroughs… A crucial factor in explaining these differences is likely to be that electors in the London boroughs are determining the composition of their council whereas their <strong>counterparts in the metropolitan boroughs will often be unable to effect a change in control however they cast their votes</strong>. Nonetheless, we should not ignore the possibility that <strong>the greater frequency with which electors in the metropolitan boroughs are expected to vote may also be a contributory factor</strong> to the differences in turnout” (emphasis added)</p>
</blockquote>
<p>This paragraph nicely illustrates the two ways in which staggered elections can cause changes in turnout: by reducing the stakes (only one third of the council is at play) and by increasing election frequency. Of course, when term length is fixed, then increasing election frequency necessarily means reducing the stakes, and so some questions about mechanisms are moot in the English local government context.</p>
</section>
<section id="staggered-elections-and-unitarisation" class="level1">
<h1>Staggered elections and unitarisation</h1>
<p>Staggered elections are found in a variety of English councils. Where there are staggered elections, councillors are usually elected in thirds, but a couple of weirdo councils (hello Oxford!) elect by halves.</p>
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="http://www.chrishanretty.co.uk/posts/staggered_elections/index_files/figure-html/unnamed-chunk-1-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>Staggered elections aren’t only found in district councils. In fact, it’s metropolitan boroughs which are the most frequent users of this election type.</p>
<p>However when district councils have <em>unitarised</em>, the resulting unitary authorities tend to adopt all-out elections. For example: although two former councils in the North Yorkshire unitary council area (Craven and Harrogate) were elected by thirds, the new unitary council is elected in an all-out election. Similarly in Cumberland, although Carlisle elected by thirds the unitary council is elected in all-out elections.</p>
<p>Unitarisation might therefore reduce the number of councils electing by thirds, because no one choosing a new electoral system from scratch now seems to choose election by thirds.<sup>2</sup> Although the government’s broader plans might include incentives for metropolitan boroughs to move away from election by thirds, it is far easier to choose a system for a new institution than change a system for an existing institution. Unitarisation won’t eliminate election by thirds, but it will likely make it less common.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="http://www.chrishanretty.co.uk/posts/staggered_elections/drake_machiavelli.webp" class="img-fluid figure-img"></p>
<figcaption>The Drake/Machiavelli crossover is here</figcaption>
</figure>
</div>
</section>
<section id="all-out-elections-and-turnout" class="level1">
<h1>All-out elections and turnout</h1>
<p>So far all I’ve shown you is that some district councils use staggered elections, and that there are good reasons from other political science studies to think that this damages turnout. Now I’m going to go one step beyond, and try and estimate <em>how much</em> moving to all-out elections could boost turnout, using data from English local elections.</p>
<p>The data I’m using mostly comes from successive editions of the Rallings/Thrasher <a href="https://www.electionscentre.co.uk/?page_id=2278">Local Elections Handbook</a>; more recent data comes from the Electoral Commission or the <a href="https://commonslibrary.parliament.uk/2023-local-elections-handbook-and-dataset/">handbooks jointly produced</a> by Rallings/Thrasher and the House of Commons library. The turnout figures here are “ballot box turnout figures”, which includes ballots which were rejected at the count. The data covers from the period from 1991 to 2023; I’m not aware of a good complete source for turnout in the 2024 local elections. You can download the data in CSV format <a href="https://gist.github.com/chrishanretty/2e76754aebbf1bbaf7f13784ab66b82e">here</a>.</p>
<p>The data includes information on the type of election: whole, thirds, or halves. This applies to the current election, rather than the general scheme of elections used by that council. As a result, councils can have “whole council” elections for two reasons:</p>
<ul>
<li>they generally have whole council elections;</li>
<li>they generally have staggered elections, but have had to hold whole council elections as a result of boundary changes</li>
</ul>
<p>Whole council elections which were held just because of boundary changes are marked in the column <code>whole_bc_redistr</code>.</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-scatter" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-scatter-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/staggered_elections/index_files/figure-html/fig-scatter-1.png" class="img-fluid figure-img" style="width:100.0%">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-scatter-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: A scatter-plot showing election turnout on the vertical axis as a function of year (horizontal axis), election frequency (colour of plotted points), and type of local council (shape)
</figcaption>
</figure>
</div>
</div>
</div>
<p>Figure&nbsp;1 shows my attempt to plot the raw data. You’ll see peaks in election years (1997, 2001, 2005, 2010, and 2015). I’ve also overlaid three trend lines for the different election frequencies. These trend lines all share the same pattern over time, but they’re shifted up or down to best fit the pattern for the different election frequencies. The trend line for “whole council” elections is around four percentage points higher than the trend line for election by thirds. However, the higher turnout in these elections might be the result of the <em>type</em> of places which have these kinds of elections. What we really need are changes <em>within</em> councils.</p>
<p>We can estimate changes within councils by fitting a two-way fixed effects regression model. In TWFE models, we allow each year to affect turnout in its own unique way, and each unit (here, councils) to affect turnout in its own unique way. These year and unit fixed effects are nuisance parameters that we don’t really care about. What we do care about are the effects of other variables – in our case, the effects of election frequency.</p>
<p>If councils only ever held elections at the one frequency, then we wouldn’t be able to disentangle the council-specific effects from the effects of election frequency – but enough councils have changed election frequency over time to allow us to estimate some effects.</p>
<p>Any other things which might effect turnout – the presence of police and crime commissioner elections, concurrent European Parliament elections, postal vote trials, the changing quality of governance in the council – are either ignored or wrapped up into the year fixed effects.</p>
<div class="cell">
<div id="tbl-regression" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-regression-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;1: Regression models of turnout in English local authorities, 19991 to 2023. Ninety five percent confidence interval shown in parentheses.
</figcaption>
<div aria-describedby="tbl-regression-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_rqrtej9h9s0ohlic8wt2(i, j, css_id) {
          var table = document.getElementById("tinytable_rqrtej9h9s0ohlic8wt2");
          var cell = table.rows[i]?.cells[j];  // Safe navigation to avoid errors
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function insertSpanRow(i, colspan, content) {
        var table = document.getElementById('tinytable_rqrtej9h9s0ohlic8wt2');
        var newRow = table.insertRow(i);
        var newCell = newRow.insertCell(0);
        newCell.setAttribute("colspan", colspan);
        // newCell.innerText = content;
        // this may be unsafe, but innerText does not interpret <br>
        newCell.innerHTML = content;
      }
      function spanCell_rqrtej9h9s0ohlic8wt2(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_rqrtej9h9s0ohlic8wt2");
        const targetRow = table.rows[i];
        const targetCell = targetRow.cells[j];
        for (let r = 0; r < rowspan; r++) {
          // Only start deleting cells to the right for the first row (r == 0)
          if (r === 0) {
            // Delete cells to the right of the target cell in the first row
            for (let c = colspan - 1; c > 0; c--) {
              if (table.rows[i + r].cells[j + c]) {
                table.rows[i + r].deleteCell(j + c);
              }
            }
          }
          // For rows below the first, delete starting from the target column
          if (r > 0) {
            for (let c = colspan - 1; c >= 0; c--) {
              if (table.rows[i + r] && table.rows[i + r].cells[j]) {
                table.rows[i + r].deleteCell(j);
              }
            }
          }
        }
        // Set rowspan and colspan of the target cell
        targetCell.rowSpan = rowspan;
        targetCell.colSpan = colspan;
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: 6, j: 3 }, { i: 6, j: 2 }, { i: 6, j: 1 }, { i: 6, j: 4 },  ], css_id: 'tinytable_css_wz03us0wqyloie8k8oii',}, 
          { positions: [ { i: 4, j: 1 }, { i: 4, j: 4 }, { i: 4, j: 3 }, { i: 4, j: 2 },  ], css_id: 'tinytable_css_dha3bwazj58f3wnvov6m',}, 
          { positions: [ { i: 1, j: 2 }, { i: 1, j: 1 }, { i: 2, j: 1 }, { i: 3, j: 1 }, { i: 5, j: 2 }, { i: 5, j: 1 }, { i: 3, j: 2 }, { i: 1, j: 3 }, { i: 2, j: 3 }, { i: 2, j: 2 }, { i: 1, j: 4 }, { i: 5, j: 3 }, { i: 3, j: 4 }, { i: 3, j: 3 }, { i: 5, j: 4 }, { i: 2, j: 4 },  ], css_id: 'tinytable_css_5ur3ifdugpl008ispqr7',}, 
          { positions: [ { i: 0, j: 1 }, { i: 0, j: 4 }, { i: 0, j: 3 }, { i: 0, j: 2 },  ], css_id: 'tinytable_css_6kyq0ccmlve7hqoepltt',}, 
          { positions: [ { i: 6, j: 0 },  ], css_id: 'tinytable_css_6nqbd9ysuq05ev31as0f',}, 
          { positions: [ { i: 4, j: 0 },  ], css_id: 'tinytable_css_cr1h6c9jljycacv7ihrc',}, 
          { positions: [ { i: 1, j: 0 }, { i: 2, j: 0 }, { i: 3, j: 0 }, { i: 5, j: 0 },  ], css_id: 'tinytable_css_z62kd65eo8oetj4h8y6k',}, 
          { positions: [ { i: 0, j: 0 },  ], css_id: 'tinytable_css_g7n133v7tpuixjup26ov',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_rqrtej9h9s0ohlic8wt2(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_wz03us0wqyloie8k8oii, .table th.tinytable_css_wz03us0wqyloie8k8oii { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_dha3bwazj58f3wnvov6m, .table th.tinytable_css_dha3bwazj58f3wnvov6m { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_5ur3ifdugpl008ispqr7, .table th.tinytable_css_5ur3ifdugpl008ispqr7 { text-align: center; }
      .table td.tinytable_css_6kyq0ccmlve7hqoepltt, .table th.tinytable_css_6kyq0ccmlve7hqoepltt { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_6nqbd9ysuq05ev31as0f, .table th.tinytable_css_6nqbd9ysuq05ev31as0f { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_cr1h6c9jljycacv7ihrc, .table th.tinytable_css_cr1h6c9jljycacv7ihrc { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_z62kd65eo8oetj4h8y6k, .table th.tinytable_css_z62kd65eo8oetj4h8y6k { text-align: left; }
      .table td.tinytable_css_g7n133v7tpuixjup26ov, .table th.tinytable_css_g7n133v7tpuixjup26ov { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_rqrtej9h9s0ohlic8wt2" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col"> </th>
                <th scope="col">(0)</th>
                <th scope="col">(1)</th>
                <th scope="col">(2)</th>
                <th scope="col">(3)</th>
              </tr>
        </thead>
        <tfoot><tr><td colspan="5">Model (0) includes no controls. Model (1) includes year and council fixed effects. Model (2) is like model (1) but without all-out elections which required by redistricting. Model (3) is like model (2) but also excludes 2004 elections</td></tr></tfoot>
        <tbody>
                <tr>
                  <td>Election by halves (v. thirds)</td>
                  <td>0.978</td>
                  <td>0.284</td>
                  <td>0.269</td>
                  <td>0.609</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[-1.598, 3.554]</td>
                  <td>[-0.861, 1.429]</td>
                  <td>[-0.913, 1.451]</td>
                  <td>[-0.591, 1.808]</td>
                </tr>
                <tr>
                  <td>All-out elections (v. thirds)</td>
                  <td>4.644</td>
                  <td>1.296</td>
                  <td>0.864</td>
                  <td>0.901</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[4.069, 5.219]</td>
                  <td>[0.879, 1.712]</td>
                  <td>[0.193, 1.535]</td>
                  <td>[0.228, 1.574]</td>
                </tr>
                <tr>
                  <td>Num.Obs.</td>
                  <td>5337</td>
                  <td>5337</td>
                  <td>5131</td>
                  <td>5044</td>
                </tr>
                <tr>
                  <td>R2</td>
                  <td>0.045</td>
                  <td>0.915</td>
                  <td>0.918</td>
                  <td>0.920</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</figure>
</div>
</div>
<p>Table&nbsp;1 shows the results of four different regression models of turnout in English local elections. The zero-th model includes no control variables at all, and just shows what was previously shown in Figure&nbsp;1: that councils which hold all-out elections have turnout which is slightly moer than four points higher than councils which hold elections by-thirds.</p>
<p>Model (1) then goes on to include controls for year and the council. Under certain assumptions,<sup>3</sup> we can now start speaking of the “effect” of all-out elections, compared to election by thirds. This first estimate of the effect suggests that moving to all out elections increases turnout by around 1.3 percentage points. This is quite a big effect. It’s around one quarter of the within-year standard deviation in turnout between councils. It’s also around the same size as the <a href="https://hollodec.github.io/2024/07/09/voterid.html">negative effect of general election turnout</a> as a result of the new voter identification laws. However, since local election turnout is lower than general election turnout, the effect is proportionately bigger.</p>
<p>It’s true that the effect does drop a little bit when we drop some observations which we might think, for various reasons, to be problematic. Model (2) drops cases where a council held all-out elections required by redistricting. Our best estimate of the effect is now less than a percentage point. However, the difference between these two estimates isn’t itself significant: the confidence interval now runs between 0.2 percentage points and 1.5 percentage points, and so includes the point estimate from Model (1). When we drop turnout levels in 2004, which might have been affected by all-postal voting trials, the estimate goes back up a little, but by such a small amount relative to the degree of uncertainty that it’s really not worth reporting.</p>
<p>This suggests to me that moving to all-out elections would boost turnout, compared to election by thirds – and that if unitarisation involves getting rid of election by thirds then that might be something to be said in its favour.</p>
</section>
<section id="conclusion" class="level1">
<h1>Conclusion</h1>
<p>Even people who think about local government reform probably don’t think first of its effects on turnout. However, <em>someone</em> probably should. For the last four years for which there is consistent data (2019 to 2023), turnout has been below fifty percent <strong>in every local authority area</strong>. I don’t know whether <a href="https://ukandeu.ac.uk/how-can-starmer-deliver-mission-driven-government/">mission-led government</a> is the same as government by target – but it would be nice to think of a mission to boost turnout. What would it take to bring turnout in local elections over fifty percent, what would that cost, and what trade-offs might be involved?</p>


</section>


<div id="quarto-appendix" class="default"><section id="footnotes" class="footnotes footnotes-end-of-document"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>

<ol>
<li id="fn1"><p>The population of the North Yorkshire unitary authority area is 623,501; this population divided by 229 + 72 is 2,071. The same population divided by 90 is 6,928.↩︎</p></li>
<li id="fn2"><p><a href="@rogergiess.bsky.social"><span class="citation" data-cites="rogergiess.bsky.social">@rogergiess.bsky.social</span></a> points out that this was not true of an earlier wave of unitary authorities like Portsmouth, Thurrock and Reading which kept the district pattern of election by thirds.↩︎</p></li>
<li id="fn3"><p>That is, the usual assumptions for difference-in-difference analysis plus additional assumptions involving homogeneity of treatment effects and the absence of dynamic treatment effects required by the fact that we have staggered adoption and moves <em>in</em> and <em>out</em> of treatment. If you want to run the latest diff-in-diff estimator, be my guest. The difference between a blog post and an academic article, and it involves twenty pages of appendices and alternative estimators and data subsets.↩︎</p></li>
</ol>
</section></div> ]]></description>
  <category>elections</category>
  <category>local government</category>
  <guid>http://www.chrishanretty.co.uk/posts/staggered_elections/</guid>
  <pubDate>Fri, 20 Dec 2024 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Assembly sizes are biased towards divisibility</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/divisibility/</link>
  <description><![CDATA[ 





<section id="what-plato-wrote" class="level1">
<h1>What Plato wrote</h1>
<p>In <a href="https://classics.mit.edu/Plato/laws.5.v.html">book V of his Laws</a> – helpfully summarized by the <a href="https://iep.utm.edu/pla-laws/">Internet Encyclopedia of Philosophy</a> as “Plato’s last, longest, and, perhaps, most loathed work”, Plato claimed that there was an ideal number of citizens for a polity, and justified this on unusual grounds:</p>
<blockquote class="blockquote">
<p>“The number of our citizens shall be 5040 – this will be a convenient number; and these shall be owners of the land and protectors of the allotment… Every legislator ought to know so much arithmetic as to be able to tell what number is most likely to be useful to all cities; and we are going to take that number which contains the greatest and most regular and unbroken series of divisions. The whole of number has every possible division, and the number 5040 can be divided by exactly fifty-nine divisors, and ten of these proceed without interval from one to ten: this will furnish numbers for war and peace, and for all contracts and dealings, including taxes and divisions of the land. These properties of number should be ascertained at leisure by those who are bound by law to know them; for they are true, and should be proclaimed at the foundation of the city, with a view to use” (Jowett translation)</p>
</blockquote>
<p>Plato’s claims about the number 5040 are still true today. There are fifty-nine divisors of 5,040 if we exclude the number itself, and 5,040 is divisible by two, three, four, … all the way up to ten. It’s a highly divisible number, and more particularly a <a href="https://en.wikipedia.org/wiki/Highly_composite_number">highly composite number</a>.</p>
<p>Although Plato’s claims about the number 5,040 are still true, the relevance of these claims is almost nil. Plato’s views about citizenship are abhorrent today; there are no self-governing polities with so few citizens;<sup>1</sup> and almost all self-governing polities rely on representation rather than direct participation in the work of government.</p>
<p>If we want to take what is good from Plato, and work out what numbers are “most likely to be useful to all cities”, we can take this property of <em>divisibility</em> and apply it not to the number of citizens, but to the number of legislators. Plato himself did this: he proposes <a href="https://classics.mit.edu/Plato/laws.6.vi.html">in book VI</a> that any colony have a council of 360, which “will be a convenient number for sub-division” and which, like 5,040, is highly divisible (23 divisors) and highly composite.</p>
</section>
<section id="victorian-number-generator" class="level1">
<h1>Victorian number generator</h1>
<p>I was thinking about Plato thanks to a recent trip to <del>Terra Australis</del> Australia, where the Parliament of Victora is <a href="https://www.parliament.vic.gov.au/electoralsysteminquiry">reviewing electoral arrangements</a> for its upper chamber, the Legislative Council.</p>
<p>Two parts of the review concern the size of the Legislative Council and the number of electoral districts. At present, the Legislative Council has 40 members, or roughly four-ninths the size of the Legislative Assembly, which has 88 members. The forty members of the Legislative Council are elected in eight districts, each with a district magnitude of five.</p>
<p>Considering first the size of the Legislative Council, the ratio between the Council and the Assembly is very slightly greater than the ratio between most upper chambers and their lower chambers. In general, upper chambers are around 40% the size of the corresponding lower chamber.</p>
<p>You can see that in Figure&nbsp;1, which uses data from the <a href="https://data.ipu.org/compare/">International Parliamentary Union</a> showing lower chamber size on the horizontal axis against upper chamber size on the vertical axis. The dotted line gives the best-fitting line according to <a href="https://en.wikipedia.org/wiki/Ordinary_least_squares">ordinary least squares</a>; the solid line shows the line where the size of the upper chamber is equal to the size of the lower chamber. The Legislative Council is slightly above the trend line, but still well within the confidence interval of the associated linear regression.</p>
<div class="cell" data-fig="true">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1">ipu_download <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"compare--statutory_members_number--2024--export--241118-011132--EN.csv"</span></span>
<span id="cb1-2"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.exists</span>(ipu_download)) {</span>
<span id="cb1-3">    dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(ipu_download) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-4">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(Status <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Suspended"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-5">        dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">iso2c =</span> ISO.Code,</span>
<span id="cb1-6">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Members =</span> Statutory.number.of.members,</span>
<span id="cb1-7">                      Chamber.type) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-8">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Chamber.type =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(Chamber.type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-"</span>,</span>
<span id="cb1-9">                                     <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Lower chamber"</span>,</span>
<span id="cb1-10">                                     <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(Chamber.type))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-11">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pivot_wider</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">names_from =</span> Chamber.type,</span>
<span id="cb1-12">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values_from =</span> Members) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-13">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>()</span>
<span id="cb1-14">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb1-15">    </span>
<span id="cb1-16">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">structure</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">iso2c =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AL"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DZ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AO"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AG"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AR"</span>,</span>
<span id="cb1-17"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AM"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AU"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AT"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AZ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BS"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BH"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BB"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BY"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BZ"</span>,</span>
<span id="cb1-18"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BJ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BT"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BO"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BA"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BW"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BR"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BN"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BG"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BF"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BI"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV"</span>,</span>
<span id="cb1-19"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"KH"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CM"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CA"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CF"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CL"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CN"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CO"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"KM"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CG"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CR"</span>,</span>
<span id="cb1-20"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CI"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"HR"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CU"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CY"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CZ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"KP"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DK"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DJ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DM"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DO"</span>,</span>
<span id="cb1-21"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"EC"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"EG"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SV"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GQ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ER"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"EE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SZ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ET"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FJ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FI"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FR"</span>,</span>
<span id="cb1-22"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GA"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GM"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GH"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GR"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GT"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GN"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GW"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GY"</span>,</span>
<span id="cb1-23"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"HT"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"HN"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"HU"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IS"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IN"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ID"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IR"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IQ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IL"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"IT"</span>,</span>
<span id="cb1-24"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"JM"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"JP"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"JO"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"KZ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"KE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"KI"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"KW"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"KG"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LA"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LV"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LB"</span>,</span>
<span id="cb1-25"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LS"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LR"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LY"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LI"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LT"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LU"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MG"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MW"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MY"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MV"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ML"</span>,</span>
<span id="cb1-26"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MT"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MH"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MR"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MU"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MX"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FM"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MC"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MN"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ME"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MA"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MZ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NA"</span>,</span>
<span id="cb1-27"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NR"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NP"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NL"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NZ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NI"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NG"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MK"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NO"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OM"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PK"</span>,</span>
<span id="cb1-28"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PW"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PA"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PG"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PY"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PH"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PL"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PT"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"QA"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"KR"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MD"</span>,</span>
<span id="cb1-29"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"RO"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"RU"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"RW"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"KN"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LC"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"VC"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"WS"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SM"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ST"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SA"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SN"</span>,</span>
<span id="cb1-30"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"RS"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SC"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SL"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SG"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SK"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SI"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SB"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SO"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ZA"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SS"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ES"</span>,</span>
<span id="cb1-31"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"LK"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SR"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CH"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SY"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TJ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TH"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TL"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TG"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TO"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TT"</span>,</span>
<span id="cb1-32"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TN"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TR"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TM"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TV"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UG"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UA"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GB"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TZ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"US"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UY"</span>,</span>
<span id="cb1-33"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UZ"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"VU"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"VE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"VN"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"YE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ZM"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ZW"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Lower chamber</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">140</span>L,</span>
<span id="cb1-34"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">407</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">28</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">220</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">18</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">257</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">107</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">151</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">183</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">125</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">39</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">350</span>L,</span>
<span id="cb1-35"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">110</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">32</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">109</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">47</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">130</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">42</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">69</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">513</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">45</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">240</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">71</span>L,</span>
<span id="cb1-36"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">123</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">72</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">125</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">180</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">338</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">140</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">203</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">155</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3000</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">187</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">24</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">151</span>L,</span>
<span id="cb1-37"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">57</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">255</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">151</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">470</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">687</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">179</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">65</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">32</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">190</span>L,</span>
<span id="cb1-38"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">137</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">596</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">101</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">74</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">547</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">55</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">577</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">98</span>L,</span>
<span id="cb1-39"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">58</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">598</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">275</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">160</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">81</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">102</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">69</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">119</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">128</span>L,</span>
<span id="cb1-40"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">199</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">63</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">545</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">580</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">290</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">329</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">160</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">120</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">400</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">63</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">465</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">138</span>L,</span>
<span id="cb1-41"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">98</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">350</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">45</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">65</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">164</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">128</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">122</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">73</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>L,</span>
<span id="cb1-42"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">141</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">163</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">193</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">223</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">93</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">147</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">65</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">33</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">176</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">66</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>L,</span>
<span id="cb1-43"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">24</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">126</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">81</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">395</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">250</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">104</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">19</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">275</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">120</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">91</span>L,</span>
<span id="cb1-44"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">171</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">360</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">123</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">169</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">336</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">71</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">118</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">130</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">316</span>L,</span>
<span id="cb1-45"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">460</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">230</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">45</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">101</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">330</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">450</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">18</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">22</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">51</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>L,</span>
<span id="cb1-46"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">55</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">151</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">165</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">250</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">35</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">149</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">104</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">275</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">400</span>L,</span>
<span id="cb1-47"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">550</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">350</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">225</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">51</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">349</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">250</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">63</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">65</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">113</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>L,</span>
<span id="cb1-48"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">42</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">161</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">125</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">529</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">450</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">650</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">393</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">435</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">99</span>L,</span>
<span id="cb1-49"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">52</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">167</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">500</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">301</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">167</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">280</span>L), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Upper chamber</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb1-50"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">174</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">72</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">76</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">21</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">65</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>L,</span>
<span id="cb1-51"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">36</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">81</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">39</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">62</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">105</span>L,</span>
<span id="cb1-52"><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">108</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">72</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">99</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">81</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">109</span>L,</span>
<span id="cb1-53"><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">32</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">70</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">153</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">348</span>L,</span>
<span id="cb1-54"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">70</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">69</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">245</span>L,</span>
<span id="cb1-55"><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">205</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">21</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">248</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">69</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">68</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb1-56"><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">33</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">18</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">70</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb1-57"><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">128</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">120</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">42</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">59</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">75</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb1-58"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">109</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">87</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">96</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">45</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">24</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb1-59"><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">136</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">170</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">26</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb1-60"><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">54</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">265</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">46</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">33</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb1-61"><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">32</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">77</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">800</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">31</span>L, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>L,</span>
<span id="cb1-62"><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">111</span>L, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">80</span>L)),</span>
<span id="cb1-63"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">190</span>L),</span>
<span id="cb1-64"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">class =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"data.frame"</span>)</span>
<span id="cb1-65">}</span>
<span id="cb1-66"></span>
<span id="cb1-67"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Let's drop the 3,000 member chamber</span></span>
<span id="cb1-68">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-69">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Lower chamber</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3000</span>)</span>
<span id="cb1-70"></span>
<span id="cb1-71"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(dat,</span>
<span id="cb1-72">       <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Lower chamber</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>,</span>
<span id="cb1-73">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Upper chamber</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-74">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-75">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formula =</span> y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> x,</span>
<span id="cb1-76">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>,</span>
<span id="cb1-77">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb1-78">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#df691a"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-79">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">limits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">700</span>),</span>
<span id="cb1-80">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expansion</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-81">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">limits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">800</span>),</span>
<span id="cb1-82">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expansion</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-83">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### geom_abline(color = "#df691a") +</span></span>
<span id="cb1-84">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_textabline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#df691a"</span>,</span>
<span id="cb1-85">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Upper chamber size equals Lower chamber size"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-86">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"point"</span>,</span>
<span id="cb1-87">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>,</span>
<span id="cb1-88">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">88</span>,</span>
<span id="cb1-89">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">44</span>,</span>
<span id="cb1-90">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5cb85c"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-91">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>,</span>
<span id="cb1-92">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">88</span>,</span>
<span id="cb1-93">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">144</span>,</span>
<span id="cb1-94">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb1-95">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb1-96">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Victoria</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Leg. Council"</span>,</span>
<span id="cb1-97">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5cb85c"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-98">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"curve"</span>,</span>
<span id="cb1-99">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">48</span>,</span>
<span id="cb1-100">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">140</span>,</span>
<span id="cb1-101">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">88</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb1-102">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">44</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb1-103">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb1-104">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb1-105">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">arrow =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrow</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">length =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unit</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"npc"</span>)),</span>
<span id="cb1-106">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5cb85c"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb1-107">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_dark</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-108">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0f2537"</span>,</span>
<span id="cb1-109">                                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>),</span>
<span id="cb1-110">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#2b3e50"</span>),</span>
<span id="cb1-111">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>),</span>
<span id="cb1-112">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>))</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div id="fig-regression" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-regression-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/divisibility/index_files/figure-html/fig-regression-1.png" class="img-fluid figure-img" width="864">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-regression-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: A scatter plot of lower chamber size (horizontal axis) against upper chamber size (vertical axis), with the position of the Victorian Assembly highlighted. The sole dot above the solid line is the part-time House of Lords.
</figcaption>
</figure>
</div>
</div>
</div>
<p>How does the size of the legislative council interact with the size of the districts? <em>If</em> you want equal sized districts (and that’s a big if), then the total size of the Legislative Council sets limits on how many regions you can have. If you have 40 members, then you can have eight districts each of five members, or five districts of eight members, but you can’t have six evenly sized districts or seven evenly sized districts. If you had the <a href="https://en.wikipedia.org/wiki/Twin_prime">twin primes</a> (39 or 41 members), you wouldn’t be able to have evenly sized districts at all.</p>
<p>(Having evenly sized districts isn’t a necessary criterion, but the <a href="https://www.parliament.vic.gov.au/electoralsysteminquiry">discussion paper</a> which accompanies the review is mostly illustrated with even-sized districts, and the impact of variation in district magnitude upon system properties is in my view still an open question.)</p>
<p>Since you can change districts more easily than you can change the number of members of a legislature, it seems like we should choose the size of the legislature so it’s appropriate (is smaller than the lower chamber by some commonly found ratio) and permits lots of possible divisions.</p>
<p>In the case of the Victorian Legislative Council, a chamber with 36 members would more closely approximate the ratio found amongst national upper chambers (36/88 <img src="https://latex.codecogs.com/png.latex?%5Capprox"> 40%), and is highly divisible, allowing evenly-sized districts with 1, 2, 3, 4, 6, 9, 12, or 18 members, or eight different options. Indeed 36 is not only highly divisible in the sense of having a lot of divisors for a number its size, it’s highly composite. This means that a assembly size of 36 allows more flexibility than a legislative council of 40, which allows evenly sized districts with 1, 2, 4 5, 8, 10 and 20 members, or seven different options.</p>
</section>
<section id="its-all-a-bit-odd" class="level1">
<h1>It’s all a bit odd</h1>
<p>Perhaps this property of divisibility strikes you as verging into numerology. I’m certainly not aware that anyone has analysed how easily legislative assemblies can be divided. The only remotely similar property I’ve heard discussed is oddness and evenness, where there is an argument for having <em>odd-sized</em> chambers.</p>
<p>The argument goes like this: that democracy is about majority rule, and in an odd-sized chamber there will always be a majority if votes are binary votes and if abstentions are not allowed. By contrast, in an even-sized chamber there might be a tie. There are therefore some circumstances in which even-sized chambers fail to identify a majority either in favour or in opposition to some proposal. If a tie leads to failure of a motion, then this creates an anti-democratic bias towards the status quo, with the size of the bias depending on how big the chamber is and how often controversial issues will be finely balanced.</p>
<p>At least one parliament was designed explicitly to have an odd number of members and thereby prevent a tie. In the <a href="https://en.wikipedia.org/wiki/1973_Swedish_general_election">1973 election to the Swedish Riksdag</a>, government and opposition forces both won 175 of 350 seats. The number of seats was changed to 349 for the following 1976 election.<sup>2</sup></p>
<p>Unfortunately, it seems that no one is paying attention to the Swedish experience. Most legislative chambers have an even number of members, as Figure&nbsp;2 shows. This figure uses the same IPU data used to plot Figure&nbsp;1, except that this time I include all chambers, whether or not the system is unicameral or bicameral, and I drop the Chinese National People’s Congress, because it’s absolutely huge.</p>
<div class="cell" data-fig="true">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">all_chambers <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Lower chamber</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>, dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Upper chamber</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>)</span>
<span id="cb2-2">plot_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tribble</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>comparison, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>parity, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>proportion,</span>
<span id="cb2-3">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"All chambers"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Even"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(all_chambers <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%%</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb2-4">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"All chambers"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Odd"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(all_chambers <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%%</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb2-5">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Lower chambers"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Even"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Lower chamber</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%%</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb2-6">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Lower chambers"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Odd"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Lower chamber</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%%</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb2-7">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Upper chambers"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Even"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Upper chamber</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%%</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb2-8">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Upper chambers"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Odd"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Upper chamber</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%%</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>))</span>
<span id="cb2-9"></span>
<span id="cb2-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(plot_df,</span>
<span id="cb2-11">       <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> parity,</span>
<span id="cb2-12">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> proportion,</span>
<span id="cb2-13">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> parity)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-14">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_discrete</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Parity"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-16">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Proportion of legislatures"</span>,</span>
<span id="cb2-17">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> scales<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>percent) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#df691a"</span>,</span>
<span id="cb2-19">                                     colorspace<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lighten</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#df691a"</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)),</span>
<span id="cb2-20">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">guide =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb2-21">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>comparison, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nrow =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb2-23">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-24">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_dark</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0f2537"</span>,</span>
<span id="cb2-26">                                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>),</span>
<span id="cb2-27">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#2b3e50"</span>),</span>
<span id="cb2-28">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>),</span>
<span id="cb2-29">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>))    </span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div id="fig-parity" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-parity-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/divisibility/index_files/figure-html/fig-parity-1.png" class="img-fluid figure-img" width="864">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-parity-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;2: Proportions of chambers that are odd- or even-sized, according to chamber type.
</figcaption>
</figure>
</div>
</div>
</div>
<p>The preference for even-sized assemblies is not overwhelming, but it is a bit more pronounced amongst upper chambers, where almost three out of every five chambers have an even number of members. Although having an odd number of members might help prevent ties, having an even number of members does help with Plato’s concern of divisibility. I’ll look at divisibility now.</p>
</section>
<section id="a-house-divided" class="level1">
<h1>A house divided</h1>
<p>When we looked at whether odd- or even-sized chambers are preferred, we could calculate whether each individual chamber has an odd or even number of members, and then compare that to the expected proportion of even and odd numbers. That proportion is constant, at fifty percent.</p>
<p>When we look at divisibility, it’s not so clear what we’re supposed to compare to. We can calculate the number of divisors for each number, but it’s not clear what benchmark we should use for this.</p>
<p>Here’s an R function, taken from <a href="https://stackoverflow.com/questions/19465720/writing-a-function-to-calculate-divisors-in-r">Stack Overflow</a>, which will calculate the divisors for a given assembly size:</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">divisors <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x){</span>
<span id="cb3-2">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#  Vector of numbers to test against</span></span>
<span id="cb3-3">  y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(x)</span>
<span id="cb3-4">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#  Modulo division. If remainder is 0 that number is a divisor of x so return it</span></span>
<span id="cb3-5">  y[ x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%%</span>y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> ]</span>
<span id="cb3-6">}</span></code></pre></div></div>
</details>
</div>
<p>We can list the divisors for the current size of the Victorian Legislative Council:</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">divisors</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>)</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>[1]  1  2  4  5  8 10 20 40</code></pre>
</div>
</div>
<p>and calculate the number of divisors (including the number itself):</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">n_divisors <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb6-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(x, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x)<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">divisors</span>(x)))</span>
<span id="cb6-3">}</span>
<span id="cb6-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_divisors</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>)</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 8</code></pre>
</div>
</div>
<p>We can go on to calculate this for <em>all</em> chambers in the IPU data.</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1">all_chambers <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Lower chamber</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>, dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Upper chamber</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>)</span>
<span id="cb8-2">all_chambers <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(all_chambers)</span>
<span id="cb8-3">stat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_divisors</span>(all_chambers))</span>
<span id="cb8-4">stat</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 7.279851</code></pre>
</div>
</div>
<p>The <em>average</em> legislative chamber therefore has just over seven divisors. We can calculate this, but we’re forced back to two classic questions, “is that a lot or a little?” and “a lot or little compared to what?”</p>
</section>
<section id="getting-to-the-kernel-of-the-comparison" class="level1">
<h1>Getting to the kernel of the comparison</h1>
<p>Ideally we would like to compare the average divisibility of the chambers that actually exist to the average divisibility of numbers that are similar to the numbers we have in relevant respects (some bigger, some smaller) but which can be dissimilar in terms of their divisibility.</p>
<p>One way of doing this is to estimate a smoothed distribution which matches the numbers we see. <a href="https://en.wikipedia.org/wiki/Kernel_density_estimation">Kernel density estimators</a> are a good way of doing this. It’s not necessary to understand <em>how</em> a kernel density is constructed, but it is necessary to understand the output of the procedure.</p>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1">all_chambers <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> all_chambers[all_chambers <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>]</span>
<span id="cb10-2">plot_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> all_chambers)</span>
<span id="cb10-3"></span>
<span id="cb10-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(plot_df, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb10-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_histogram</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">after_stat</span>(density)),</span>
<span id="cb10-6">                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">binwidth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb10-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_density</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#df691a"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb10-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_continuous</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Chamber size"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb10-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Density"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb10-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_dark</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb10-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0f2537"</span>,</span>
<span id="cb10-12">                                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>),</span>
<span id="cb10-13">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#2b3e50"</span>),</span>
<span id="cb10-14">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>),</span>
<span id="cb10-15">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>))    </span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div id="fig-density" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-density-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/divisibility/index_files/figure-html/fig-density-1.png" class="img-fluid figure-img" width="864">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-density-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;3: A histogram of chamber sizes with overlaid kernel density estimate. Vertical axis shows density (count divided by sum of counts of all bins in the histogram).
</figcaption>
</figure>
</div>
</div>
</div>
<p>Figure&nbsp;3 shows a histogram of chamber sizes. The orange line is the kernel density estimate. It reproduces the shape of the histogram – greater density at lower values, a long tail out towards the seven hundreds – but without reproducing exactly the spikes at certain values. The smoothness of the shape depends on a <em>bandwidth</em> parameter: here I’ve used the ggplot default, which is also the <a href="https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/bandwidth">R default</a>.</p>
<p>What we can therefore do is:</p>
<ul>
<li>estimate a kernel density using the <em>actual sizes</em> of legislative chambers;</li>
<li>randomly draw from that estimated distribution</li>
<li>calculate the average number of divisors of those “fake” chamber sizes</li>
<li>compare the actual average number of divisors to the average on the fake data.</li>
</ul>
<p>Here’s <a href="https://stats.stackexchange.com/questions/321542/how-can-i-draw-a-value-randomly-from-a-kernel-density-estimate">some code</a> that will do just that. Note that I’ve taken logs so that we don’t get any negative numbers from our kernel density estimate.</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">448</span>)</span>
<span id="cb11-2">z <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">density</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(all_chambers),</span>
<span id="cb11-3">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">kernel =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gaussian"</span>)</span>
<span id="cb11-4"></span>
<span id="cb11-5">rdens <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(n,</span>
<span id="cb11-6">                  z,</span>
<span id="cb11-7">                  data) {</span>
<span id="cb11-8">  width <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> z<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bw</span>
<span id="cb11-9">  rkernel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(n) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(n, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd =</span> width)</span>
<span id="cb11-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sample</span>(data, n, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">replace=</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rkernel</span>(n)</span>
<span id="cb11-11">}</span>
<span id="cb11-12"></span>
<span id="cb11-13">repl_func <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb11-14">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Generate the density on the log scale</span></span>
<span id="cb11-15">    newx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rdens</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(x), z, x)</span>
<span id="cb11-16">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Exponentiate and round to get back on the integer scale</span></span>
<span id="cb11-17">    newx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>(newx))</span>
<span id="cb11-18">    newstat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_divisors</span>(newx))</span>
<span id="cb11-19">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(newstat)</span>
<span id="cb11-20">}</span>
<span id="cb11-21"></span>
<span id="cb11-22">res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replicate</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">repl_func</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log</span>(all_chambers)))</span></code></pre></div></div>
</details>
</div>
<p>We now have one thousand numbers giving the average number of divisors of fake chamber sizes in one thousand fake sets of data. We can plot that distribution, and plot the real world figure next to it.</p>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1">plot_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> res)</span>
<span id="cb12-2"></span>
<span id="cb12-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(plot_df, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb12-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_density</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#df691a"</span>,</span>
<span id="cb12-5">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> colorspace<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lighten</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#df691a"</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>),</span>
<span id="cb12-6">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb12-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_vline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xintercept =</span> stat,</span>
<span id="cb12-8">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5cb85c"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb12-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_continuous</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Average number of divisors"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb12-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Density"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb12-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_dark</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb12-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>,</span>
<span id="cb12-13">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Simulated data"</span>,</span>
<span id="cb12-14">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">6.25</span>,</span>
<span id="cb12-15">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.6</span>,</span>
<span id="cb12-16">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb12-17">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#df691a"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb12-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"segment"</span>,</span>
<span id="cb12-19">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">6.25</span>,</span>
<span id="cb12-20">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.6</span>,</span>
<span id="cb12-21">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.6</span>,</span>
<span id="cb12-22">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.95</span>,</span>
<span id="cb12-23">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">arrow =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrow</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">length =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unit</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.02</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"npc"</span>)),</span>
<span id="cb12-24">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#df691a"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb12-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>,</span>
<span id="cb12-26">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Real world data"</span>,</span>
<span id="cb12-27">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>,</span>
<span id="cb12-28">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.25</span>,</span>
<span id="cb12-29">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb12-30">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5cb85c"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb12-31">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"segment"</span>,</span>
<span id="cb12-32">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>,</span>
<span id="cb12-33">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.25</span>,</span>
<span id="cb12-34">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.25</span>,</span>
<span id="cb12-35">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> stat,</span>
<span id="cb12-36">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">arrow =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrow</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">length =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unit</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.02</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"npc"</span>)),</span>
<span id="cb12-37">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5cb85c"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb12-38">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0f2537"</span>,</span>
<span id="cb12-39">                                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>),</span>
<span id="cb12-40">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#2b3e50"</span>),</span>
<span id="cb12-41">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>),</span>
<span id="cb12-42">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>))    </span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div id="fig-newstat" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-newstat-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/divisibility/index_files/figure-html/fig-newstat-1.png" class="img-fluid figure-img" width="864">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-newstat-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;4: Distribution of the average number of divisors in simulated data (orange density) and in the real world (green line).
</figcaption>
</figure>
</div>
</div>
</div>
<p>The green line, representing data from the real world, is way out to the right of the distribution resulting from our fake data. This means that real chamber sizes are much more divisible than fake data which try to match the overall characteristics of chamber sizes.</p>
</section>
<section id="a-simpler-way-to-the-same-conclusion" class="level1">
<h1>A simpler way to the same conclusion</h1>
<p>Although kernel density estimates are the most obvious way of mimicking the distribution of a sample, we don’t have to resort to such a complicated technique. Here’s an alternative way of generating something that “looks like” chamber sizes, but can have different divisibility:</p>
<ul>
<li>take each actual chamber size</li>
<li>draw as many random numbers from [-1, 0, +1] as there are actual chamber sizes</li>
<li>add on these increments to create some fake data</li>
<li>calculate the average number of divisors for the fake data</li>
</ul>
<p>This code does just that, and stores the average number of divisors.</p>
<div class="cell">
<details open="" class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1">repl_func2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb13-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Generate the density on the log scale</span></span>
<span id="cb13-3">    increments <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sample</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(x), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">replace =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb13-4">    newx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> x <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> increments</span>
<span id="cb13-5">    newstat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_divisors</span>(newx))</span>
<span id="cb13-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(newstat)</span>
<span id="cb13-7">}</span>
<span id="cb13-8"></span>
<span id="cb13-9">res2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replicate</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">repl_func2</span>(all_chambers))</span></code></pre></div></div>
</details>
</div>
<p>As before, we can plot the distribution of the fake data and overlay the actual figure.</p>
<div class="cell">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1">plot_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> res2)</span>
<span id="cb14-2"></span>
<span id="cb14-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(plot_df, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_density</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#df691a"</span>,</span>
<span id="cb14-5">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> colorspace<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lighten</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#df691a"</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>),</span>
<span id="cb14-6">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_vline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xintercept =</span> stat,</span>
<span id="cb14-8">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5cb85c"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb14-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_continuous</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Average number of divisors"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Density"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb14-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_dark</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-12">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>,</span>
<span id="cb14-13">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Simulated data"</span>,</span>
<span id="cb14-14">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">6.25</span>,</span>
<span id="cb14-15">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.6</span>,</span>
<span id="cb14-16">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb14-17">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#df691a"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"segment"</span>,</span>
<span id="cb14-19">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">6.25</span>,</span>
<span id="cb14-20">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.6</span>,</span>
<span id="cb14-21">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.6</span>,</span>
<span id="cb14-22">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">6.05</span>,</span>
<span id="cb14-23">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">arrow =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrow</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">length =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unit</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.02</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"npc"</span>)),</span>
<span id="cb14-24">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#df691a"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb14-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>,</span>
<span id="cb14-26">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Real world data"</span>,</span>
<span id="cb14-27">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>,</span>
<span id="cb14-28">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.25</span>,</span>
<span id="cb14-29">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span id="cb14-30">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5cb85c"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-31">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"segment"</span>,</span>
<span id="cb14-32">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>,</span>
<span id="cb14-33">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.25</span>,</span>
<span id="cb14-34">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.25</span>,</span>
<span id="cb14-35">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> stat,</span>
<span id="cb14-36">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">arrow =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrow</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">length =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unit</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.02</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"npc"</span>)),</span>
<span id="cb14-37">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5cb85c"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb14-38">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0f2537"</span>,</span>
<span id="cb14-39">                                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>),</span>
<span id="cb14-40">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#2b3e50"</span>),</span>
<span id="cb14-41">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>),</span>
<span id="cb14-42">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#ebebeb"</span>))    </span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div id="fig-newstat2" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-newstat2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/divisibility/index_files/figure-html/fig-newstat2-1.png" class="img-fluid figure-img" width="864">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-newstat2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;5: Distribution of the average number of divisors in simulated data (orange density) and in the real world (green line).
</figcaption>
</figure>
</div>
</div>
</div>
<p>Just as before, the real world legislative chambers we see are more divisible than the fake data we’ve generated by adding or subtracting a single seat. Whether we use a fancy technique (kernel density estimation) or a simple technique (adding or subtracting one), we reach the same conclusion: legislative chamber sizes are more divisible than they might otherwise be.</p>
</section>
<section id="why-do-we-get-this-pattern" class="level1">
<h1>Why do we get this pattern?</h1>
<p>It would be nice to think that constitutional framers are thinking carefully about the divisibility of their legislatures, and choosing that number “most likely to be useful to all [polities]”. Unfortunately, I don’t think that constitutional framers think like that, and that some of these patterns have to do with how much we like particular numbers.</p>
<p>Our like or dislike of certain numbers might seem a pretty slender basis for choosing the size of a legislature. After all, some likes and dislikes are culturally constructed. My house number is 44, which is just about the worst number you can have in Chinese, where 44 sounds a lot like “death death”. Many hotels have no thirteenth floor, but the association between thirteen and bad luck probably only holds in cultures that have some Christian roots.</p>
<p>Some numbers, however, do seem to be liked more than others because they’re easily accessible. Dan King and Chris Janiszewski <a href="https://doi.org/10.1509/jmkr.48.2.327">claim</a> that people like small numbers, and numbers which are the result of common additions and multiplications. Other authors <a href="https://www.theguardian.com/science/2014/apr/13/favourite-number-survey-psychology">reach similar conclusions</a>.</p>
<p>To return to the numbers used by the Victorian Legislative Council: I might like the number forty more than I like the number thirty-nine or the number forty-one because I spent time as a child learning my times tables, and because forty appears in those times tables as the answer to five times eight and eight times five.</p>
<p>The likeability of numbers is therefore connected to their divisibility, but likeability probabily trumps divisibility. In King and Janiszewski’s data, numbers ending in five are liked more than other numbers. That probably has something to do with the fact that most humans have five fingers on each hand, and use hands to count with. But numbers ending in five aren’t always very divisible. Twenty-five has far fewer divisors (3) than twenty-four (8), but people apparently like twenty-five more than they like twenty-four. Even in the histogram shown in Figure&nbsp;3 you can see the spikes at 25, 50, 75 and 100. <strong>We like the numbers that we like, and divisibility is a happy accident.</strong></p>
<p>This of course is an <em>explanation</em> of why the distribution of chamber sizes is what it is, rather than a <em>justification</em>. For my part, I’ll be writing to suggest that the Victorian Legislative Council have a highly divisible, highly composite number of members (36) rather than the 40 it has now.</p>
</section>
<section id="acknowledgements" class="level1">
<h1>Acknowledgements</h1>
<p>Thanks to <code>@jameschalmers.bsky.social</code>, <code>@urbaneprofessor.bsky.social</code> and <code>@paulfscott.bsky.social</code>, all of whom sent me copies of Bort’s article “The Numbers Game”.</p>


</section>


<div id="quarto-appendix" class="default"><section id="footnotes" class="footnotes footnotes-end-of-document"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>

<ol>
<li id="fn1"><p>Palau comes closest, with a population of 10,645, of whom roughly 60% are over the age of 18, giving a total adult population of around 6,500. I don’t consider the Vatican to be self-governing.↩︎</p></li>
<li id="fn2"><p>For a time I thought that the size of the Scottish Parliament might have been determined with this in mind. This view was sadly scotched (pun intended) by Eberhard Bort’s article, <a href="https://doi.org/10.3366/SCOT.2002.0019?sid=semanticscholar">“The Numbers Game”</a>, where I learned that the number 129 was a compromise between Labour (who wanted a parliament of 112, or the seventy-two existing constituencies plus forty top-up members) and the Liberal Democrats (who wanted a parliament of 145, or seventy-three constituency members plus seventy-two top up MPs). The Liberal Democrats would have had seventy-three constituency members rather than seventy-two because Orkney and Shetland would each have had a constituency member. Not coincidentally, the Westminster constituency of Orkney and Shetland <a href="https://en.wikipedia.org/wiki/Orkney_and_Shetland_(UK_Parliament_constituency)">“has elected only Liberal and Liberal Democrat MPs since 1950; the longest run of any British parliamentary constituency”</a>.↩︎</p></li>
</ol>
</section></div> ]]></description>
  <category>legislatures</category>
  <guid>http://www.chrishanretty.co.uk/posts/divisibility/</guid>
  <pubDate>Mon, 09 Dec 2024 00:00:00 GMT</pubDate>
</item>
<item>
  <title>How much do gender and ethnicity affect wannabe MPs’ chances of being selected?</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/candidate_clogit/</link>
  <description><![CDATA[ 





<div class="callout callout-style-default callout-warning callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Warning</span>tl;dr version
</div>
</div>
<div class="callout-body-container callout-body">
<p>To model the chances of winning a contest, you should use conditional logistic regression, but this requires extra work to turn coefficient values into changes in the probability of winning the contest.</p>
</div>
</div>
<p>The selection of parliamentary candidates is one of the most important mechanisms in the British political life, yet it’s incredibly hard to research.</p>
<p>That’s why a <a href="https://journals.sagepub.com/doi/10.1177/13691481241270519">new paper by Chris Butler, Marta Miori and Rob Ford</a> is so welcome.</p>
<p>The authors compile an <a href="https://doi.org/10.7910/DVN/J6UKGO">anonymized dataset</a> of short-listed candidates, and link candidate characteristics (age, gender, ethnicity) to the chances of being selected as a party candidate.</p>
<p>It’s great work, but that doesn’t mean I wouldn’t like to see some things done differently.</p>
<p>The authors have modelled the probability of success using a logistic regression, where one, or a positive outcome, means being selected, and zero, or a negative outcome, means not being selected.</p>
<p>There are problems with using a logistic regression for this kind of model.</p>
<p>The big problem is that some factors might only matter for selection in a <em>relative sense</em>.</p>
<p>If candidate selection was done by bribery, then all you would need to get selected would be “more bribe money than the other candidate”. In some constituencies – City of London, say – the top bribe might be very high. In other constituencies the top bribe might be very low.</p>
<p>If we just entered the bribe paid by each candidate, we might falsely conclude that the bribe paid had no effect, because some literal losers in City of London paid quite a lot, and some lucky people elsewhere paid very little.</p>
<p>A second problem is that using a logistic regression also complicates making statements about how changes in factors affect the probability of success.</p>
<p>If I change some candidate’s trait – make them male instead of female – then we would like to say that their probability of being selected has gone up – but if we’re saying their probability of being selected has gone up, that implies that the probabilities of selection for other candidates must go down, which wouldn’t happen when you’re generating predictions from a logistic regression.</p>
<p>In this post, I’ll replicate their model using a <a href="https://en.wikipedia.org/wiki/Conditional_logistic_regression">conditional logistic regression</a>. A conditional logistic regression is exactly the right kind of model when <strong>cue Highlander voice</strong> there can be only one.</p>
<p align="center">
<iframe src="https://giphy.com/embed/8L0yOaWLNmHnm9T4yy" width="480" height="269" style="" frameborder="0" class="giphy-embed" allowfullscreen="">
</iframe>
</p>
<section id="replicating-what-was-done" class="level1">
<h1>Replicating what was done</h1>
<p>I’ll begin by loading the libraries I need, and the replication data. I load <code>tidyverse</code> for general data cleaning, <code>mclogit</code> for modelling. I use <code>modelsummary</code> and <code>hrbrthemes</code> for making stuff look pretty.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1891</span>)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">suppressPackageStartupMessages</span>({</span>
<span id="cb1-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse)</span>
<span id="cb1-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(mclogit)</span>
<span id="cb1-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(modelsummary)</span>
<span id="cb1-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(hrbrthemes)</span>
<span id="cb1-7">})</span>
<span id="cb1-8"></span>
<span id="cb1-9">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.delim</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ShortlistedCands2019Anonymous.csv"</span>,</span>
<span id="cb1-10">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">";"</span>,</span>
<span id="cb1-11">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.strings =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NA"</span>))</span></code></pre></div></div>
</div>
<p>I’m going to filter to cases where we know the outcome. I’m also going to create a unique <code>contest</code> identifier, which is created by interacting party and constituency.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(success)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(BAME)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">contest =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">interaction</span>(party, constituency)))</span></code></pre></div></div>
</div>
<p>I’ll also remove contests where there was only one candidate listed.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(contest) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_cands =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb3-4">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pos_within_contest =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_cands <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span></code></pre></div></div>
</div>
<p>I’m also going to drop variables I don’t need:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-2">    dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(success, contest, gender, BAME, local,</span>
<span id="cb4-3">                  past_selection, elected_cllr, occ_party)</span></code></pre></div></div>
</div>
<p>Using this, I’ll estimate a model using the same predictors used by the authors to create their Figure 2: being female, being from an ethnic minority, living locally, having stood previously, being an elected councillor, and having worked for the party.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">m <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mclogit</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cbind</span>(success, contest) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> gender <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> BAME <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> local <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-2">                 past_selection <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> elected_cllr <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb5-3">                 occ_party,</span>
<span id="cb5-4">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> dat)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>
Iteration 1 - deviance = 265.8233 - criterion = 0.4664284
Iteration 2 - deviance = 265.7618 - criterion = 0.0002312444
Iteration 3 - deviance = 265.7618 - criterion = 1.594636e-08
Iteration 4 - deviance = 265.7618 - criterion = 2.138082e-16
converged</code></pre>
</div>
</div>
<p>I can then report this model.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">my_cm <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'gender'</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Female'</span>,</span>
<span id="cb7-2">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'BAME'</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Ethnic minority'</span>,</span>
<span id="cb7-3">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'local'</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Lives locally'</span>,</span>
<span id="cb7-4">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'past_selection'</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Stood before'</span>,</span>
<span id="cb7-5">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'elected_cllr'</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Elected councillor'</span>,</span>
<span id="cb7-6">        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'occ_party'</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Worked for party'</span>)</span>
<span id="cb7-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">modelsummary</span>(m,</span>
<span id="cb7-8">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">coef_map =</span> my_cm,</span>
<span id="cb7-9">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">statistic =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"conf.int"</span>) </span></code></pre></div></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_hpttezgogl5dpgmo69tg(i, j, css_id) {
          var table = document.getElementById("tinytable_hpttezgogl5dpgmo69tg");
          var cell = table.rows[i]?.cells[j];  // Safe navigation to avoid errors
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function insertSpanRow(i, colspan, content) {
        var table = document.getElementById('tinytable_hpttezgogl5dpgmo69tg');
        var newRow = table.insertRow(i);
        var newCell = newRow.insertCell(0);
        newCell.setAttribute("colspan", colspan);
        // newCell.innerText = content;
        // this may be unsafe, but innerText does not interpret <br>
        newCell.innerHTML = content;
      }
      function spanCell_hpttezgogl5dpgmo69tg(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_hpttezgogl5dpgmo69tg");
        const targetRow = table.rows[i];
        const targetCell = targetRow.cells[j];
        for (let r = 0; r < rowspan; r++) {
          // Only start deleting cells to the right for the first row (r == 0)
          if (r === 0) {
            // Delete cells to the right of the target cell in the first row
            for (let c = colspan - 1; c > 0; c--) {
              if (table.rows[i + r].cells[j + c]) {
                table.rows[i + r].deleteCell(j + c);
              }
            }
          }
          // For rows below the first, delete starting from the target column
          if (r > 0) {
            for (let c = colspan - 1; c >= 0; c--) {
              if (table.rows[i + r] && table.rows[i + r].cells[j]) {
                table.rows[i + r].deleteCell(j);
              }
            }
          }
        }
        // Set rowspan and colspan of the target cell
        targetCell.rowSpan = rowspan;
        targetCell.colSpan = colspan;
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: 18, j: 1 },  ], css_id: 'tinytable_css_f7l5qvutpvads46xu0ug',}, 
          { positions: [ { i: 12, j: 1 },  ], css_id: 'tinytable_css_uzqkwhrp6wr9r2hh0u2q',}, 
          { positions: [ { i: 1, j: 1 }, { i: 2, j: 1 }, { i: 3, j: 1 }, { i: 4, j: 1 }, { i: 5, j: 1 }, { i: 6, j: 1 }, { i: 7, j: 1 }, { i: 8, j: 1 }, { i: 9, j: 1 }, { i: 10, j: 1 }, { i: 11, j: 1 }, { i: 16, j: 1 }, { i: 13, j: 1 }, { i: 14, j: 1 }, { i: 15, j: 1 }, { i: 17, j: 1 },  ], css_id: 'tinytable_css_rkme3d5tepc34lr1dmqh',}, 
          { positions: [ { i: 0, j: 1 },  ], css_id: 'tinytable_css_mtq9sx3kigci1d2hn4mn',}, 
          { positions: [ { i: 18, j: 0 },  ], css_id: 'tinytable_css_1d7drwx2zd4lteshrd0r',}, 
          { positions: [ { i: 12, j: 0 },  ], css_id: 'tinytable_css_mrge7up3nsb0rilvvpsz',}, 
          { positions: [ { i: 1, j: 0 }, { i: 2, j: 0 }, { i: 3, j: 0 }, { i: 4, j: 0 }, { i: 5, j: 0 }, { i: 6, j: 0 }, { i: 7, j: 0 }, { i: 8, j: 0 }, { i: 9, j: 0 }, { i: 10, j: 0 }, { i: 11, j: 0 }, { i: 16, j: 0 }, { i: 13, j: 0 }, { i: 14, j: 0 }, { i: 15, j: 0 }, { i: 17, j: 0 },  ], css_id: 'tinytable_css_m4se3nfbgxhwjr3ehxo7',}, 
          { positions: [ { i: 0, j: 0 },  ], css_id: 'tinytable_css_o0fpjfts0b74h3wno15f',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_hpttezgogl5dpgmo69tg(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script>

    <style>
      /* tinytable css entries after */
      .table td.tinytable_css_f7l5qvutpvads46xu0ug, .table th.tinytable_css_f7l5qvutpvads46xu0ug { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_uzqkwhrp6wr9r2hh0u2q, .table th.tinytable_css_uzqkwhrp6wr9r2hh0u2q { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_rkme3d5tepc34lr1dmqh, .table th.tinytable_css_rkme3d5tepc34lr1dmqh { text-align: center; }
      .table td.tinytable_css_mtq9sx3kigci1d2hn4mn, .table th.tinytable_css_mtq9sx3kigci1d2hn4mn { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_1d7drwx2zd4lteshrd0r, .table th.tinytable_css_1d7drwx2zd4lteshrd0r { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_mrge7up3nsb0rilvvpsz, .table th.tinytable_css_mrge7up3nsb0rilvvpsz { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_m4se3nfbgxhwjr3ehxo7, .table th.tinytable_css_m4se3nfbgxhwjr3ehxo7 { text-align: left; }
      .table td.tinytable_css_o0fpjfts0b74h3wno15f, .table th.tinytable_css_o0fpjfts0b74h3wno15f { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
    <div class="container">
      <table class="table table-borderless" id="tinytable_hpttezgogl5dpgmo69tg" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
        <thead>
        
              <tr>
                <th scope="col"> </th>
                <th scope="col">(1)</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td>Female</td>
                  <td>-0.531</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[-1.045, -0.017]</td>
                </tr>
                <tr>
                  <td>Ethnic minority</td>
                  <td>-0.776</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[-1.564, 0.011]</td>
                </tr>
                <tr>
                  <td>Lives locally</td>
                  <td>1.025</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[0.537, 1.513]</td>
                </tr>
                <tr>
                  <td>Stood before</td>
                  <td>0.376</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[-0.087, 0.840]</td>
                </tr>
                <tr>
                  <td>Elected councillor</td>
                  <td>0.295</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[-0.150, 0.741]</td>
                </tr>
                <tr>
                  <td>Worked for party</td>
                  <td>0.255</td>
                </tr>
                <tr>
                  <td></td>
                  <td>[-0.262, 0.772]</td>
                </tr>
                <tr>
                  <td>Num.Obs.</td>
                  <td>143</td>
                </tr>
                <tr>
                  <td>AIC</td>
                  <td>277.8</td>
                </tr>
                <tr>
                  <td>BIC</td>
                  <td>295.5</td>
                </tr>
                <tr>
                  <td>Log.Lik.</td>
                  <td>-141.722</td>
                </tr>
                <tr>
                  <td>RMSE</td>
                  <td>0.42</td>
                </tr>
                <tr>
                  <td>nagelkerke's r2</td>
                  <td>0.245456717189779</td>
                </tr>
        </tbody>
      </table>
    </div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>Now the coefficient values are there, and you can check how big they are, but it’s quite hard to relate those coefficients – log odds ratios of being chosen – to anything understandable by humans.</p>
<p>We will therefore need to calculate quantities we can understand – like changes in probabilities – under some specific scenarios. Ordinarily, when we calculate human-readable quantities of interest, we calculate <em>average marginal effects</em>, or the effect of changing a focal variable by one unit for each observation, and averaging this over all observations.</p>
</section>
<section id="a-targeted-counterfactual" class="level1">
<h1>A targeted counterfactual</h1>
<p>In cases like this, it doesn’t make sense to change the value of the focal variable for one unit for all observations. If the change of one unit affects all observations, then it doesn’t alter the probabilities of success.</p>
<p>We need to therefore consider a more targeted intervention – specifically, what happens if we change the value of the focal variable for a randomly chosen individuals within each contest. We can then average over each of these focal <em>individuals</em>, and calculate the change in the probability for them.</p>
<p>Here’s a function which will take in a data frame, and a variable name contained in a string <code>var</code> and restrict the analysis to contests where there was some variable in the focal variable. It will then randomly choose an individual with the minimum value of the focal variable, alter that individual’s value of the focal variable to the maximum value, and tag that individual as “focal”. This altered variable is stored under the name <code>cfval</code>.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1">create_counterfactual <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(data, var) {</span>
<span id="cb8-2">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Only look at those situations where there is more than one unique value of the variable</span></span>
<span id="cb8-3">    cf <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> data <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb8-4">        dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb8-5">        dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(contest) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb8-6">        dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_distinct =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get</span>(var))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb8-7">        dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb8-8">        dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_distinct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb8-9">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## set one minimum value to the maximum value</span></span>
<span id="cb8-10">    drop_first <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb8-11">        x[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb8-12">    }</span>
<span id="cb8-13">    cf <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cf <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb8-14">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">randno =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>())) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb8-15">        dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(contest) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb8-16">        dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(.data[[var]], randno) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb8-17">        dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cfval =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get</span>(var)), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">drop_first</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get</span>(var))),</span>
<span id="cb8-18">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">focal =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb8-19">        dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>randno)</span>
<span id="cb8-20">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(cf)</span>
<span id="cb8-21">}</span></code></pre></div></div>
</div>
<p>Now that we can create altered sets of data, we need to be able to calculate predicted probabilities. That can be done using the <code>calc_pps</code> function below, which calculates the linear predictor <code>mu</code>, exponentiates it, and divides by the sum of exponentiated predicted probabilities for each contest.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">calc_pps <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(b, X, grp) {</span>
<span id="cb9-2">    mu <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> X <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%*%</span> b</span>
<span id="cb9-3">    emu <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">exp</span>(mu)[,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb9-4">    grpsums <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ave</span>(emu, grp, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FUN =</span> sum)</span>
<span id="cb9-5">    pr <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> emu <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> grpsums</span>
<span id="cb9-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(pr)</span>
<span id="cb9-7">}</span></code></pre></div></div>
</div>
<p>Finally, we can put this in a overall function, which creates the counterfactuals, does some messing around with model matrices, before drawing some coefficients and calculating averages.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1">calc_fx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(mod, df, var, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_sims =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>) {</span>
<span id="cb10-2">    cf <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">create_counterfactual</span>(df, var)</span>
<span id="cb10-3"></span>
<span id="cb10-4">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Create the two model matrices</span></span>
<span id="cb10-5">    base_mat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">model.matrix</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">formula</span>(mod), cf)[,<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb10-6">    newf <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">formula</span>(mod))</span>
<span id="cb10-7">    newf <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(var), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cfval"</span>, newf)</span>
<span id="cb10-8">    newf <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.formula</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(newf[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]], newf[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ~ "</span>))</span>
<span id="cb10-9">    cf_mat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">model.matrix</span>(newf, cf)[,<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb10-10"></span>
<span id="cb10-11"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Get some betas</span></span>
<span id="cb10-12">    betas <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> MASS<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mvrnorm</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> n_sims,</span>
<span id="cb10-13">                           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mu =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(mod),</span>
<span id="cb10-14">                           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sigma =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vcov</span>(mod))</span>
<span id="cb10-15">    pp <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">apply</span>(betas, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(b) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">calc_pps</span>(b, base_mat, cf<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>contest))</span>
<span id="cb10-16">    cf_pp <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">apply</span>(betas, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(b) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">calc_pps</span>(b, cf_mat, cf<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>contest))</span>
<span id="cb10-17">    delta <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cf_pp <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> pp</span>
<span id="cb10-18"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Just get those comparisons we're interested in</span></span>
<span id="cb10-19">    delta <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> delta[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(cf<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>focal <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), ]</span>
<span id="cb10-20"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Average over cases in the data</span></span>
<span id="cb10-21">    delta <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">apply</span>(delta, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, mean)</span>
<span id="cb10-22"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Return the distribution of average effects</span></span>
<span id="cb10-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(delta)</span>
<span id="cb10-24">    </span>
<span id="cb10-25">}</span>
<span id="cb10-26"></span>
<span id="cb10-27">res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">calc_fx</span>(m, dat, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BAME"</span>)</span></code></pre></div></div>
</div>
<p>The return value of this function is a vector of <code>n_sims</code> average effect sizes. We can plot the distribution of values like this:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1">xlab <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_wrap</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Effect upon probability of success of making a random white candidate within each contest come instead from an ethnic minority"</span>)</span>
<span id="cb11-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value =</span> res),</span>
<span id="cb11-3">       <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> res)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb11-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_histogram</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb11-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_continuous</span>(xlab,</span>
<span id="cb11-6">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> scales<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>percent) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb11-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Density"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb11-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_vline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xintercept =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb11-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_vline</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xintercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(res)),</span>
<span id="cb11-10">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"darkred"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb11-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_ipsum_rc</span>()</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="http://www.chrishanretty.co.uk/posts/candidate_clogit/index_files/figure-html/unnamed-chunk-10-1.png" class="img-fluid figure-img" style="width:100.0%"></p>
</figure>
</div>
</div>
</div>
<p>We can see that across multiple simulated batches of coefficients, the average change in probability was -13.1 percentage points. That seems to me to be a pretty major penalty.</p>
<p>We can repeat this analysis for women candidates. The <code>gender</code> variable is coded so that values of one are equal to women.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1">res2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">calc_fx</span>(m, dat, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gender"</span>)</span>
<span id="cb12-2"></span>
<span id="cb12-3">xlab <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_wrap</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Effect upon probability of success of making a random male candidate within each contest be female instead"</span>)</span>
<span id="cb12-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value =</span> res2),</span>
<span id="cb12-5">       <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> res2)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb12-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_histogram</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb12-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_continuous</span>(xlab,</span>
<span id="cb12-8">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> scales<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>percent) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb12-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Density"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb12-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_vline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xintercept =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb12-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_vline</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xintercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(res2)),</span>
<span id="cb12-12">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"darkred"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> </span>
<span id="cb12-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_ipsum_rc</span>()</span></code></pre></div></div>
<div class="cell-output cell-output-stderr">
<pre><code>`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.</code></pre>
</div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="http://www.chrishanretty.co.uk/posts/candidate_clogit/index_files/figure-html/unnamed-chunk-11-1.png" class="img-fluid figure-img" style="width:100.0%"></p>
</figure>
</div>
</div>
</div>
<p>Thus, in addition to reporting the coefficient values in their article, the authors might have said:</p>
<blockquote class="blockquote">
<p>“changing the gender of a randomly chosen male candidate in a contest to be female is associated with a change in the probability of selection of -9.5 percentage points (95 percent confidence interval: -18.5 to 0.3 percentage points”</p>
</blockquote>
<p>and similarly</p>
<blockquote class="blockquote">
<p>“making a randomly chosen white candidate in a contest come instead from an ethnic minority is associated with a change in the probability of selection of -13.1 percentage points (95 percent confidence interval: -24.6 to 0.1 percentage points”</p>
</blockquote>
<p>both of which are smaller effects than the effects of being local, where they might have said:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1">res3 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">calc_fx</span>(m, dat, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"local"</span>)</span></code></pre></div></div>
</div>
<blockquote class="blockquote">
<p>“making a randomly chosen non-local candidate in a contest come instead from the local area is associated with a change in the probability of selection of 17.3 percentage points (95 percent confidence interval: 9.8 to 23.8 percentage points”</p>
</blockquote>
<p>In UK candidate selection, the key really is “location, location, location”…</p>


</section>

 ]]></description>
  <category>MPs</category>
  <category>elections</category>
  <category>gender</category>
  <category>R</category>
  <guid>http://www.chrishanretty.co.uk/posts/candidate_clogit/</guid>
  <pubDate>Thu, 26 Sep 2024 23:00:00 GMT</pubDate>
</item>
<item>
  <title>Minimal important differences in the social sciences, part 2</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/mids_pt2/</link>
  <description><![CDATA[ 





<p>In a <a href="../../posts/mids_pt1/index.html">previous post</a>, I suggested that one way of determining the minimal important difference is to establish the minimal detectable change. If you don’t know that a change is different from zero, it surely can’t be that important.</p>
<p>In this post, I want to suggest another way to determine the minimal importance difference. This is by working out whether you are indifferent between multiple proposed continuous measures of a concept. If you’re indifferent between two measures, the times when they disagree surely can’t be that important.</p>
<p>But first, a fable…</p>
<p align="center">
<iframe src="https://giphy.com/embed/Hq5AAN85oIuxeDqa5p" width="480" height="480" style="" frameborder="0" class="giphy-embed" allowfullscreen="">
</iframe>
</p>
<section id="why-the-kings-rooms-run-hot-and-cold" class="level1">
<h1>Why the king’s rooms run hot and cold</h1>
<p>A long time ago, in a far away country, there lived two inventors.</p>
<p>These two inventors wished to measure heat.</p>
<p>One inventor measured heat by placing brandy in a thin column of glass.</p>
<p>As the level of the brandy rose, so the heat in the room was judged greater.</p>
<p>The other inventor did the same, but with quicksilver instead of brandy.</p>
<p>The devices made by these men sometimes agreed, but sometimes differed.</p>
<p>People in the mountains preferred the measure based on brandy; people in the plains preferred the measure based on quicksilver.</p>
<p>The two men brought their inventions to the king of that land.</p>
<p>They showed him their inventions, and asked him to judge which was best.</p>
<p>The king, wishing to offend neither man, said he could not decide, but offered to install devices from both men in the rooms in his palace.</p>
<p>Shortly after, the king’s steward noted disagreements between these devices.</p>
<p>The cellar to the west of the palace was judged by brandy to be the coldest room in the palace.</p>
<p>By quicksilver, though, it was the cellar to the east of the palace that was judged coldest.</p>
<p>The two inventors, hearing of the steward’s observations, called on the king again.</p>
<p>“Sire”, they said, “you said you could not decide between us on general grounds. Here you need only decide on particulars. Go into the west cellar, and then into the east cellar, and say which is coldest. Then shall you know which measure is best”.</p>
<p>The king went to the west cellar, and then to the east cellar, and then back to the two inventors. He told them that just as before, he could not judge which of the rooms was colder, and thus could not say which measure was better.</p>
<p>The two inventors thanked the king and left disappointed. The king too was disappointed, for he had no wish to spend any time in the cellars of his palace, and treated his steward rudely thereafter.</p>
<p>Time passed, and the king grew old, and took to complaining of the temperature in his rooms.</p>
<p>He asked his steward to make the temperature in his water closet more equal to the temperature in his bed chamber.</p>
<p>His steward, much put upon, declined.</p>
<p>“No sire, I shall not. For I mark the difference between the measure made in your bed-chamber, and the measure made in your water closet, and these two measures are closer together than the difference between the measures in the west cellar and the measures in the east cellar, which you thought so finely matched. If you tell me now there is a difference, then I must go back to those two men who troubled you earlier, and have them trouble you again”.</p>
<p>The king, not wishing to see the two inventors again, and knowing that his steward had the better of him, accept the man’s argument. And that is why the king’s rooms blow hot and cold.</p>
</section>
<section id="back-to-the-social-sciences" class="level1">
<h1>Back to the social sciences</h1>
<p>Though that fable was exceeding subtle, I hope you see some analogies to the social sciences. We have different measures of things, and if we really want to say that we’re indifferent between them, and indifferent to cases where they disagree, we have to say that some differences (in terms of one of those measures) aren’t important.</p>
<p>The fable simplifies things, because by construction there’s only one relevant case.</p>
<p>Now let’s start again from first principles, and only then deal with the complications posed by multiple cases.</p>
<p>Let’s suppose that there is some social scientist who is indifferent between two different measures of the same concept.</p>
<p>(This individual may have written articles which use one measure, and different articles which use the rival measure. Maybe they’ve even written articles which use both measures. After all, doesn’t everyone love robustness to different measurement strategies?)</p>
<p>Let’s suppose that these two measures are continuous. This means that we can always make a pairwise comparison between two cases and identify one case which has “more” of the underlying concept on this measure. Figuratively: the measures never put their hands up and say, “too close to call”.</p>
<p>Because our two measures are different, then with enough comparisons they will on occasion disagree. If they always agreed, they wouldn’t be different.<sup>1</sup> One measure will say that the example A in the comparison has “more”; the other measure will say that it’s example B that has more.</p>
<p>Let’s suppose that there is precisely <em>one</em> pairwise comparison where there is disagreement. This is, of course, the situation given in the fable above.</p>
<p>In this case, the social scientist either thinks</p>
<ul>
<li>“example A has more [of this concept]”, or</li>
<li>they are indifferent between the example, or they think</li>
<li>“example B has more of this concept”.</li>
</ul>
<p>I would argue that they must be indifferent, because if they thought that either example A or example B had more of this concept, they would have a good reason to prefer the measure that they sided with, and couldn’t therefore be indifferent between the two measures as we initially supposed they were.</p>
<p>Now let’s consider the more typical situation where there are lots of cases of pairwise disagreement between measures.</p>
<p>We can’t take <em>any</em> specific instance and expect our social scientist to be indifferent. Maybe that instance of disagreement results from very particular circumstances. Maybe in that case the researcher thinks that one example has more, thus giving them a reason to prefer one index, but there are other offsetting cases which suggest the rival index.</p>
<p>What I’ll suggest is that our researcher has to be indifferent in the <em>average</em> or <em>median</em> case of disagreement. They have to be indifferent in the case of this case of disagreement because if they weren’t, it would strongly imply that they were not in fact indifferent between measures.</p>
<p>This argument is informal and not fully worked out. In theory if we allow no restrictions on the social scientist’s intuitive judgements, we could pair off freak results and find that the social scientist only has to be indifferent in cases involving the smallest disagreement.</p>
</section>
<section id="a-worked-example-with-disproportionality" class="level1">
<h1>A worked example with disproportionality</h1>
<p>In this section, I’ll look at how we might establish a minimal important difference for votes-seats disproportionality, given indifference between measures. Votes-seats disproportionality is a good example because most of the time votes and seats are measured without error. As a result we can’t calculate a minimal important difference based on the minimal detectable change. I’ll assume that there is a social scientist who is indifferent between the Gallagher index and the Sainte-Laguë index, two commonly used indices of disproportionalit. I’ll calculate the values of these indices for modern parliamentary elections covered by ParlGov, and generate all pairs of elections.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">suppressPackageStartupMessages</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse))</span>
<span id="cb1-2">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"view_election.csv"</span>)</span>
<span id="cb1-3">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(election_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"parliament"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">election_date =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.Date</span>(election_date)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(election_date <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.Date</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1945-12-31"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vote_share =</span> vote_share <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>,</span>
<span id="cb1-8">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seat_share =</span> seats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> seats_total)</span>
<span id="cb1-9"></span>
<span id="cb1-10">gallagher <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(v, s) {</span>
<span id="cb1-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>((v <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> s)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>))</span>
<span id="cb1-12">}</span>
<span id="cb1-13">sainte_lague <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(v, s) {</span>
<span id="cb1-14">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>((v <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> s)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> v, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb1-15">}</span>
<span id="cb1-16">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(country_name_short, election_date, election_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarize</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">d_gall =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gallagher</span>(vote_share, seat_share),</span>
<span id="cb1-19">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">d_sl =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sainte_lague</span> (vote_share, seat_share),</span>
<span id="cb1-20">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb1-21"></span>
<span id="cb1-22"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Generate all pairs</span></span>
<span id="cb1-23">pairs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">A =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>election_id),</span>
<span id="cb1-24">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">B =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>election_id)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(A <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> B) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-26">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(dat, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">join_by</span>(A <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> election_id)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(dat, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">join_by</span>(B <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> election_id),</span>
<span id="cb1-28">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">suffix =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".A"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".B"</span>))</span></code></pre></div></div>
</div>
<p>Having generated all pairs of elections, I focus on those pairs where there is disagreement concerning which example has “more” disproportionality. As might be expected, only a minority of pairings throw up some disagreement, but that minority, at roughly one in eight, isn’t neglible.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(pairs)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 212878</code></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">pairs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">gall_pref =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sign</span>(d_gall.B <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> d_gall.A),</span>
<span id="cb4-3">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sl_pref =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sign</span>(d_sl.B <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> d_sl.A)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb4-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(gall_pref <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> sl_pref)</span>
<span id="cb4-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(pairs)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 26250</code></pre>
</div>
</div>
<p>Now let’s examine the absolute differences between values of the Sainte-Laguë index.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">pairs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb6-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">delta_sl =</span> d_sl.B <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> d_sl.A)</span>
<span id="cb6-3"></span>
<span id="cb6-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(pairs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>delta_sl))</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
0.000000 0.005039 0.013049 0.022868 0.028760 0.599469 </code></pre>
</div>
</div>
<p>In this case, we wouldn’t want to force anyone to say that a difference in the Sainte-Laguë index of 0.59 units(!) was not important just because it arose in the context of a disagreement between indices. But it does seem plausible to suggest that the median absolute value of 0.013 units might be a minimal important difference. For what it’s worth, if we compare that value to the standard deviation of values of the index in our original data, we have a minimal important difference of roughly 0.125 standard deviations.</p>
<p>We could, of course, have started from the other index. Let’s examine the absolute difference between values of the Gallagher index.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1">pairs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb8-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">delta_gall =</span> d_gall.B <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> d_gall.A)</span>
<span id="cb8-3"></span>
<span id="cb8-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(pairs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>delta_gall))</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
1.600e-07 3.848e-03 9.325e-03 1.339e-02 1.863e-02 1.091e-01 </code></pre>
</div>
</div>
<p>In this case, we get a pretty small median absolute difference of just under 0.01 units – but of course the standard deviation of the Gallagher index is much smaller, at 0.048 units. Expressed in terms of standard deviations, we have a minimal important difference of roughly 0.2 standard deviations.</p>
<p>We therefore have a minimal important difference for one index, and a minimal important difference for another index. This means that some differences will be important when we use one index, and not important when we use another index. That might seem unsatisfactory, but “disagreement over indices” should surely have consequences for what is substantively important.</p>
</section>
<section id="back-to-measures-of-democracy" class="level1">
<h1>Back to measures of democracy</h1>
<p>We can apply this same logic to democracy. Let’s suppose there is a researcher who is indifferent between two measures of electoral democracy:</p>
<ul>
<li>the V-Dem project’s measure <code>v2x_polyarchy</code></li>
<li>Polity V scores</li>
</ul>
<p>Thankfully these two measures are both available in the V-Dem data.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(vdemdata)</span>
<span id="cb10-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"vdem"</span>)</span>
<span id="cb10-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Just select the variables we're interested in</span></span>
<span id="cb10-4">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> vdem <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb10-5">    dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(country_text_id, year,</span>
<span id="cb10-6">                  v2x_polyarchy,</span>
<span id="cb10-7">                  e_polity2)</span>
<span id="cb10-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Fix some Polity codes</span></span>
<span id="cb10-9">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb10-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">e_polity2 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na_if</span>(e_polity2, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">88</span>),</span>
<span id="cb10-11">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">e_polity2 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na_if</span>(e_polity2, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">66</span>))</span></code></pre></div></div>
</div>
<p>Generating all possible pairwise comparisons of all country years across all of the modern period is memory-intensive, so I’ll focus on years since 1945 and countries covered by both projects.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Restrict it to the post-war period</span></span>
<span id="cb11-2">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb11-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(year <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1945</span>)</span>
<span id="cb11-4"></span>
<span id="cb11-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Restrict it to common cases</span></span>
<span id="cb11-6">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb11-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(e_polity2)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb11-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(v2x_polyarchy))</span>
<span id="cb11-9"></span>
<span id="cb11-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Create a unique label</span></span>
<span id="cb11-11">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb11-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(country_text_id, year))</span>
<span id="cb11-13"></span>
<span id="cb11-14"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Generate all pairwise combinations of country years.</span></span>
<span id="cb11-15"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Note that there are around 4,600 country years</span></span>
<span id="cb11-16"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### so we have 4,600 * (4,600 - 1) pairings</span></span>
<span id="cb11-17"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### but we can restrict it to cases order is alphabetical</span></span>
<span id="cb11-18"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### taking it down to 10 million</span></span>
<span id="cb11-19">pairs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">A =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label),</span>
<span id="cb11-20">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">B =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label),</span>
<span id="cb11-21">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb11-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(A <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> B)</span>
<span id="cb11-23"></span>
<span id="cb11-24"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Start merging on the indicators</span></span>
<span id="cb11-25">pairs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(pairs,</span>
<span id="cb11-26">                   dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(label, v2x_polyarchy, e_polity2),</span>
<span id="cb11-27">                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">join_by</span>(A <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> label))</span>
<span id="cb11-28"></span>
<span id="cb11-29">pairs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(pairs,</span>
<span id="cb11-30">                   dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(label, v2x_polyarchy, e_polity2),</span>
<span id="cb11-31">                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">join_by</span>(B <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> label),</span>
<span id="cb11-32">                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">suffix =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".A"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".B"</span>))</span></code></pre></div></div>
</div>
<p>As before, we focus just on cases of disagreement. Here, I’ll look at cases of “strict” disagreement.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(pairs)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 48960460</code></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1">pairs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb14-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vdem_pref =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sign</span>(v2x_polyarchy.B <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> v2x_polyarchy.A),</span>
<span id="cb14-3">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">polity_pref =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sign</span>(e_polity2.B <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> e_polity2.A)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb14-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>((vdem_pref <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> polity_pref <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span></span>
<span id="cb14-5">           (vdem_pref <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> polity_pref <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb14-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(pairs)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 4961321</code></pre>
</div>
</div>
<p>Here, around 10% of pairings of country years see a disagreement between the two indices. Let’s work out what the median absolute difference in these cases of disagreement is.</p>
<p>First, let’s do <code>v2x_polyarchy</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1">pairs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb16-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">delta_vdem =</span> v2x_polyarchy.B <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> v2x_polyarchy.A)</span>
<span id="cb16-3"></span>
<span id="cb16-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(pairs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>delta_vdem))</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
0.00100 0.02800 0.06500 0.08811 0.11900 0.78000 </code></pre>
</div>
</div>
<p>Our candidate for the minimal important difference is of 0.065 units. That’s around 0.25 standard deviations when looking at the V-Dem data as a whole, and bigger than 0.05, the minimal important difference implied by the minimal detectable change.</p>
<p>and now <code>e_polity2</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1">pairs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb18-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">delta_polity =</span> e_polity2.B <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> e_polity2.A)</span>
<span id="cb18-3"></span>
<span id="cb18-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(pairs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>delta_polity))</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  1.000   1.000   2.000   3.295   4.000  20.000 </code></pre>
</div>
</div>
<p>Because the Polity score is a fine-grained ordinal variable rather than a continuous variable, the median absolute difference in cases of disagreement is exactly two units.</p>
</section>
<section id="conclusions" class="level1">
<h1>Conclusions</h1>
<p>In this post I’ve suggested that <em>if you are indifferent between two measures</em>, this can help us establish a minimal important difference. This way of establishing a minimal important difference is valuable in cases where, like electoral disproportionality, we can’t establish a minimal important difference by way of measurement error.</p>
<p>I don’t know how common it is for researchers to be genuinely indifferent between measures. I also don’t know how <em>persistent</em> that indifference is. Indeed, one possible way of reacting to these claims about minimal important differences is to quickly develop a more fine grained preference between measures based on cases of disagreement. Obviously it’s fanciful to imagine anyone going through 4 million pairs of country years and determining whether they side more with Polity or V-Dem, but sharpening our preferences by looking at cases of disagreement might still be a worthwhile way to spend some time.</p>


</section>


<div id="quarto-appendix" class="default"><section id="footnotes" class="footnotes footnotes-end-of-document"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>

<ol>
<li id="fn1"><p>There’s a possible <em>de re</em>/*de dicto confusion here, but pay no attention to that.↩︎</p></li>
</ol>
</section></div> ]]></description>
  <category>measurement</category>
  <category>academia</category>
  <guid>http://www.chrishanretty.co.uk/posts/mids_pt2/</guid>
  <pubDate>Mon, 02 Sep 2024 23:00:00 GMT</pubDate>
</item>
<item>
  <title>Minimal important differences in the social sciences, part 1</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/mids_pt1/</link>
  <description><![CDATA[ 





<p>If I told you that a weight loss drug would cause you to lose fourteen kilograms, give or take four kilograms, I think you would be impressed.<sup>1</sup></p>
<p>If I told you that a weight loss drug would cause you to lose fourteen grams, give or take four grams, I think you would be less than impressed. You might say that a difference of fourteen grams “does not matter”, or is “inconsequential” or is not “substantively significant” – and these are just the polite things you might say to me.</p>
<p align="center">
<iframe src="https://giphy.com/embed/aaAJVq2pAkuPK" width="480" height="360" style="" frameborder="0" class="giphy-embed" allowfullscreen="" align="center">
</iframe>
</p>
<p>Somewhere between fourteen grams and fourteen kilograms the effects of a weight loss drug start to <em>matter</em>, or become <em>consequential</em>, or became <em>substantively significant</em>. I’m going to call that point the <em>minimal important difference</em>, or MID.</p>
<p>I don’t know what the MID is for weight loss treatments: I’m not an expert on weight loss.<sup>2</sup></p>
<p>I do think that the MID for weight loss <em>exists</em>. I also think it’s a good idea to concentrate resources (time, attention, money) on treatments which have effects bigger than the MID, compared to treatments which have effects smaller than the minimal important difference, assuming everything about the treatments other than their effect size is the same.</p>
<p>I think that what is true of weight loss is also true of lots of outcomes in the social sciences, even where these outcomes are regarded by almost everyone as normatively very important. For example: whilst I think that higher levels of democracy are always better, I think that there are some differences in levels of democracy which are not substantively significant.</p>
<p>This blog post is one of two describing how we can establish MIDs in the social sciences. In this post, I’ll look at how we can set a lower bound for the MIDs by looking at the <em>minimal detectable change</em>. In a sequel, I’ll look at a more specific case where researchers are indifferent between multiple measures of the same concept. I’ll argue that indifference between rival measures implies indifference to changes of less than a specified amount.</p>
<section id="the-minimal-detectable-change" class="level1">
<h1>The minimal detectable change</h1>
<p>Measurement – at least for continuous quantities – is never exact. This is true for ordinary observable quantities as well as for the social scientist’s latent constructs. In the recent summer Olympics, times in swimming competitions were recorded to the hundredth of a second, rather than to the thousandth of a second.</p>
<p><a href="https://meangreenmath.com/2016/09/29/this-is-why-there-are-so-many-ties-in-swimming/">The reason is rather prosaic</a>: although it’s possible to record elapsed time to the thousandth of a second, it’s not possible to construct swimming pools with tolerances of less than a millimetre, and so any difference of less than a hundredth of a second may be due to minute differences in the length of the lanes.</p>
<p>There is therefore some sense in which a difference of less than a hundredth of a second is not important. If it were important, we’d start constructing swimming pools the same way we construct particle accelerators.</p>
<p align="center">
<iframe src="https://giphy.com/embed/KsgQUUDjcvXstTB8Ac" width="480" height="269" style="" frameborder="0" class="giphy-embed" allowfullscreen="">
</iframe>
</p>
<p>Social scientists tend not to talk about tolerances, but about the standard error of measurement. This standard error of measurement comes up in different guises:</p>
<ul>
<li>Maybe you have a psychometric test estimated under the assumptions of classical test theory, and you have a known standard error of measurement.</li>
<li>Maybe you have some rates of intercoder reliability and have converted a reliability statistic to a standard error of measurement.</li>
<li>Maybe you have a Bayesian measurement model and approximate the standard error of measurement by the posterior standard deviation of some parameter.</li>
</ul>
<p>If you are in the first two categories; you have a single standard error of measurement; if you are in the last category; you have as many standard errors of measurement as you have measured parameters. You will therefore want to replace references to <em>the</em> standard error of measurement with the <em>smallest</em> standard error of measurement.</p>
<p>If you have a standard error of measurement, you can work out the minimum detectable change, or <a href="https://doi.org/10.1093/ptj/pzac068">“the amount of change needed to exceed measurement error for a specific measure based on a predetermined confidence threshold”</a>. We may suppose that any two measures we care to compare are draws from independent normal distributions which have different means (the true scores we want to estimate but can never know) but identical standard deviations (the standard error of measurement). The difference between two normal distributions is distributed normally with standard deviation equal to the square root of the sum of the two variances. If we want to make claims about differences at the 95% level of significance,</p>
<p><span id="eq-mdc"><img src="https://latex.codecogs.com/png.latex?%0A%5Cmathrm%7BMDC%7D%20=%201.96%20%5Ctimes%20%5Csqrt%7B2%7D%20%5Cmathrm%7BSEM%7D%0A%5Ctag%7B1%7D"></span></p>
<p>where SEM is the standard error of measurement. If you’re a Bayesian, and if you have access to the posterior distributions needed, you might want to ignore this useful equation and calculate the probability that a difference is greater than zero directly.</p>
</section>
<section id="the-mdc-for-electoral-democracy" class="level1">
<h1>The MDC for electoral democracy</h1>
<p>Let’s use as an example the minimal detectable change for electoral democracy. For this I’ll use data from the V-Dem project, and values of their variable <code>v2x_polyarchy</code> for the post-war period. I’ll also use the posterior standard deviation (<code>v2x_polyarchy_sd</code>) as an equivalent of the standard error of measurement.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(vdemdata)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"vdem"</span>)</span>
<span id="cb1-3">vdem <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> vdem <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">subset</span>(year <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1945</span>,</span>
<span id="cb1-5">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">select =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(country_text_id, year, v2x_polyarchy, v2x_polyarchy_sd)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb1-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">subset</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(v2x_polyarchy))</span>
<span id="cb1-7"></span>
<span id="cb1-8">smallest_posterior_sd <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(vdem<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>v2x_polyarchy_sd)</span></code></pre></div></div>
</div>
<p>Specifically, I’ll use the <em>smallest</em> posterior standard deviation. In part because of the way the V-Dem scores are transformed to the range [0-1], the standard deviations are smallest at low values. The V-Dem project as a whole is most confident about the levels of electoral democracy in Eritrea in 2007. (Spoiler: they’re pretty confident there wasn’t much). The posterior standard deviation for this country year is 0.002 units on a 0-1 scale.</p>
<p>If we multiply this quantity by 1.96 and againt by the square root of two, we get a figure of 0.0055 units. To put it on a different metric, that’s roughly 0.02 standard deviations.</p>
<p>This MDC gives a rationale for only reporting V-Dem figures to two decimal places, because any information in that third decimal place is smaller than the minimum detectable change.</p>
<p>It is possible to give a different minimum detectable change depending on the research question. This alternative figure can be larger or smaller.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">conditional_posterior_sd <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> vdem <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">subset</span>(v2x_polyarchy <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>)</span>
<span id="cb2-3"></span>
<span id="cb2-4">conditional_posterior_sd <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> conditional_posterior_sd<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>v2x_polyarchy_sd <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>()</span></code></pre></div></div>
</div>
<p>Here’s an example of a larger MDC. Perhaps you are interested in democratic back-sliding, and want to focus on countries which score above 0.4 on this 0-1 scale. Recall that the V-Dem project tends to be more confident about low scores on their democracy measures. When we restrict ourselves to cases which score above 0.4, the smallest posterior standard deviation is 0.019. This in turn means that the MDC is around 0.05 units. This is an order of magnitude greater than what we had before. For comparison: levels of electoral democracy in the UK since 2000 have never ranged by more than 0.04 units (from 0.84 to 0.88).</p>
<p>It’s also possible to argue for a smaller MDC by shifting the unit of analysis. Suppose that we were not interested in country-years, but in regional averages. For independent measures, the standard error of measurement decreases with the square root of the number of observations. If our regions have thirty-six countries in them, the MDC is smaller by a factor of 6. If we really formed our ideas of what was detectable (and, <em>a fortiori</em>, important) by thinking first about regional averages, this might be a good MDC to use. I tend not to think “region-first”, but maybe you do.</p>
</section>
<section id="is-the-mdc-for-democracy-a-mid" class="level1">
<h1>Is the MDC for democracy a MID?</h1>
<p>I don’t think anything in the previous section is particularly controversial. It’s as good a guide to the MDC as you can get without having access to the full posterior distribution for the V-Dem variable in question.<sup>3</sup></p>
<p>What is more controversial is the idea that the minimum detectable change should set a lower limit on the minimal important difference.</p>
<p>There is a good pragmatic argument, which says that for any putative change in one direction, you should not hold it out to be important if later more accurate measurement would show that it was in fact a change in the opposite direction.</p>
<p>This pragmatic argument, however, only works in the context of the measures we have. It is perfectly consistent to say that the minimal important difference is in fact smaller than the minimum detectable change, and for that reason we should improve our measurement techniques.</p>
<p>I think the strongest context for this argument comes from conflict deaths. One of my <a href="https://pure.royalholloway.ac.uk/en/persons/michael-spagat">colleagues at Royal Holloway</a> works a lot on the measurement of conflict deaths. His <a href="https://ojs.ub.uni-konstanz.de/srm/article/view/2373">paper on survey measurement of conflict deaths in Iraq</a> shows that estimates of the number of conflict deaths in Iraq differ by one and a half orders of magnitude, from 26,000 to 1.0 million. If the differences between estimates represented the standard error of measurement rather than poor research conduct, we would be placed in a position where the minimum detectable change involved several thousand deaths. That seems wrong. Maybe we should just get better at measuring conflict casualties – a sort of “git gud” approach to substantive significance.</p>
<p>The pragmatic argument does, however, seem to work for measures of electoral democracy. It would <em>in principle</em> to be possible to improve the V-Dem project by involving more experts per country, and to increase its scope by extending the analysis not just forward (at a rate of one year per year) but backwards. The increase in the number of country experts would improve the accuracy; the increase in the number of country-years can only make the smallest posterior standard deviation smaller.</p>
<p>In practice, however, the V-Dem project is one of the best funded social science projects in history, and the project has literally unrivalled temporal and geographic coverage. In what follows, I’ll look at other big projects which have near complete coverage of the units of analysis.</p>
</section>
<section id="mdcs-for-other-variables" class="level1">
<h1>MDCs for other variables</h1>
<section id="party-positions" class="level2">
<h2 class="anchored" data-anchor-id="party-positions">Party positions</h2>
<p>The <a href="https://manifesto-project.wzb.eu/">Manifesto Project</a> generates estimates of parties’ left-right positions in different ways based on the content of their manifestos. It allows researchers to calculate bootstrapped standard errors for each document.</p>
<p>Let’s suppose we use the <a href="https://doi.org/10.1111/j.1939-9162.2010.00006.x">logit RILE measure</a>. This variable has a mean close to zero, a standard deviation close to one, and fat tails which mean that there are some observations with values greater than plus or minus three.</p>
<p>The lowest standard error in the data has a value of just under 0.024 units. This means that the minimal detectable change is around 0.06 units, or 0.07 standard deviations. This is a change roughly equal to the change in the Liberal Democrats’ (putative) left-right position between 2017 and 2019.</p>
</section>
<section id="left-right-positions-of-supreme-court-justices" class="level2">
<h2 class="anchored" data-anchor-id="left-right-positions-of-supreme-court-justices">Left-right positions of Supreme Court justices</h2>
<p><a href="http://mqscores.wustl.edu/">Martin-Quinn scores</a> are annual estimates of the positions of justices on the Supreme Court of the United States. They’re estimated using a Bayesian item response model, and the authors report the posterior standard deviation. The mean score is close to zero; the standard deviation across all judge years is close to two.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">mq <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"http://mqscores.wustl.edu/media/2022/justices.csv"</span>)</span></code></pre></div></div>
</div>
<p>The justice with the smallest posterior standard deviation is Byron White, who served on the court for a long time (1962 - 1993) and who was located close to the court median. The posterior standard deviation for White in 1967 is 0.141 units. This implies that the minimum detectable change is 0.4 units, or just under 0.2 standard deviations. Considering the most recent Martin-Quinn scores, this difference is roughly the difference between a Brett Kavanaugh and an Amy Cony Barrett.</p>
</section>
<section id="pledge-fulfillment" class="level2">
<h2 class="anchored" data-anchor-id="pledge-fulfillment">Pledge fulfillment</h2>
<p>Pledge fulfillment is the proportion of a parties’ promises which are fulfilled before the next election. Measuring pledge fulfillment requires researchers to work out which statements are pledges, and which pledges have been (fully or partly) fulfilled. Both of these tasks are subjective. The authors of the <a href="https://doi.org/10.1111/ajps.12313">leading study on pledge fulfillment</a> therefore report rates of agreement between coders. Across pairs of researchers, the average rate of agreement on pledge <em>fulfillment</em> (not pledge identification) was 93%.</p>
<p>I’m sure there’s a formula which will allow me to calculate between percentage agreement and other reliability statistics, but I took the cheat’s way out and simulated some fake data. Here I use the <code>IRRsim</code> package to simulate data with 100 raters, 100 “events” (pledges) and three categories, collapsing these to top-two versus all else. This gives data which approximates the pledge fulfillment data.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse)</span></code></pre></div></div>
<div class="cell-output cell-output-stderr">
<pre><code>── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.2     ✔ tibble    3.2.1
✔ lubridate 1.9.4     ✔ tidyr     1.3.1
✔ purrr     1.0.4     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (&lt;http://conflicted.r-lib.org/&gt;) to force all conflicts to become errors</code></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(IRRsim)</span>
<span id="cb6-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">26943</span>)</span>
<span id="cb6-3">tmp <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> IRRsim<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">simulateRatingMatrix</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nLevels =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, </span>
<span id="cb6-4">                             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, </span>
<span id="cb6-5">                             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">k_per_event =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>, </span>
<span id="cb6-6">                             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">agree =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.93</span>, </span>
<span id="cb6-7">                             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nEvents =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb6-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb6-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">across</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">everything</span>(), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(x <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)))</span>
<span id="cb6-10">sem <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colMeans</span>(tmp))</span>
<span id="cb6-11">mdc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">qnorm</span>(.<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">975</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> sem</span></code></pre></div></div>
</div>
<p>The minimum detectable change is 3.3 percentage points, or just under 0.07 standard deviations. In other terms, that’s slightly less than the average pledge fulfillment ratio amongst UK governing parties (86%) and the Swedish minority coalition led by Fredrik Reinfeldt.</p>
</section>
</section>
<section id="conclusions" class="level1">
<h1>Conclusions</h1>
<p>In this post I’ve suggested one way that we can established minimal important differences for outcomes in the social sciences, at least for those outcomes which are measured on a continuous scale with some reported standard error of measurement (or something analogous).</p>
<p>I’ve applied this to four measures – levels of democracy, left-right positions of political parties, left-right positions of judges on SCOTUS, and rates of pledge fulfillment.</p>
<p>I’ve noted that the MDC depends on how the unit of analysis is characterised. Some measures – like seat-share weighted cabinet positions – are measured on the same scale as constituent units, but we can be more precise when dealing with aggregates. The situation would be more complicated with measurements which depend on two noisy inputs.</p>
<p>In the next blog, I’ll look at how we might instead establish minimal important differences in the case where we are indifferent between two rival measures. This can be applied to cases where both measures are measured ostensibly without error, and generally gives larger MIDs.</p>


</section>


<div id="quarto-appendix" class="default"><section id="footnotes" class="footnotes footnotes-end-of-document"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>

<ol>
<li id="fn1"><p>This is roughly the effect of semaglutide / Wegovy, according to <a href="https://www.nature.com/articles/s41591-022-02026-4">this study</a>; effect sizes in weight loss are more commonly specified in percent, and so I have multiplied the percentage point effect size (-15.2) by the average weight of the trial participants (106 kg). I think it’s fair to say that Wegovy has been broadly recognised as a major new development in the treatment of weight loss.↩︎</p></li>
<li id="fn2"><p>Experts on weight loss, as you might expect, have written about this. <a href="https://doi.org/10.1186/s12916-014-0175-5">This paper</a> suggests that most funding agencies use a minimal important difference of five percent, but at the same time it argues that the MID should really be higher, at around twenty percent, which would mean that the effects of Wegovy are less than the MID.↩︎</p></li>
<li id="fn3"><p>The full posterior distributions are incredibly unwieldy, and very infrequently updated. I would not recommend that you work with them unless you have a lot of time, a lot of working memory, and incredible patience.↩︎</p></li>
</ol>
</section></div> ]]></description>
  <category>measurement</category>
  <category>academia</category>
  <guid>http://www.chrishanretty.co.uk/posts/mids_pt1/</guid>
  <pubDate>Mon, 26 Aug 2024 23:00:00 GMT</pubDate>
</item>
<item>
  <title>When the biggest party doesn’t form the government</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/biggest_party_no_govt/</link>
  <description><![CDATA[ 





<p>Charlotte Minvielle, a former candidate for the New Popular Front (NFP), has <a href="https://www.theguardian.com/commentisfree/article/2024/aug/09/france-president-power-emmanuel-macron-system?CMP=Share_iOSApp_Other">an article in the Guardian</a> in which she criticises Emmanuel Macron’s reluctance to consider a government led by the NFP, and calls for a Sixth Republic. (Hat-tip to Declan Gaffney for drawing my attention to it).</p>
<p>Although I think the NFP should have the first chance to form a government, and although I believe that parliamentarism is superior to both presidentialism and semipresidentialism, I disagree with Minvielle when she writes</p>
<blockquote class="blockquote">
<p>“In any parliamentary democracy, the political force with the most elected representatives is allowed to form, and lead, a government. This is not the case in France, an anomaly in a region predominantly characterised by parliamentary democracies such as the UK, Spain and Germany”</p>
</blockquote>
<p>This is not true, even in the countries Minvielle mentions. Betwen 1972 and 1983 the CDU/CSU was the largest political force in the Bundestag, but between 1974 and 1982 the Social Democratic Party governed with the FDP.</p>
<p>Coalitions excluding the largest party are moderately common in Scandinavia, where Minvielle has campaigned. For example: the Social Democrats won the most seats in the 2022 Riksdag election, but the present Swedish government is a right-wing coalition led by the Moderates.</p>
<p>We can go beyond citing specific counterexamples and show the rate at which the largest party fails to enter government. I’ll do this using data from ParlGov, which collects data on election results and government participation in a large set of (mostly parliamentary, mostly European) democracies.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">suppressPackageStartupMessages</span>({<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse)})</span>
<span id="cb1-2">pg_url <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"https://parlgov.org/data/parlgov-development_csv-utf-8/view_cabinet.csv"</span></span>
<span id="cb1-3"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.exists</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"view_cabinet.csv"</span>)) {</span>
<span id="cb1-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">download.file</span>(pg_url,</span>
<span id="cb1-5">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">destfile =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"view_cabinet.csv"</span>)</span>
<span id="cb1-6">}</span>
<span id="cb1-7">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"view_cabinet.csv"</span>)</span></code></pre></div></div>
</div>
<p>I’m going to exclude caretaker governments and pre-1945 governments.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(caretaker <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">election_date =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.Date</span>(election_date),</span>
<span id="cb2-4">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">start_date =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.Date</span>(start_date)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(election_date <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.Date</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1945-01-01"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb2-6">    dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(country_name_short,</span>
<span id="cb2-7">                  cabinet_id, cabinet_name, start_date,</span>
<span id="cb2-8">                  election_id, election_date, </span>
<span id="cb2-9">                  party_name_short, cabinet_party, prime_minister, seats)</span></code></pre></div></div>
</div>
<p>Within each cabinet, I’m going to keep only the largest party. I’ll then ask whether that largest party is in the government.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">largest_party <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(cabinet_id, election_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Start largest first</span></span>
<span id="cb3-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(seats)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-5">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### take the top row within each cabinet</span></span>
<span id="cb3-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">slice</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-7">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### remove that grouping</span></span>
<span id="cb3-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-9">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### just focus on a single variable rather than the whole dataframe</span></span>
<span id="cb3-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pull</span>(cabinet_party) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-11">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### get the mean of this variable</span></span>
<span id="cb3-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>()</span>
<span id="cb3-13"></span>
<span id="cb3-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(largest_party <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 83</code></pre>
</div>
</div>
<p>Thus, for governments that ParlGov knows about between 1945 and the end of 2023, around 83% featured the largest party – which of course means that 17% didn’t.</p>
<p>This figure includes governments that formed immediately after an election and governments that formed after a post-election cabinet collapsed. Let’s see how the figure changes when we focus on post-election cabinets only.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">largest_party <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb5-2">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(election_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb5-3">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### pick rows from the earliest starting government</span></span>
<span id="cb5-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(start_date <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(start_date)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb5-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(election_id, cabinet_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb5-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### Start largest first</span></span>
<span id="cb5-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(seats)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb5-8">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### take the top row within each cabinet</span></span>
<span id="cb5-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">slice</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb5-10">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### remove that grouping</span></span>
<span id="cb5-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb5-12">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### just focus on a single variable rather than the whole dataframe</span></span>
<span id="cb5-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pull</span>(cabinet_party) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb5-14">    <span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">### get the mean of this variable</span></span>
<span id="cb5-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>()</span>
<span id="cb5-16"></span>
<span id="cb5-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(largest_party <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 85</code></pre>
</div>
</div>
<p>When we look only at governments that formed after an election, 85% of governments included the largest party. This means that even in this most favourable case, around one in every seven governments doesn’t include the largest party.</p>
<p>When something happens in one in seven of the cases you’re analysing, it can’t be dismissed as an exception to a general rule. Although there are good reasons why the largest party has a claim to enter into government, that claim isn’t conclusive. We elect legislatures to decide by majority, and if you cannot find a legislative majority to support you that is a problem for your potential government, whether or not your government includes the largest party.</p>



 ]]></description>
  <category>parties</category>
  <category>elections</category>
  <category>coalitions</category>
  <guid>http://www.chrishanretty.co.uk/posts/biggest_party_no_govt/</guid>
  <pubDate>Thu, 08 Aug 2024 23:00:00 GMT</pubDate>
</item>
<item>
  <title>The single party majority limbo</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/single_party_majority_limbo/</link>
  <description><![CDATA[ 





<p>In last week’s UK election, the Labour party managed to win 412 of 650 seats (63.4%) on 33.7% of the vote.</p>
<p>This is the lowest share of the vote to win a majority in British electoral history.</p>
<p>It made me wonder whether any other elections have seen a single party win a majority on such a low share of the vote.</p>
<p>Answering this question is more difficult than it may seem, for two reasons.</p>
<p>First, “share of the vote” is not altogether simple. In two round systems, or in systems which use multiple tiers, there are two sets of vote shares. In the 2014 Japanese general election, the LDP won 291/475 (61% of seats) – but was its vote share 33.11%, the proportion of votes it received in the proportional tier, or 48.1%, the proportion of votes it received in the constituency tier?</p>
<p>Second, although we have good coverage of consolidated parliamentary democracies with populations of greater than a million, we often lack information on elections to legislatures in micro-states. Often these elections are ones where we see high levels of disproportionality.</p>
<p>In what follows, I’ll be using data from <a href="https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/OGOURC">ElectionsGlobal</a>, which covers the period up to 2015, and I’ll be focusing on “simple” electoral systems, where voters express a single preference which determines party seat shares. I’ve manually pruned the list to the three genuine cases where a party has won a majority on a vote share less than that won by the Labour party.</p>
<p>With that said, let’s make our way down the list.</p>
<section id="somalia-1969" class="level1">
<h1>Somalia 1969</h1>
<p>Between independence in 1960 and Siad Barre’s coup in 1969, Somalia held two elections which were genuine multiparty contests, and which might have been free and fair if you don’t look too closely at some of the reported vote totals. In both of these elections, the Somali Youth League won a majority of seats. In the 1964 election, it won a majority of seats with a majority of votes. Five years later, it won a <strong>73/127 = 57% of seats on a third of the vote</strong> (33.24%). It was only able to do this due to the remarkable fragmentation of the vote: per <a href="https://en.wikipedia.org/wiki/1969_Somali_parliamentary_election">Wikipedia</a>, 26 parties won election to the legislature.</p>
</section>
<section id="norway-1915" class="level1">
<h1>Norway 1915</h1>
<p>The 1915 election was the penultimate Norwegian election held under first-past-the-post, and looking at the result it’s not hard to see why. The Liberal party won <strong>74/123 = 60% of seats on a third of the vote</strong> (33.07%). Following the election</p>
<blockquote class="blockquote">
<p>“all parties acknowledged that the situation was such that this could no longer continue, and a better electoral rule should be found, a more just electoral rule” (Gunnard Knudsen, quoted in <a href="https://doi.org/10.1177/0010414018762369">Cox, Fiva and Smith</a> )</p>
</blockquote>
<p>In fact it would take the perverse results of the 1918 election, where Labour came first in terms of votes but third in terms of seats, before electoral reform could be approved.</p>
</section>
<section id="grenada-1995" class="level1">
<h1>Grenada 1995</h1>
<p>I don’t know a lot about Grenada. I would have expected that a small micro-state with an assembly size of just 15 would have a two-party system. But here comes the New National Party, winning <strong>8/15 = 53% of seats on 32.4% of the vote</strong>, with the two remaining parties splitting most of the remainder of the vote between them, whilst still leaving space for the “Good Old Democratic Party”, who surely must be the least successful political party to have <a href="https://en.wikipedia.org/wiki/Good_Old_Democratic_Party">its own Wikipedia page</a>.</p>
</section>
<section id="honourable-mentions" class="level1">
<h1>Honourable mentions</h1>
<p>The Fijian election of 1999 would have made the list, but for the use of the Alternative Vote in constituencies of two types, meaning that the vote share of the Fiji Labour party (33.26%) is based on first preferences in the “open constituencies” rather than communal constituencies.</p>
<p>The South African election of 1910 would have made the list if I were included contested elections in non-democratic systems; if it were included, it would be at the top of the list, with Botha’s National Party winning a majority despite winning fewer votes than the Unionist Party (28.5% versus 37.7%).</p>


</section>

 ]]></description>
  <category>parties</category>
  <category>elections</category>
  <guid>http://www.chrishanretty.co.uk/posts/single_party_majority_limbo/</guid>
  <pubDate>Sat, 06 Jul 2024 23:00:00 GMT</pubDate>
  <media:content url="http://www.chrishanretty.co.uk/posts/single_party_majority_limbo/limbo.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Why wait for Survation?</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/why_wait_for_survation/</link>
  <description><![CDATA[ 





<div class="callout callout-style-default callout-warning callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Warning
</div>
</div>
<div class="callout-body-container callout-body">
<p>The election has now come and gone, and the thing I said definitely wouldn’t happen – Labour winning fewer seats than they won in 1997 – has in fact happened. It seems that the reasons for our failure were connected to the second failure mode – a failure to get the overall vote shares right. The fact that Labour achieved such a large number of seats on such a low vote share suggests that they were efficient and that swing away from the Conservatives was proportional rather than uniform.</p>
</div>
</div>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>Since this was written, there have been two delayed data drops. All fieldwork was conducted before polls opened. An update of Wednesday evening predicting Labour on 475 can be found <a href="https://t.co/gfapsCgKHs">here</a>; an update of Thursday which predicts Labour of 470 can be found <a href="https://www.survation.com/final-survation-mrp-projection-of-the-2024-general-election/">here</a>. These last-minute updates are regrettable, but these models take a long time to run, and as a result it is not always possible for all the scheduled data to come in. There have been no code changes between these updates, just a couple of hundred new data points and some longer runs.</p>
</div>
</div>
<p>Yesterday Survation <a href="https://www.survation.com/survation-mrp-labour-99-certain-to-win-more-seats-than-in-1997/">published</a> an update from their MRP model, a model with which I have been closely involved.</p>
<p>The model predicts a Labour seat tally of 484, on a Labour vote share of 42%. The Conservatives are predicted to win 64 seats, on a vote share of 23%.</p>
<p>The forecast – and this close to the election we can probably dispense with the distinction between forecasting and nowcasting – has been roundly described as “punchy”.</p>
<p>Some might even describe it as “courageous”, but more in the <a href="https://www.youtube.com/watch?v=ik8JT2S-kBE&amp;ab_channel=wakeup2thelies">Yes Minister</a> sense of the word than implying any particular virtue on our part.</p>
<p>Because the forecast is “punchy”, I thought it might be helpful to discuss the main two failure modes of an MRP forecast:</p>
<ul>
<li>First, we might have got the mapping between national vote share and seats wrong. Labour might win as many votes as we think, they’ll just be in different places, leading to a lower seat haul.</li>
<li>Second, we might have got the vote shares wrong: Labour might win fewer votes than we think, and/or the Conservatives more.</li>
</ul>
<p>I’m going to consider these two failure modes in order to explain why I felt confident about the claim that Labour are almost certain to win more seats than they did in 1997. This claim is particularly important to me because I don’t want to be associated (again) with ruling out something that then went on to happen, as I did in 2015 when I said there was almost no chance of a Conservative majority.</p>
<p>I’m going to start with the mapping between national and local. We model how respondents say they’ll vote, and then make predictions at the local level. We do this because we believe there’s no simpler way of doing – no axiomatic rule that allows us to say that a party with such and such share of the vote should win x or y percent in this area. However, it is helpful to consider some simple rules as reference points, and evaluate our forecast in that light.</p>
<section id="historical-uk-and-comparative-reference-points" class="level1">
<h1>Historical UK and comparative reference points</h1>
<p>One reference point is to look at past historical elections where there was a large gap between the first and second-placed, and first and third placed parties, and see what share of seats the first-placed party won. I focus on the gap between first and second because under first past the post it’s not enough to do well in an absolute sense: you also have to be ahead of your opponent. A vote share of 48% can win you almost all of the seats if your nearest opponent is on 24%; it can lose you almost all of the seats if your nearest opponent is on 52%.</p>
<p>In post-war UK electoral history, the two elections with a big lead are the elections of 1997 and 1983. In 1997, Labour polled 12.8 percentage points ahead of the Conservatives in Great Britain, and won 418 seats, albeit in a slightly larger House of Commons of 659. At present, Labour’s share of the vote is lower than it was in 1997, but its lead over the Conservative party is greater. If the Labour lead is greater than 1997, then maybe the Labour seat count will be bigger too.</p>
<p>In 1983, the Conservatives polled almost sixteen percentage points ahead of Labour in Great Britain, and won 397 seats. At present, Labour’s share of the vote is lower than the Conservative share was in 1983, but their lead is once again greater. This example is less favourable to Labour, in that it implies that you can rack up a sixteen point lead and still not break four hundred, but sixteen points is less than what we see at present.</p>
<p>More generally we can look at <em>all</em> post-war democratic elections and examine those elections which were held under first-past-the-post, and plot the gap to second place against the leading party’s seat share.</p>
<div class="cell">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="http://www.chrishanretty.co.uk/posts/why_wait_for_survation/index_files/figure-html/unnamed-chunk-1-1.png" class="img-fluid figure-img" width="864"></p>
<figcaption>Gap between first and second party by seat share (horizontal axis) against first party’s share of seats (vertical axis)</figcaption>
</figure>
</div>
</div>
</div>
<p>I’ve plotted that using data from <a href="https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/OGOURC">ElectionsGlobal</a> combined with information from <a href="https://mattgolder.com/elections">Democratic Electoral Systems</a> in order to restrict my analysis to elections held under first past the post. I’ve also added a polynomial trend line to show what we might expect at different leads, if we knew nothing other than the gap between the first- and second-placed party. The trend line fits the two UK elections just mentioned quite well.</p>
<p>The suggestion from the trend line is that if you have a lead of around 19%, you might expect to win 68% of seats, or (0.68 * 650) = 442 seats.</p>
<p>Comparative evidence therefore suggests that if you knew nothing about the election except the Labour lead over the Conservatives and the fact that the election is being contested under first-past-the-post, then you would predict a very large seat share. This comparative evidence is in line with two UK historical examples, which would predict that the Labour seat share in 2024 should be greater than the Labour seat share in 1997, or the Conservative seat share in 1983, because the Labour lead is bigger than either party’s lead was in those two elections.</p>
</section>
<section id="uniform-and-proportional-swing" class="level1">
<h1>Uniform and proportional swing</h1>
<p>At this point it might reasonably be objected that we do in fact know more than simply the Labour lead over the Conservatives and the fact that the election is being held under first-past-the-post. We know past support for each party in each seat from notional election results. This can help us predict seat counts under an assumption of uniform national swing, such that if Labour is up so many percentage points, we can add that to their performance last time, and by repeating this for all parties, calculate who is in the lead in each seat.</p>
<p>John Curtice has <a href="https://www.bbc.co.uk/news/articles/cl7y2xj728do">helpfully</a> calculated the seat count under uniform national swing using an average of vote shares from different MRP models. Under UNS, you get a Labour total of 370, with the SNP on 34. This calculation precedes the most recent Survation update.</p>
<p>Uniform national swing does have a tremendous record in predicting seat outcomes. It is very useful, but it does have some limitations. The main limitation is that it can create negative values where a party’s national vote share goes down by more than it previously won in a seat. (The converse, where adding an increase to a party’s national share would take its local share to greater than 100%, is rarely if ever seen). Since parties cannot win negative votes, then any national change which implies negative votes in some places means that the change must be less than uniform (i.e., less steep) in some places, and correspondingly more than uniform (i.e., steeper) in some other places. Sometimes the label used more this type of swing is proportional, since the amount of swing is proportional to how well the party did previously.</p>
<p>Usually this limitation of uniform national swing is not a serious limitation, and is very rarely a serious problem for one of the two largest parties. However, the likely change in the Conservative vote is so large than applying uniform national swing creates some problems. If we suppose a change in the Conservative vote share of twenty points, then there are almost ninety seats where uniform national swing would create negative Conservative vote share. If we sum up the negative votes predicted, that’s almost 350,000 extra votes which have to come from other seats, or roughly one percent of the national vote share. This means that the Conservatives would need to lose one percentage point <em>more</em> than their nation-wide loss in all the other seats just to make the sums add up. If we suppose that the Conservative vote never reaches exactly zero, but falls to one or two percent, then the figures become even greater.</p>
<p>Uniform national swing will therefore be placed under severe pressure in this election, and there is no golden rule saying that when UNS is under pressure, it will emerge triumphant. <a href="https://electionsetc.com/2024/06/26/breaking-the-swingometer-historical-precedents-for-proportional-change/">Steve Fisher and Jake Dibden</a> have helpfully analysed cases where parties have suffered large national swings, and examined the proportionality of their swing in these cases. The conclusion is that proportional swing can well happen when there are large national swings.</p>
<p>What I take from these two analyses is that uniform national swing sets a plausible lower bound on the Labour seat tally, and that we should therefore expect a figure greater than 370. “How much greater” is, of course, a matter of further analysis, and the point of MRP modelling is to take the analysis to the level of the voter and make post-stratified predictions. Our election models in 2017 and 2019, conducted for private clients in the financial sector, were reasonably accurate in terms of the headline seat counts, and for that reason we opted to retain the model we had used for 2019, without making any adjustments to account for <a href="https://twitter.com/kevcunningham/status/1808354000988787156">attenuation</a>.</p>
</section>
<section id="getting-the-headline-figures-wrong" class="level1">
<h1>Getting the headline figures wrong</h1>
<p>The discussion of comparative reference points and models of swing suggest that even if our mapping between national vote share and seat level outcomes is wrong in the specific sense of being too favourable to Labour, then we would still expect a very big Labour figure based on Labour’s lead over the Conservative party and its change in the share of the vote since last time.</p>
<p>The second failure mode of MRP models is that they get the national shares wrong. Because the national shares are just aggregates of what we predict at local level, if we get the national shares wrong it means we’ve also gotten the local results wrong.</p>
<p>We might get it wrong because MRP relies on polling, and because the errors in modern polling are not the kinds of errors that result from simple random sampling. Opinion pollsters rely on people who opt-in to internet panels or who pick up the phone to queries from polling companies. These people are different from the general population. Although we can adjust for some of these differences – and in particular, we adjust for age, sex, highest level of qualifications, past vote, and constituency – we cannot adjust for characteristics for which we have no national reference point, like “political interest” or “agreeableness”, neither of which feature on the Census (though maybe they should).</p>
<p>It is therefore possible that although the samples used for MRP are very large, they could be very wrong. If there is a polling miss of the same direction and magnitude as there was in 1992 or 2015, our seat forecasts would be very wrong. Most big polling misses are collective misses, but here there is a canary in the mine: polls like the most recent poll from <a href="https://www.veriangroup.com/press-release/uk-polling-02-july-2024">Verian</a>, a company which I greatly respect, suggest a very different picture, with a 15 point Labour lead over the Conservatives (36 over 21).</p>
<p>The question to ask, therefore, is: could the polls be wrong? This question was extensively discussed at a recent British Polling Council event on the 5th June. The general conclusion from that event was that there was very little evidence from Westminster by-elections or local elections to suggest that they are very wrong. In particular, I took heart from one random probability sample by Verian, which at the time was giving very similar national vote shares to our MRP model at the time. Random probability samples, which involve drawing people at random from a list and repeatedly going back to them until they answer, are an expensive gold standard.</p>
<p>My view is therefore that whilst error in the overall vote share is the single greatest point of failure in our model, there is not much evidence to suggest that failure is likely, or more likely than normal. The pattern of failure would have to be quite specific, and (given the random probability sample I mentioned earlier) would likely have to have emerged during the course of the election, either because of opinion change or because of a compositional change which emerges when you weight by turnout likelihood.</p>
</section>
<section id="vibes-check" class="level1">
<h1>Vibes check</h1>
<p>One source of information which I think can be discarded are reports by Labour canvassers who say that they are not detecting the same kinds of enthusiasm which they detected in 1997, and that therefore Labour cannot be on course for a similarly large victory. “Enthusiasm” in some absolute sense does not matter in elections. Our MRP model is not forecasting that Labour will win more votes than they did in 1997, and might for that reason be more popular or the subject of greater enthusiasm. Indeed, we’re only just confident that they’ll poll a greater vote share than they did in 2017. What matters is not enthusiasm for Labour, but a general weariness of the Conservatives. That sentiment does not seem to be in short supply.</p>
</section>
<section id="conclusions" class="level1">
<h1>Conclusions</h1>
<p>This is the kind of forecast that you want if you don’t want to see herding: people who are following an existing model, who trust in the process, and don’t make adjustments to reflect an external view of what seems most likely. Unfortunately it is also the kind of forecast that means that on Friday morning there is a chance that we will have egg on our faces. Right now I am dwelling more on that chance that the chance we will look like seers.</p>


</section>

 ]]></description>
  <category>parties</category>
  <category>polling</category>
  <category>mrp</category>
  <guid>http://www.chrishanretty.co.uk/posts/why_wait_for_survation/</guid>
  <pubDate>Tue, 02 Jul 2024 23:00:00 GMT</pubDate>
  <media:content url="http://www.chrishanretty.co.uk/posts/why_wait_for_survation/seats.png" medium="image" type="image/png" height="87" width="144"/>
</item>
<item>
  <title>How left- or right-wing are parties’ 2024 manifestos?</title>
  <dc:creator>Chris Hanretty</dc:creator>
  <link>http://www.chrishanretty.co.uk/posts/manifestos_2024/</link>
  <description><![CDATA[ 





<p>Roughly two weeks ago most of the parties released their 2024 general election manifestos.</p>
<p>Manifestos are a key source of information about parties’ priorities. They allow us to form expectations about what future governments will do, and allow us to test whether governments did in fact deliver what was promised by the party or parties making up government.</p>
<p>Manifestos are most used in political science as the basis for inferring parties’ positions on a left-right scale, whether that is on the basis of <a href="https://manifestoproject.wzb.eu/down/papers/budge_right-left-scale.pdf">proportions of “right” and “left-wing” (quasi-)sentences</a>, or some more <a href="https://doi.org/10.1177/13540688211026076">complicated</a> <a href="https://doi.org/10.1111/j.1939-9162.2010.00006.x">transformation</a> of those counts.</p>
<p>Placing parties on a left-right scale on the basis of their manifesto usually involves coded parts of that sentence in different pre-defined categories. This work can take a long time if performed by humans. Recently it’s become possible to carry out this coding task automatically using large language models. The <a href="https://huggingface.co/manifesto-project/manifestoberta-xlm-roberta-56policy-topics-context-2023-1-1">Manifesto Project itself has fine-tuned a large language model</a> to categorize manifestos.</p>
<p>In this post, I use that LLM to position the parties on the left-right scale. I’m not the first to do this – <a href="https://x.com/Dr_K_Farnsworth/status/1802238901509149175">Kevin Farnsworth has done the same thing</a> – but I will be sharing all of my <a href="https://github.com/chrishanretty/manifesto_2024">materials on Github</a> in case it’s of use to people. My emphasis is on sharing a first approximation rather than a finished product: if I were using this for an academic article I would want to spend longer cleaning the texts and checking the sentence splitting was working properly.</p>
<section id="what-did-the-parties-talk-most-about" class="level1">
<h1>What did the parties talk most about?</h1>
<p>Our first pass at the data has to involve the different Manifesto Project categories themselves. If we can’t understand the distribution of text across topic codes, we can’t understand anything built on those codes.</p>
<p>With that in mind, here’s the proportion of sentences (or things recognized as sentences by the <code>tidytext</code> package) belonging to the top ten topic codes, in the Labour manifesto.</p>
<div class="cell">
<div id="tbl-lab10" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-lab10-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;1: Top ten topic codes in the Labour manifesto
</figcaption>
<div aria-describedby="tbl-lab10-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<table class="cell caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;">Topic</th>
<th style="text-align: right;">Proportion</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">504 - Welfare State Expansion</td>
<td style="text-align: right;">0.1200652</td>
</tr>
<tr class="even">
<td style="text-align: left;">605 - Law and Order: Positive</td>
<td style="text-align: right;">0.0934960</td>
</tr>
<tr class="odd">
<td style="text-align: left;">305 - Political Authority</td>
<td style="text-align: right;">0.0678734</td>
</tr>
<tr class="even">
<td style="text-align: left;">411 - Technology and Infrastructure</td>
<td style="text-align: right;">0.0569023</td>
</tr>
<tr class="odd">
<td style="text-align: left;">503 - Equality: Positive</td>
<td style="text-align: right;">0.0545345</td>
</tr>
<tr class="even">
<td style="text-align: left;">506 - Education Expansion</td>
<td style="text-align: right;">0.0461089</td>
</tr>
<tr class="odd">
<td style="text-align: left;">301 - Federalism</td>
<td style="text-align: right;">0.0371837</td>
</tr>
<tr class="even">
<td style="text-align: left;">501 - Environmental Protection: Positive</td>
<td style="text-align: right;">0.0366665</td>
</tr>
<tr class="odd">
<td style="text-align: left;">403 - Market Regulation</td>
<td style="text-align: right;">0.0360994</td>
</tr>
<tr class="even">
<td style="text-align: left;">701 - Labour Groups: Positive</td>
<td style="text-align: right;">0.0331945</td>
</tr>
</tbody>
</table>
</div>
</div>
</figure>
</div>
</div>
<p>The top entry – welfare state expansion – is perhaps unsurprising to see in the manifesto of a nominally left-wing party. What might be more surprising are that “law and order: positive” and “political authority” are second and third. These two codes are often taken to be (culturally or generally) “right-wing” codes. Let’s see some sample sentences coded as “law and order: positive” (more accurately: sentences for which “law and order: positive” had the highest probability of membership):</p>
<div class="cell">
<div class="cell-output cell-output-stdout">
<pre><code>Labour will restore neighbourhood policing with thousands of extra officers, and we will equip officers with the powers they need.
 - Labour will end the practice of empty warnings by ensuring knife carrying triggers rapid intervention and tough consequences.
 - Labour will stop the chaos that lets too many criminals act with impunity, turn the page with stronger policing, and rebuild our criminal justice system.
 - We aim to halve knife crime in a decade.
 - We will make it easier for high- performing police forces to charge domestic abuse suspects to speed up the process.
 - Labour will introduce a new Neighbourhood Policing Guarantee, restoring patrols to our town centres by recruiting thousands of new police officers, police and community support officers, and special constables.</code></pre>
</div>
</div>
<p>Now let’s see some sentences which are coded as “political authority”:</p>
<div class="cell">
<div class="cell-output cell-output-stdout">
<pre><code>I am absolutely convinced that Keir Starmer is the leader to deliver the change this country needs.
 - We switched and voted Labour at the local elections.
 - Only Labour can turn the page.
 - Because whether it is crashing the pound to give tax cuts to the richest 1%; degrading public services because of a mess made by the banks; or the failure to invest in clean British energy that left us exposed when Putin invaded Ukraine – so much of what Britain has been through in the past 14 years is explained by a Conservative failure to face the future.
 - In contrast, Labour has been transformed from a party of protest to one that always puts the interests of the country first.
 - I have changed my party.</code></pre>
</div>
</div>
<p>These sentences seem to be divided between sentences positioning Labour as a party which has authority, and sentences criticising the Conservatives for eroding the authority of the state.</p>
<p>If Labour wrote most about welfare state expansion, law and order, and political authority, what did the Conservatives write about?</p>
<div class="cell">
<div id="tbl-con10" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-con10-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;2: Top ten topic codes in the Conservative manifesto
</figcaption>
<div aria-describedby="tbl-con10-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<table class="cell caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;">Topic</th>
<th style="text-align: right;">Proportion</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">504 - Welfare State Expansion</td>
<td style="text-align: right;">0.1164932</td>
</tr>
<tr class="even">
<td style="text-align: left;">411 - Technology and Infrastructure</td>
<td style="text-align: right;">0.0847710</td>
</tr>
<tr class="odd">
<td style="text-align: left;">605 - Law and Order: Positive</td>
<td style="text-align: right;">0.0782575</td>
</tr>
<tr class="even">
<td style="text-align: left;">503 - Equality: Positive</td>
<td style="text-align: right;">0.0532497</td>
</tr>
<tr class="odd">
<td style="text-align: left;">501 - Environmental Protection: Positive</td>
<td style="text-align: right;">0.0437313</td>
</tr>
<tr class="even">
<td style="text-align: left;">506 - Education Expansion</td>
<td style="text-align: right;">0.0398936</td>
</tr>
<tr class="odd">
<td style="text-align: left;">402 - Incentives</td>
<td style="text-align: right;">0.0394108</td>
</tr>
<tr class="even">
<td style="text-align: left;">403 - Market Regulation</td>
<td style="text-align: right;">0.0385882</td>
</tr>
<tr class="odd">
<td style="text-align: left;">703 - Agriculture and Farmers: Positive</td>
<td style="text-align: right;">0.0350385</td>
</tr>
<tr class="even">
<td style="text-align: left;">104 - Military: Positive</td>
<td style="text-align: right;">0.0330753</td>
</tr>
</tbody>
</table>
</div>
</div>
</figure>
</div>
</div>
<p>The table is surprisingly similar. Seven issues appear in both top ten lists. Just to show you that the classifier is not a stopped clock which always spits out the same probabilities of membership in these categories, here’s the top ten list for the Green Party of England and Wales:</p>
<div class="cell">
<div id="tbl-green10" class="cell quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-green10-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table&nbsp;3: Top ten topic codes in the Green party manifesto
</figcaption>
<div aria-describedby="tbl-green10-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="cell-output-display">
<table class="cell caption-top table table-sm table-striped small">
<thead>
<tr class="header">
<th style="text-align: left;">Topic</th>
<th style="text-align: right;">Proportion</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">501 - Environmental Protection: Positive</td>
<td style="text-align: right;">0.1527127</td>
</tr>
<tr class="even">
<td style="text-align: left;">504 - Welfare State Expansion</td>
<td style="text-align: right;">0.1234883</td>
</tr>
<tr class="odd">
<td style="text-align: left;">416 - Anti-Growth Economy: Positive</td>
<td style="text-align: right;">0.0881110</td>
</tr>
<tr class="even">
<td style="text-align: left;">503 - Equality: Positive</td>
<td style="text-align: right;">0.0851554</td>
</tr>
<tr class="odd">
<td style="text-align: left;">403 - Market Regulation</td>
<td style="text-align: right;">0.0426745</td>
</tr>
<tr class="even">
<td style="text-align: left;">605 - Law and Order: Positive</td>
<td style="text-align: right;">0.0421714</td>
</tr>
<tr class="odd">
<td style="text-align: left;">411 - Technology and Infrastructure</td>
<td style="text-align: right;">0.0384761</td>
</tr>
<tr class="even">
<td style="text-align: left;">701 - Labour Groups: Positive</td>
<td style="text-align: right;">0.0360142</td>
</tr>
<tr class="odd">
<td style="text-align: left;">506 - Education Expansion</td>
<td style="text-align: right;">0.0317049</td>
</tr>
<tr class="even">
<td style="text-align: left;">301 - Federalism</td>
<td style="text-align: right;">0.0308639</td>
</tr>
</tbody>
</table>
</div>
</div>
</figure>
</div>
</div>
<p>It is reassuring to see environmental protection as the most common code, and surprising (but not for that less accurate) to see anti-growth or degrowth feature in there.</p>
</section>
<section id="how-left--or-right-wing-are-they" class="level1">
<h1>How left- or right-wing are they?</h1>
<p>Learning about topic codes is important, but part of the reason we come up with lists of codes is in order to reduce complexity. One way of reducing complexity is to code topics as either “left” or “right-wing” based on a salience theory of communication, where parties concerned with equality talk about things they want to use to address inequality (market regulation, nationalisation), rather than engaging in a detailed discussion of why unfettered markets go wrong. That is, parties follow the maxim: “say what you’re for, rather than what you’re against”.</p>
<p>The Manifesto Project’s RILE list of left- and right-wing codes has the following topics as left-wing:</p>
<div class="cell">
<div class="cell-output cell-output-stdout">
<pre><code>103 - Anti-Imperialism
 - 105 - Military: Negative
 - 106 - Peace
 - 107 - Internationalism: Positive
 - 202 - Democracy
 - 403 - Market Regulation
 - 404 - Economic Planning
 - 406 - Protectionism: Positive
 - 412 - Controlled Economy
 - 413 - Nationalisation
 - 504 - Welfare State Expansion
 - 506 - Education Expansion
 - 701 - Labour Groups: Positive</code></pre>
</div>
</div>
<p>and the following topics as right-wing:</p>
<div class="cell">
<div class="cell-output cell-output-stdout">
<pre><code>104 - Military: Positive
 - 201 - Freedom and Human Rights
 - 203 - Constitutionalism: Positive
 - 305 - Political Authority
 - 401 - Free Market Economy
 - 402 - Incentives
 - 407 - Protectionism: Negative
 - 414 - Economic Orthodoxy
 - 505 - Welfare State Limitation
 - 601 - National Way of Life: Positive
 - 603 - Traditional Morality: Positive
 - 605 - Law and Order: Positive
 - 606 - Civic Mindedness: Positive</code></pre>
</div>
</div>
<p>The Manifesto Project constructs a measure, RILE, which is the proportion of right-coded sentences, minus the proportion of left-coded sentences. How do the parties line up when we follow this procedure?</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-lr1" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-lr1-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/manifestos_2024/index_files/figure-html/fig-lr1-1.png" class="img-fluid figure-img" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-lr1-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: Left right positions based on RILE scores for 2024 manifestos
</figcaption>
</figure>
</div>
</div>
</div>
<p>This ordering makes some sense. Reform is to the right of the Conservative party, which in turn is to the right of the Labour Party. The Green Party, together with the Scottish National Party and Plaid Cymru, are to the left of both the Labour Party and the Liberal Democrats. There may, however, be some questions about the relative positioning of Labour and the Liberal Democrats: whilst the party has been very clearly to the left of Labour on some occasions (most notably under Charlie Kennedy’s leadership), the Liberal Democrats are still(!) led by a contributor to the <a href="https://en.wikipedia.org/wiki/The_Orange_Book">Orange Book</a>.</p>
</section>
<section id="how-have-the-parties-changed-since-2019" class="level1">
<h1>How have the parties changed since 2019?</h1>
<p>One natural question is: to what extent have the parties’ positions changed since 2019? Here I rely on <a href="https://doi.org/10.1111/1467-923X.13009">estimates produced by my colleague Nick Allen</a>, together with Judith Bara, with coding by Michelle Springfield. The following plot shows the parties’ 2024 scores on the horizontal axis, against their 2019 scores. The dotted line shows a 1:1 correspondence.</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-lr2" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-lr2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/manifestos_2024/index_files/figure-html/fig-lr2-1.png" class="img-fluid figure-img" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-lr2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;2: Comparison of 2024 and 2019 RILE scores
</figcaption>
</figure>
</div>
</div>
</div>
<p>Five of six plotted points land close to the dotted line, with Labour the big exception. The fact that Labour is in the lower right quadrant means that the party has moved substantially to the right.</p>
<p>This finding is somewhat sensitive to the coding decisions made. Here’s a similar plot, but plotting both the hand-coded 2019 scores and an automated read of the 2019 Labour and Conservative manifestos, using the same process I have used above for 2024.</p>
<div class="cell">
<div class="cell-output-display">
<div id="fig-lr3" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-lr3-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="http://www.chrishanretty.co.uk/posts/manifestos_2024/index_files/figure-html/fig-lr3-1.png" class="img-fluid figure-img" width="672">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-lr3-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;3: Comparison of 2024 and 2019 RILE scores with automated versions
</figcaption>
</figure>
</div>
</div>
</div>
<p>The automated reading of the 2019 manifestos would have Labour roughly <em>as</em> left-wing as the other left-wing parties, rather than being out to their flank, and the Conservatives more left-wing than a manual reading of the 2019 manifesto suggests. An apples-to-apples, LLM-to-LLM comparison would therefore suggest that both parties have moved to the right: the Conservatives a little bit, Labour a lot.</p>
</section>
<section id="conclusions" class="level1">
<h1>Conclusions</h1>
<p>As you might expect from <a href="http://chrishanretty.co.uk/posts/finetuning/">my other work</a>, I believe that large language models can help researchers code large volumes of text quickly and reliably. In writing this blog post, I’ve experienced more unease defending the RILE schema than I have defending the coding decisions made by the large language model. Any systematic process will, when applied to enough data, inevitably generate one or two decisions that seem implausible, but I think that for existing schema with large volumes of training data, LLMs reduce that number to the bare minimum.</p>


</section>

 ]]></description>
  <category>parties</category>
  <category>code</category>
  <category>language</category>
  <guid>http://www.chrishanretty.co.uk/posts/manifestos_2024/</guid>
  <pubDate>Tue, 25 Jun 2024 23:00:00 GMT</pubDate>
  <media:content url="http://www.chrishanretty.co.uk/posts/manifestos_2024/bert.png" medium="image" type="image/png"/>
</item>
</channel>
</rss>
