Packages to calculate seats allocation from votes?

Hello

Is there any package to calculate how seats are distributed among the different parties given the number of votes in different regions of a country or to perform any kind of calculations or graphics with data collected on elections?

There are different methods and related words: largest remainder method, d’Hondt, Highest Averages Methods of Allocating Seats Proportionally, Hare quota…

1 Like

I believe these are not implemented, but should be pretty easy to implement. Any of the major graphic packages should be able to handle the data and make the appropriate graphics (at least basic functionality, if one would like to use a map / parliament seat arrangement or other more elaborated plots it might require some custom code). If you believe this is a feature you and others might like it would be worth to reach out and release a package. I could help out with the basics.

In fact I’m going to use it just once, but maybe other would use it too.
One of the reasons people choose one platform or other (such as Julia) is because it has interesting packages already implemented.
I guess quite a lot of people do some kind of study on political data and it could be useful for them.

I can’t say I am familiar with political science, but my impression is that voting systems are wildly different between countries, and also change in time. So this is at best borderline between something one would write for an application (research paper, predictive model, etc), and a package for general use.

That said, there is no harm in packaging it up once you write it. Packages are very lightweight in Julia, and writing the unit tests would help with reproducible research.

1 Like

I don’t know of a package, but I will say that I did a blog post on the topic, and it only took 25 lines of code, counting reading data, etc. I used JuMP and Gurobi, so all the hard work of formulating the problem in a machine-understandable way and solving the problem are handled by existing general purpose packages. So if you’re just looking to use this functionality once, that’s a promising approach.

2 Likes