The massive “Lava Jato” (car wash) corruption scandal cut a wide swath across the Brazilian political landscape, contributing to public outcry against President Dilma Rousseff. Brazil’s Senate voted to suspend Rousseff in May, pending her impeachment trial on alleged budgetary improprieties.

Rousseff’s Workers’ Party is not the only political party in hot water. By one count, 59 percent of members of the Brazilian lower house and 58 percent of senators are either under investigation or have been convicted. It might seem as if the whole Brazilian government is rife with corruption. But new data paint a different picture. Yes, Brazil’s political system encourages corruption, but parts of the government work quite well.

Brazil’s odd electoral system contributes to corruption

Brazil’s hybrid electoral system, which combines majoritarian elections for executive office and open-list proportional elections for the lower house of Congress, generates a high level of party fragmentation. Most presidents arrive in office with their parties controlling less than one-fifth of the lower house, even though many reforms require the support of three-fifths of both houses of Congress.

This problem has been resolved through a system of “coalitional presidentialism” — a combination of presidentialism and a multiparty system. The president must govern with the help of a patchwork of political parties, an arrangement that often reaches 10 or more parties and stretches across the ideological spectrum.

Brazil’s president has a number of tools to hold together the coalition, including strong decree powers, budgetary powers and veto powers. But the system means coalition allies also often expect political goodies such as choice government jobs and, as recent scandals have demonstrated, side payments.

But not all Brazilian public officials are corrupt

In fact, parts of the Brazilian state function quite well. They are “islands of excellence” with relatively little meddling by political parties. And they have a lot of “capacity,” meaning they have a well-paid, independent career civil service with a strong esprit de corps. The Central Bank (BCB), Foreign Ministry (MRE) and Securities Commission (CVM) fit that bill.

On the other hand, many other agencies frequently used to reward coalition partners with goodies like government jobs — Cities (CID), National Department of Infrastructure (DNIT) or Sports (ESP) — lack both capacity and autonomy.

Here’s how we know

Our recent paper in Governance uses data on 326,000 federal civil servants in Brazil to measure the capacity for the 95 most important federal agencies in Brazil. This takes into account the proportion of civil servants in expert careers, career longevity, staff requisitioned from other agencies and average salaries. We also measured autonomy, based on individual civil servants’ recorded party affiliations and their partisan distribution through the bureaucracy. We also measured which of Brazil’s 30-odd political parties dominates individual agencies.

So in the figure below, the Comptroller General’s Office (CGU), a ministerial-level agency charged with fighting corruption (mapped in the upper right quadrant), scores high on both autonomy and capacity, as do legal/law enforcement bodies in general.

All of these things matter for corruption. Based on ten years of media reports about corruption, we found that agencies dominated by a single party were more likely to see corruption. An agency with an average level of partisan dominance (such as the CVM, in the upper right quadrant of the graph) would have 3 fewer reports of corruption compared to an agency more dominated by a single party, such as the Education Ministry (EDU, in the bottom left).

But greater capacity and autonomy reduce corruption. The difference in capacity of the Fundação Joaquim Nabuco, NAB (lower left quadrant), an agency focused on educational research, and the Comptroller General’s Office (CGU, in the upper right quadrant) would be associated with half as many corruption reports. More autonomy from political parties likewise leads to a decline in predicted corruption.

What does this all mean? Understanding the current state of affairs in Brazil means understanding which portions of the government are more likely to function effectively than others, and which are more susceptible to corruption. Our research shows how Brazil might guard against future scandals, in particular by improving or eliminating agencies that include large numbers of political appointees and are therefore most vulnerable to corruption.

Katherine Bersch is a postdoctoral fellow at the Center for Democracy, Development, and the Rule of Law at Stanford University.

 Sérgio Praça is assistant professor at the School of Social Sciences at the Getulio Vargas Foundation in Rio de Janeiro.

 Matthew M. Taylor is associate professor at the School of International Service at American University and adjunct senior fellow for Latin America studies at the Council on Foreign Relations. Follow him on @taylorlatam.