Using ‘combomarginsplot’

In preparing graphs for a book I am working on, I have found a Stata package called ‘combomarginsplot’ very valuable. I wanted to share the experience in case it might help other reseachers. The package was written by Nicholas Winter, and I am indebted to him for this terrific tool.
The book is on how parties assign their MPs to legislative committees. The committees are divided into categories, including “high policy” (things like justice, foreign affairs, and defense), “public goods” (such as health and education), and “distributive” (principally agriculture, transport, and construction). The typology is based on one developed some years ago by Pekkanen, Nyblade, and Krauss (2006).
Covariates that we hypothesize are associated with assignment to a given committee category include gender, occupation, seniority, and various other personal and electoral variables.
One of the ways in which ‘combomarginsplot’ has come in handy is in setting covariates for purposes of simulating how various attributes of a politician are associated with increased or decreased probability that a member might be assigned to a given committee category.
Normally it would be fine to use standard ‘margins’ and ‘marginsplot’ for such purposes. For instance, if for a given party–let’s call it “Likud”–we want to know the odds that a candidate of a given gender is assigned to public policy (PG), we would run the logistic regression for this category, and then do the ‘margins’ command. It might look like this:
margins, at(female=(0 1) ) level(90)
  marginsplot, recast(scatter) plotopts(msiz(vsmall) mc(gs4)) ciopts(lw(medthick)) ///
xscale(range(0 1)) xsc(r(-.99 1.7)) ylabel(0(.2)1) ysc(r(0 1)) scheme(s1mono) ///
aspectratio(3) ytitle(“”) title(“Likud: PG”) name(Likud_pg_fem, replace)
A formatting note: Note the use of the “recast” option. The standard ‘marginsplot’ can produce some really dreadfully ugly graphs! The “recast(scatter)” option gives you these clean capped bars. (You can also use “recast(bar)”, but I find it less appealing.) The x-axis option, “xsc(r(-.99 1.7))”, is also useful because without doing something like this, the default has the bars right next to the box borders, and lots of white space in between. Obviously, Stata graph commands can be adjusted to user preference. This is mine; yours might vary.
The command above produces a graph like this:
Nice, right? No, not really. Please never accept a “result” like this! Look at the confidence interval for female MP. It goes above 1.00. But this is a logistic regression–the outcome can be, by definition, 1.00 or 0.00. It can’t be 1.2! Just because Stata says so, doesn’t make it so!
Sometimes setting ‘margins’ scenarios a certain way actually leads to the estimate being generated off a hypothetical case that is really unrealistic, given the data. That is, there may not be many real politicians who meeet the criteria. Then–especially if the overall sample is not very large–you can get utterly impossible “predictions”.
Go look at your data, and see what’s going on. In this case, it turns out that the problem is that a very small percentage of men in this party had what we term “high-policy occupations” (mostly lawyers), but a high percentage of the women did. When we run ‘margins’ without specifying values for any other covariates, we get an estimate at the sample means of the other variables on the right-hand side of the regression. So it is estimating men and women with the same likelihhod of also being of high-policy occupation, even though the male and female subsamples are rather different.
What we need is to estimate the men and women in separate ‘margins’ commands, each being more realistic on other covariates. However, we want the estimates for men and women to appear in the same box in our final graph. It won’t do to run separate ‘marginsplot’ commands and then do ‘graph combine’ because that will make two separate boxes in the space of one. So here is how you can make it look like the first graph, despite being based on two separate calls to ‘margins’:
margins, at(female=1 occu_hi=1) level(90) saving(“File1”, replace)
margins, at(female=0 occu_hi=0) level(90) saving(“File2”, replace)
  combomarginsplot “File2” “File1” , ///
    recast(scatter) plotopts(msiz(vsmall) mc(gs4)) ciopts(lw(medthick)) ///
ylabel(0(.2)1) ysc(r(0 1)) scheme(s1mono) ///
labels(0 1) xscale(r(.5 2.5)) xtitle(“Female MP”) ///
aspectratio(3) ytitle(“”) title(“Likud: PG”) name(Likud_pg_fem, replace)
When we do all the above, we get:
We see more plausible confidence intervals, because we are estimating on realistic politicians. There is essentially no difference in this party between the probabilities of men and women getting PG committees (or, more to the point, between women with high-policy occupations and men without them). We already knew from the first example plot above that there was not a significant difference. It was the confidence intervals that went haywire, due to the unrealistic scenario.
A challenging part of of this was getting the bars in the right place within the box. First, one needs to use the ‘labels’ option in order to have them marked “0” and “1” instead of the names of the saved file (e.g., “File1”, although you can name them just about anything you want). With a little–OK, a lot–of trial and error, it turned out that “xscale(r(.5 2.5))” worked about right.
I have found several other convenient uses for ‘combomarginsplot’ in this and other projects. A perhaps more common use than the one I demonstrated here would be when the plotted curves come from different regressions. You can save the results from each, then combine them into a single plot area. Another, which I have used, is combining multiple outcomes from one regression, such as a multinomial logit.
It is terrific that Stata has such a community of public goods providers to create tools like this!

Zimbabwe, 2018

The Zimbabwe election results were finally announced. Presumably to the surprise of few, the incumbent President Mnangagwa of ZANU-PF has “won” and the party will have a two-thirds majority of the assembly (elected by FPTP and with high malapportionment).

Amazingly, Mnangagwa won just enough to not require a runoff! Yes, I am being cynical.

The official results apparently show ZANU-PF getting more votes for assembly than for presidency. That would be unusual for a major party in a presidential system, but here’s assuming that the gap was even greater than officially reported. Either that, or the assembly election was even more rigged than the presidential.

Also unusual–and for me a strong indicator that things were being cooked–is that the assembly result was released days before the presidential. I do not have actual records on these things, but I believe such a sequence is highly unusual. Usually they either come out together, or the presidential result gets announced first.

Another indicator of fraud is that the reported turnout went down between an earlier announcement and the final one. It is not hard to imagine that sufficient opposition votes were discarded to ensure Mnangagwa had over 50%.

Not much more to say, really. But if you want to have your say, here’s the space.

I highly recommend this post at On Elections:

Zimbabwe: another doubtful and deadly election result

Pakistan, 2018

Pakistan elections were today.

Something to watch is how well new religious parties do. One of them, Tehreek-e-Labbaik Pakistan, has a campaign poster that features a woman candidate, although you will need a little imagination to see her.

One of the party’s male candidates explains, “The party has nominated a few women… because… it is mandatory under the election law.”

I understand (via experts on Twitter) that there could be many by-elections in the weeks to come. One even spoke of a “wave” of them. Some of these will be mandated by a provision that invalidates any constituency result in which at least 10% of women on the voter roll did not participate. Others will be necessary because candidates can run in multiple constituencies and, if they win more than one, they have to step aside in all but one. Still others will be needed because several candidates (at least 8) have died since nomination; it is not clear to the extent the deaths are natural or due to election violence.

The electoral system is mostly FPTP. The total size of the National Assembly is 342, and 272 of them are from single-seat districts via plurality. Others are reserved for women or ethnic minorities; some form of PR is supposedly used for these, but I do not have the details. Perhaps someone will enlighten us in the comments. This election is the first under a newly delimited constituency map.

Early results put Pakistan Tehreek-e-Insaf, led by Imran Khan, in the lead.

Unless I say so explicitly, mention of parties or candidates on this blog is not an endorsement. That is especially so when I have no clue what a party’s poster appearing with my entry even says!

Academic writing styles

I am working on two books this summer/fall. I hope both will be done by the end of December, although that may be over-optimistic. As a result of being engaged in these writing processes, questions of academic writing style have been on my mind.

I owe many debts of gratitude to my mentor and frequent coauthor, Rein Taagepera. But the most recent one was his suggestion that every empirical chapter in our new book (Votes from Seats, 2017) start with a presentation of the key result. Don’t drag the reader through prior literature and a bunch of “hypotheses” (a practice he hates, and I tend to agree) before getting to the point. Start with the point, and then explain how you got there, and only then why others did not get there. But the thing is, this almost never works with a journal article (and maybe doesn’t work with books for most scholars not named Shugart or Taagepera), because reviewers impose a standard format that just makes for plodding reading. And writing.

For probably the best demonstrations of our preferred presentation, if you have access to the book, see Chapter 7, which has an overview of “Duverger’s law” near its end, but starts with the Seat Product formula for effective number of seat-winning parties and a graph showing the payoff. Also Chapter 12, in which the previously proposed concept of “proximity” is discussed at the end of a chapter that opens with some data plots showing our preferred “elapsed time“. Other empirical chapters in the book mostly follow this format as well.

Mexico, 2018

Mexico has its elections for President, Chamber of Deputies, and Senate on 1 July. It has been clear for a while that, barring a big surprise, Andrés Manuel López Obrador (popularly known as AMLO) will win.

AMLO’s support has risen steadily out of what looked like a tight three-way contest some months ago into a strong lead. When voters responding “no preference” are removed, it even looks likely that AMLO could win a clear majority of votes. Mexico elects its presidency via nationwide plurality, and no Mexican president has earned half the votes since 1994 (at a time when most experts still considered the regime authoritarian, albeit increasingly competitive).

Assuming AMLO wins, it will highlight the competitive three-party nature of the system. When the center-right National Action Party (PAN) won the presidency in 2000, it broke decades of continuous control by the Institutional Revolutionary Party (PRI). The PAN won again in 2006, on less than 37% of the votes in a very tight race, with AMLO close behind (and refusing to acknowledge defeat). The PRI returned to the presidency in 2012, and now AMLO will give the left its chance. (AMLO was with the Party of the Democratic Revolution, PRD, but in recent years has set up a new party, MORENA, while the remnant PRD is backing the PAN candidate this time.)

I would be very interested in seeing an analysis of AMLO’s own manifesto (and his party’s, if separate). There is much hand-wringing over his leftist “populism”. However, when he ran in 2006, he staked out a centrist economic platform well to the right of his own party–a clear case of what “presidentialization” does to parties. (See the discussion of the general point, and also the 2006 Mexican campaign, in my book with David Samuels, Presidents, Parties, and Prime Ministers). Is he doing so this time? I can’t claim to have followed closely enough to know.

As for the Chamber of Deputies, if the pattern of recent Mexican elections holds, the party winning the presidency will win fewer votes for its congressional candidates. That could mean MORENA (and pre-election allies) will not have a majority of seats. On the other hand, as noted above, these previous presidents have not themselves won majorities. Moreover, the electoral system is mixed-member (with the voter having a single vote). It is sometimes erroneously categorized as mixed-member proportional (MMP), but it is actually leans much more to the majoritarian category (MMM). Seats won based on nationwide votes for party are added to single-seat districts won (by plurality).

The allocation is not compensatory, but it is also not strictly parallel. There are caps on allowable over-representation (unlike in a “pure” MMM system). The most important cap is that no party can have a final seat percentage that is more than eight percentage points above its vote percentage. Thus if a party wins under 42% of the votes, it is unable to have a majority of seats. If it gets over 42% it is not guaranteed a majority, but a majority becomes likely, due to the non-compensatory nature of the allocation. This cap kept the PRI from retaining its majority in the midterm election of 1997, and I believe it has been hit in several subsequent elections, as well. This is what I will be watching most closely: Will MORENA (and allies) get a Deputies majority?

The Senate is also elected in a mix of regional and nationwide seats. Each state has three senators, elected by closed list, limited-nominations plurality. The largest list gets two seats and the runner up gets one. Then there are 32 seats elected by nationwide proportional representation (allocated in parallel, not compensatory manner).

These provisions, combined with the regionalization of party support in Mexico, make it difficult for a party (or alliance) to win a majority of the Senate’s 128 seats. AMLO is unlikely to have majorities in both houses, but it is worth noting that the federal budget must clear only the Chamber. There is no Senate veto on the spending side of the budget, although both houses must pass all other types of bills. Thus the left will be in a strong, but not unchecked, position to implement its program for the first time in Mexican democratic history.

Turkey, 2018: Unusual alliance behavior

On 24 June, Turkey has concurrent presidential and assembly elections. These will usher in the new constitution, under which Turkey becomes a presidential system. (The current system is premier-presidential, having changed from parliamentary with the adoption of direct presidential elections.)

The election was called earlier than necessary in an attempt by the president, Recep Tayyip Erdogan, to catch the opposition unprepared. However, unexpectedly, several opposition parties have assembled joint lists an alliance (see clarification below) to contest the assembly elections. Polling suggests that they could win a majority.

The coalition behavior of the opposition is unusual in that it features parties running in a pre-election coalition for assembly elections while running separately for a concurrent presidential election. I know of few cases of major parties behaving this way. It makes sense, however, in that Turkey’s 10% nationwide threshold for assembly seats makes for potentially high disproportionality (so much so that I questioned whether it was “democratic” several years before the crackdown that followed the attempted coup). On the other hand, the presidency is elected by two-round majority, meaning first-round divisions do not necessarily prevent a group of parties eventually getting one of their own elected. (See Chile 2005 for another example of such unusual alliance behavior.; also Taiwan 2012.)

The Peoples Democratic Party (HDP), which counts on Kurdish support, is running separately. It cleared the threshold in both elections of 2015 (a, b), and may do so again.


Zeynep Somer-Topcu clarifies, regarding the assembly alliances:

Ballot had each party and then a larger box for the alliance. You could just stamp anywhere within the box for alliance (if no party preference). Threshold applies to alliance but each party’s MPs enter based on their parties’ vote shares once alliance passes threshold.

(via Twitter, presented here with her OK)

I think it is quite unusual for alliances to work this way, allowing vote pooling across separate lists to help drag smaller parties over a threshold.

Early STV voting equipment

Voting technology is one obstacle to wider use of ranked-choice voting. Although groups like OpaVote have had open-source fixes for years, US jurisdictions tend to rely on commercial vendors. A decade ago, many of them resisited developing the technology. Now, of course, voters can “complete the arrow,” as is done in San Francisco, or bubble in a candidate-by-ranking matrix, as was done in Maine last week.

The challenges get thornier with STV elections. Due to the “multi-winner” nature of a race, there sometimes are very many candidates. That can result in confused voters and burdensome vote counts. Only in 1991 did Cambridge (MA) solve these problems by computerizing its electoral system. That could have happened as early as 1936, when many cities still were holding STV elections.

As it turns out, IBM had found a way to mechanize the voting process. George Hallett of the erstwhile Proportional Representation League writes:

Among the most persuasive arguments against P. R., in spite of their essential triviality, have been the objections that it required several days to get the result in a large election and that it required paper ballots and hand counting, both of which in plurality elections without the safeguards of a central count have acquired an evil reputation. In connection with the possible early use of P. R. in New York City, where these objectives would be stronger than ever psychologically, an effective answer to them has now been devised.


IBM’s system used standard, punch-card readers to count STV ballots at a rate of 400 per minute. According to Hallett, “the final result of a P. R. election in New York City can easily be determined by some time in the morning of the day after election.”

Voters would use a series of dials to rank candidates, one through 20. Then, as some will recall, the machine would record a voter’s votes when they pulled the lever to open the curtain. Opening the curtain punched the holes into the punch-card ballot.

Here is the quotation in its context (albeit a bit blurry):

Other features of the system were:

  • Precinct-based error correction. A voter could not give the same ranking to more than one candidate. Nor could a voter skip a ranking.
  • Freedom of choice. A voter could rank as few candidates as they wanted. They also could rank as many as they wanted. Although the machine was built for 20 rankings, there appears to have been accommodation for write-in and additional candidates. Finally, a voter could go back and change their mind about a ranking.
  • Early “cyber-security.” Now we worry about nefarious actors loading malware onto touchscreens. Back in the 1930s, however, the worry was that poll workers might stuff a ballot box or throw out ballots they did not like. IBM’s solution was simple. Poll workers would not have access to individual ballots. Once a voter voted, the ballot fell into a sealed container, only to be opened in the central-count location.

Why the machine did not catch on remains a mystery. IBM appears to have been pitching it to New York City in advance of the November referendum, which put STV into place from 1937 to 1947. Those passing by 41 Park Row could see a demonstration model at the Citizens Union office.

It is a shame that New York (and other cities) did not go with the system. According to Mott (1926), the average invalid-ballot rate in 19 elections to that point was 9.1 percent. My data reveal invalid rates of up to 18 percent (Manhattan and Brooklyn, 1941). Part of this was abstention altogether. Another part was the lack of interest in discerning voter intent, handling skipped rankings with compassion, and so forth. IBM’s machine, however, would have addressed some of those issues, all while educating voters at the same time that they voted.