Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Programming Problem

From   Guido Tiemann <[email protected]>
To   [email protected]
Subject   st: Programming Problem
Date   Fri, 19 Jul 2002 17:07:30 +0200

Hm, somehow my posting got returned and. Hence, I send it again, hopefully that will not be a double posting.




My topic is not so much a specific or technical question, but a full-scale request for help. I already did a quick and dirty solution working with many dummy variables. Unfortunately, it turned out to be neither elegant nor "quick".

My problem: I would like to program a vote --> seat conversion in electoral systems applying the d'Hondt formula. Hence, in my dataset each observation consists of the absolute number of votes for each party i (v1, v2, v3, ..., vi) and I want to obtain the respective number of seats (m1, m2, m3, ..., mi). The d'Hondt highest averages method, applied in an electoral district returning m seats, works as follows: The absolute vote numbers are divided by a sequence of integers which, in case of d'Hondt, is simply 1,2,3,..., and the m seats are sequentially awarded to the parties with the highest averages.

An Example concerning a six-member district:

div 1 div 2 div 3

V1 41000 (1) 20500 (3) 13667 (6) = 3 seats
V2 29000 (2) 14500 (5) 9667 = 2 seats
V3 17000 (4) 8500 = 1 seat
V4 13000 = no seat

In this example, the first seat is awarded to party 1 (receiving 41000 votes), the second to party 2 (receiving 29000) votes, the third again to party 1 (for 41000/2=20500 votes) and so on.

My quick and dirty solution deals with lots of dummy variables, and is for that reason pretty slow. I suppose some sort of matrix programming would do much better, but I was not able to program it.

Any ideas? Any help would be greatly appreciated!!

Guido Tiemann

* For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index