PageRenderTime 32ms CodeModel.GetById 4ms RepoModel.GetById 0ms app.codeStats 0ms

/website/mpsee.php

https://github.com/openaustralia/publicwhip-matthew
PHP | 282 lines | 246 code | 28 blank | 8 comment | 24 complexity | d3854defb7b1bb4b9f2fe3065e71973d MD5 | raw file
Possible License(s): AGPL-1.0, BSD-3-Clause
  1. <?php require_once "common.inc";
  2. # $Id: mpsee.php,v 1.19 2005/12/05 01:44:39 frabcus Exp $
  3. # The Public Whip, Copyright (C) 2003 Francis Irving and Julian Todd
  4. # This is free software, and you are welcome to redistribute it under
  5. # certain conditions. However, it comes with ABSOLUTELY NO WARRANTY.
  6. # For details see the file LICENSE.html in the top level of the source.
  7. $title = "MP vote map"; pw_header()
  8. ?>
  9. <p>For your convenience, this is a tool for
  10. interactively navigating the space of MPs clustered by
  11. their voting records. We've taken just the votes of every MP,
  12. done some maths, and plotted a map. The axes are made automatically by
  13. the maths. <a href="#details">Read more about this below</a>.
  14. </p>
  15. <p><span class="ptitle">Usage instructions:</span> Click and drag the
  16. mouse pointer in the image to drag, zoom, or select from the space.
  17. (Click on the radio buttons at the bottom
  18. marked "Drag", "Zoom", or "Select" to determine the mode.)
  19. Zooming happens if you drag the mouse pointer right or left.
  20. The panel on the right shows the list of MPs.
  21. Selected names are highlighted in white in the image. Warning:
  22. when you select from the image with the circle pointer,
  23. you may get more than one MP, and you will have to scroll
  24. through the list to see them all. </p>
  25. <p><span class="ptitle">Not working?</span> If you are able, download <a href="http://www.java.com">Sun's Java
  26. software</a>. On Windows, the old unsupported Microsoft versions of Java will not do.
  27. Alternatively, get a taste with a static
  28. <a href="votemap/mpsee-2005.png">2005 screenshot</a>,
  29. <a href="votemap/mpsee-2001.png">2001 screenshot</a> or
  30. <a href="votemap/mpsee-1997.png">1997 screenshot</a> of the clustered MPs.
  31. </p>
  32. <?php
  33. function applet($year)
  34. {
  35. ?>
  36. <p align=center>
  37. <!--"CONVERTED_APPLET"-->
  38. <!-- HTML CONVERTER -->
  39. <SCRIPT LANGUAGE="JavaScript"><!--
  40. var _info = navigator.userAgent;
  41. var _ns = false;
  42. var _ns6 = false;
  43. var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
  44. //--></SCRIPT>
  45. <COMMENT>
  46. <SCRIPT LANGUAGE="JavaScript1.1"><!--
  47. var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0) || (_info.indexOf("AIX") > 0) || (_info.indexOf("OS/2") > 0) || (_info.indexOf("IRIX") > 0)));
  48. var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0));
  49. //--></SCRIPT>
  50. </COMMENT>
  51. <SCRIPT LANGUAGE="JavaScript"><!--
  52. if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "700" HEIGHT = "400" codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0"><NOEMBED><XMP>');
  53. else if (_ns == true && _ns6 == false) document.writeln('<EMBED \
  54. type="application/x-java-applet;version=1.4" \
  55. CODE = "mpapplet.class" \
  56. ARCHIVE = "mpscatt.jar" \
  57. WIDTH = "700" \
  58. HEIGHT = "400" \
  59. posfile ="mpcoords-<?=$year?>.txt" \
  60. scriptable=false \
  61. pluginspage="http://java.sun.com/products/plugin/index.html#download"><NOEMBED><XMP>');
  62. //--></SCRIPT>
  63. <APPLET CODE = "mpapplet.class" ARCHIVE = "mpscatt.jar" WIDTH = "700" HEIGHT = "400"></XMP>
  64. <PARAM NAME = CODE VALUE = "mpapplet.class" >
  65. <PARAM NAME = ARCHIVE VALUE = "mpscatt.jar" >
  66. <PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">
  67. <PARAM NAME="scriptable" VALUE="false">
  68. <PARAM NAME = "posfile" VALUE="mpcoords-<?=$year?>.txt">
  69. Sun Java 1.4 or above required
  70. </APPLET>
  71. </NOEMBED>
  72. </EMBED>
  73. </OBJECT>
  74. <!--"END_CONVERTED_APPLET"-->
  75. <?php
  76. }
  77. print "<h2>MP vote map 2005 parliament</h2>\n";
  78. applet("2005");
  79. print "<h2>MP vote map 2001 parliament</h2>\n";
  80. applet("2001");
  81. print "<h2>MP vote map 1997 parliament</h2>\n";
  82. applet("1997");
  83. ?>
  84. </p>
  85. <h2><a name="details">What is cluster analysis?</a></h2>
  86. <p>Cluster analysis is a technique used by scientists who have measured
  87. comparable features of a set of similar objects, and need to group them
  88. into categories. The objects can be anything from homonid skulls, to
  89. beetles, to fossilized grass seeds. The features can be forebrow size,
  90. leg length, or spikiness. Usually, there are very many features which
  91. are all compared at once. They are multiplied and reduced down to one
  92. single <em>dissimilarity measure</em>. We invent a formula that
  93. decides, for example, that this skull is 0.97 skull units different to
  94. that skull, according to our measure.
  95. <p>We can use computational techniques to simulate a spring network between
  96. all the different skulls in the collection. If the two skulls are
  97. placed too close together, according to the dissimilarity measure, they
  98. are pushed apart; if they start are too far apart, a force pulls them
  99. together. The computer calculates the positions of the skulls in space
  100. to minimize the strain in the spring network.
  101. <p>If all has gone well, and we have chosen an appropriate dissimilarity
  102. function, the skulls in the collection will group into clusters which
  103. probably correspond to one species. The clusters will be in bigger
  104. clusters, which may or may not correspond to a genus, and so on.
  105. <p>Since the dissimilarity measure is arbitrarily chosen, and
  106. experimentally altered to make better results, it takes further proof to
  107. be sure that the clusters are significant and not a mistake due to the
  108. way you are measuring at it.
  109. <h2>How is this cluster analysis done?</h2>
  110. <p>We've chosen a dissimilarity measure which depends on the number of
  111. votes the same way, and the number of votes against one another, between
  112. two MPs when they both vote in the same division. If every time two MPs
  113. vote in the chamber they always vote the same way, their dissimilarity
  114. measure is zero. If they always vote on opposite sides, when they both
  115. vote, their dissimilarity measure is one. The actual function is:
  116. [Number of votes on opposite sides] / [Number of divisions in which both
  117. voted].
  118. <p>Our cluster analysis calculation was done using Multi-Dimensional
  119. Scaling. The mathematics behind this is available in many textbooks,
  120. and <a href="http://www.ast.cam.ac.uk/~rgm/scratch/statsbook/stmulsca.html">on the web</a>. The
  121. calculation itself, as opposed to the proof that this calculation gives
  122. what you want, is reasonably simple to describe. Although most people
  123. won't understand it, it's important to mention it openly in case they do.
  124. <p>It ought to be a rule that the public does not accept any computational
  125. result unless the computation is itself publicly available. The
  126. analogy between computer algorithms whose output has a bearing on, say,
  127. government policy, and the law, is close. We do not tolerate being
  128. subject to laws that are secret and unpublished, regardless of whether
  129. we understand them; we can hire a lawyer if we don't. The same should
  130. be true with computational results which can sometimes hide a great many
  131. errors and fudge factors that should not be present.
  132. <p>Multidimensional scaling. First step: write the dissimilarity measure
  133. as a symmetric matrix: 650 MPs along the top, 650 MPs down the side.
  134. The dissimilarity measure between MP1 and MP99, say, is the same as the
  135. dissimilarity measure between MP99 and MP1, which is why it is
  136. symmetric. The matrix also has zeros down the diagonal.
  137. <p>Factorize this symmetric matrix into its diagonal form of an orthogonal
  138. matrix, times a diagonal matrix of eigen values, times the transpose of
  139. the orthogonal matrix. This is one of those fundamental matrix
  140. operations discovered by mathematicians hundreds of years ago, and
  141. taught in first year college maths degrees. The first two columns of
  142. the orthogonal matrix, scaled by the square root of the corresponding
  143. eigenvalues, are the coordinates of the points in the map. In practice,
  144. we can choose any number of dimensions, or columns, to make the clusters
  145. in multi-dimensional space, but, in this case, two dimensions give a
  146. good picture.
  147. <h2>What do the axes mean?</h2>
  148. <p>This is the most popular question.
  149. <p>The axes don't mean anything. Here's why:
  150. <p>The diagram is generated to represent the closeness of the voting
  151. patterns. MPs who usually vote the same way are plotted close to one
  152. another, and MPs who usually vote far apart are plotted further
  153. distant. You can reflect this map across a line, or rotate it through
  154. any angle, and the distances between the points will be no different.
  155. The meaningful axes you're looking don't necessarily have to be
  156. horizontal or vertical. We've kept this orientation of the picture
  157. because it fits on the screen nicely.
  158. <p>There can also be distortions in the angles between the clusters. If
  159. the Tory party voting pattern moved close to Labour, for example, the
  160. axis between the Labour cluster and the LibDem cluster would rotate
  161. counter-clockwise to bring the Tories closer to one rather than the other.
  162. <p>I would guess than any meaning you do see in the axes are subjective,
  163. post-hoc observations. Distances are important, not the directions.
  164. You should pay no attention to them.
  165. <p>I am not a believer in those Left-Right/Libertarian-Authoritarian
  166. political diagrams on which I've seen analysts attempt to plot people's
  167. political views. This type of analysis is, I think, more of a tool of
  168. persuasion than of sociological measure. The idea that you can nail
  169. your opinion to some point on a spectrum, and someone else can read out
  170. your personal set of policies from its location, is worse than
  171. professional astrology. Each person's set of preferences will depend on
  172. personal experience, expertise, reasoning, and hearsay. We are all so
  173. different with regards to the input of these factors. It's not probable
  174. they would fit into a philosophically pre-determined spectrum.
  175. <p>Perhaps some sort of survey and cluster analysis will suggest a
  176. different, realistic pattern. But the measurements will be too
  177. confounded by the persuasive nature of policy tables having done their
  178. work already. Such a survey would have to work from behavioural data,
  179. rather than stated opinion polls.
  180. <p>One very good critique of our current electoral system is that it
  181. depends entirely on the self-measurement of human opinion. Human beings
  182. are notorious for holding opinions that are systematically at odds with
  183. even their own reality (eg to ask: "How many units of alcohol do you
  184. think you drink a week?"). Policy spectrums, which this cluster diagram
  185. is emphatically not, are an easy way to influence political opinions by
  186. bundling policies up -- ones which you do like, together with ones you
  187. don't fully understand and probably wouldn't like if you did -- and
  188. getting you to pick from them. In practice, influencing opinions are
  189. far easier for many politicians and vested interests to do, particularly
  190. for ones not immediately in power, than to make changes to reality.
  191. <p>The election game, which puts the public's battered and misdirected
  192. opinion at a higher level of importance than any sociological measure,
  193. is clearly treated as a sport by the professional players.
  194. <h2>Why is Tony Blair and his cabinet so far away from the rest of his party?</h2>
  195. <p>I suspect it's because they mostly show up to votes which tend to be on
  196. contentious issues when many MPs are rebelling. This gives them a
  197. higher than expected dissimilarity measure than if they turned up to
  198. all the non-contentious votes when there was no rebellion. They show up
  199. during these contentious issues in order to encourage their MPs to vote
  200. the way they want; the rebellions could have been larger had they not shown up.
  201. <p>The impression that they are pulling their party away from its centre of
  202. gravity, in the way that the leaders of the other parties are not, is
  203. probably correct.
  204. <h2>What are the green dots?</h2>
  205. <p>We've coloured the MPs who are not in the three big parties green.
  206. These parties don't have enough MPs to form colourful clusters; it's for
  207. aesthetic reasons, rather than anything we have against these smaller
  208. parties, that they are all lumped together. You can, however, click on
  209. the individual members to find out pretty quickly that the Welsh and
  210. Scottish national party members tend to associate with the LibDems,
  211. while the Ulster parties tend to align with the Tories.
  212. <h2>Any future developments?</h2>
  213. <p>We've tried a few experiments, such as subselecting for votes on
  214. particular issues, and calculating the pattern for a three-month sliding
  215. window and animating it through time. Neither produced very
  216. enlightening results, so we've not bothered to publish them.
  217. <p>The pattern per parliament is reasonably stable and consistent. In
  218. fact, it's a much better result than you normally get from cluster
  219. analysis of any kind. I think these diagrams are about as far as it
  220. goes with this, and they are not bad. If you would like the data in a
  221. form you can play with in your own cluster analysis software, then
  222. you download it on our <a href="project/data.php">Raw Data</a> page.
  223. <p><b>2004-02-06</b> Chris Lightfoot did just that, and has generated very
  224. interesting cluster graphics using principal component analyis. This differs
  225. from our distance-metric based clustering, by instead rotating a
  226. multidimensional space so the 2D projection you see has the maximum variance
  227. across it. Full details, pictures and political commentary can be found in Chris's blog
  228. entries <a
  229. href="http://ex-parrot.com/~chris/wwwitter/20040203-which_parliamentary_co-ordinate_are_you.html">
  230. "Which Parliamentary co-ordinate are you?"</a> and
  231. <a href="http://www.ex-parrot.com/~chris/wwwitter/20040211-nontraditional_political_movements.html">"Nontraditional
  232. political movements"</a>. Chris's analysis enables him to work out what
  233. the axes mean, and draw pictures of how MPs move between the last two parliaments. Go have a look.
  234. <p>
  235. <p>More of the same? <a href="minwhirl.php">Try our Ministerial Whirl</a></p>
  236. <?php pw_footer() ?>