Reuters/Mike Segar/File photo

During the 2016 campaign, China and Mexico were often painted with the same political brush. President-elect Donald Trump described the countries as America’s biggest economic rivals, taking advantage of us, undermining growth and stealing jobs.

The view wasn’t confined to Republicans: Bernie Sanders won followers as he lambasted the government for crafting free trade deals that sent jobs to Mexico and China.

Mexico and China are similar in some ways. They’re both populous countries, with workers who on average make a fraction of what Americans make. They are currently America’s two largest sources of exports.

But if you look more closely at our economic relationships with each country, China and Mexico start to look different. One looks more like a partner, while the other looks like a rival.

Some researchers say Mexico was unfairly maligned in the U.S. election. In fact, if the United States wants to compete with China’s manufacturing powerhouse, they say, Mexico is likely to be one of its most valuable allies.

“The U.S. and Mexico at the most fundamental level are economic partners. We will sink or swim together in the global economy,” says Christopher Wilson, the deputy director of the Mexico Institute at the Wilson Center (no relation).

The U.S. and Mexican economies have become tied together because of policy choices such as the North American Free Trade Agreement, as well as geography, Wilson says. They experience growth and recessions together, and the productivity of their industries is linked because they trade so many materials and inputs used to make other products.

“It’s fundamentally different from the U.S. relationship with any other country than perhaps Canada,” he says.

The reason has to do with the way companies set up global supply chains. In the last few decades, the step-by-step process companies use to manufacture goods has stretched beyond national borders. Today, a car’s engine might be made in one country and the leather for car seats in another. The car might be assembled in a third country, depending on what each location does best.

Sometimes these supply chains snake around the world, but more often they are concentrated in a particular region, involving neighboring countries working together to compete globally on various products, says Wilson.

One of the world’s most formidable regional chains is centered in East Asia, often incorporating high-end products from Japan and Korea, and inexpensive labor from China. Another centers in Europe, where high-tech German manufacturers draw on the inexpensive labor of countries such as Poland or Turkey.

Then there’s the supply chain in North America, in which companies produce beer, planes, electronics, medical devices and other products by combining research, technology, raw materials and labor from Canada, the United States and Mexico.

But the way we measure trade overlooks/obscures the existence of these regional supply chains. When we record imports, we attribute the total value of the product to the last country it was in. But these days, that country is often just the last stop on a product’s long trip from conception to delivery.

Take, for example, the Apple iPhone, a product that is nominally “made in China." In a widely cited study, researchers found that Apple created most of the product’s value through its product design, software development and marketing operations, most of which happen in the United States. Apple ended up keeping about 58 percent of the iPhone 4’s sales price. The gross profits of Korean companies LG and Samsung, which provided the phone’s display and memory chips, captured another 5 percent of the sales price. Less than 2 percent of the sales price went to pay for Chinese labor.

“We estimate that only $10 or less in direct labor wages that go into an iPhone or iPad is paid to China workers. So while each unit sold in the U.S. adds from $229 to $275 to the U.S.-China trade deficit (the estimated factory costs of an iPhone or iPad), the portion retained in China's economy is a tiny fraction of that amount,” the researchers wrote.

The last country a product stops in is often its place of assembly. Because assembly is labor intensive, it is often done in lower-cost countries. So trade statistics end up exaggerating imports from lower-cost countries such as China and Mexico.

In fact, roughly two-thirds of international trade is actually in “intermediate goods” — the bits and pieces that get integrated into a final product, according to economists Robert Johnson and Guillermo Noguera.

These distortions add up. Johnson and Noguera estimated in 2011 that the U.S.-China trade imbalance would fall by about 40 percent if the value of all of the intermediate goods flowing into China were extracted.

In the case of Mexico, the distortion may be even more noteworthy, because many of the inputs Mexico uses in its products are American-made. If the incoming administration were to erect a 35 percent tariff on imports from Mexico, as Trump discussed during the campaign, it would be taxing products that are partly American, economists say.

Just how American are they? The figures are difficult to calculate directly, since they require proprietary information from companies about the inputs they use. But using an economic model, Chad P. Bown, a senior fellow at the Peterson Institute for International Economics in Washington, and his colleagues estimate that about 11 percent of the value of goods manufactured in Mexico come from American-made inputs. With automobiles, the figure is 14 percent. With electrical equipment, it rises to 19 percent.

For China, the numbers are a lot lower — about 2 percent on average, Bown says.

Other estimates are even higher. A 2010 paper by economist Robert Koopman and others found that 40 percent of the value of finished goods imported into the United States from Mexico was so-called “U.S. content,” intermediate products that support American companies and jobs. For Chinese imports, the percentage was only 4 percent.

“Imports from different countries are very different in the way they either do or do not support the U.S. economy,” Wilson says.

The integration between the U.S. and Mexican economies may be one reason that free trade agreements with Mexico appear to have had a much smaller effect on U.S. workers than agreements with China, researchers say.

Economists David Autor, David Dorn and Gordon Hanson estimate that U.S.-China trade growth was responsible for one-quarter of all U.S. manufacturing job losses from 1990-2007. Yet they found almost no negative impact from U.S. imports from Mexico, which also grew significantly during the period.

Not all economists agree. Research by John McLaren of the University of Virginia and Shushanik Hakobyan of Fordham University has shown that blue-collar workers in industries most affected by NAFTA had significantly lower wage growth over the 1990s compared with other workers.

Overall, McLaren says he believes the impact of NAFTA on American wages was small, but that the effects were concentrated in some communities. He’s not surprised that voters were upset about it or considered it to be an injury to their economic well-being.

Still, he says, we should keep NAFTA’s effects in perspective. More than 20 years later, NAFTA likely has much less impact on manufacturing jobs than trade with China, and the effect of both is likely dwarfed by the influence of technological change and automation, he says.

In the years since NAFTA, manufacturers have redesigned their production systems to spread operations throughout the United States, Canada and Mexico. Ultimately, those changes may have made North American manufacturers better able to compete with global rivals.

American auto production provides an example. NAFTA brought about huge changes in the industry, with many companies moving well-paying blue-collar assembly jobs to Mexico.

But the agreement triggered other changes as well. Automakers became more efficient, and were able to add new makes and models that they couldn’t have otherwise, economist Gordon Hanson said in an email. Parts of the supply chain that required more skilled and educated workers ultimately expanded in the United States and Canada. Ultimately, NAFTA both destroyed and created U.S. jobs, Hanson says.

While overall employment in the U.S. motor vehicle and parts sector fell nearly 18 percent since 1994, the value the industry added to the U.S. economy grew 50 percent.

Today, “there’s no longer any such thing as an American car, or a Canadian car, or a Mexican car,” Wilson says. “Every car made on the continent uses parts and materials from at least two out of the three countries.”

U.S. government statistics demonstrate this. Take the Tacoma, a mid-size truck that Toyota is increasingly producing in Mexico. According to statistics from the U.S. Transportation Department, 65 percent of the value of a Tacoma is created in the United States or in Canada. Another 15 percent comes from Japan.

If the United States withdraws from NAFTA or puts tariffs on cars assembled in Mexico, cars made in North America will become more expensive, Bown says. Over time, companies might shift their supply chains to lower those costs. Some jobs could come back to the United States, but they likely wouldn’t stay. To remain competitive, carmakers would likely introduce more automation, or shift their operations to Asia or Europe, economists say.

“Without the availability of nearby Mexican plants to do the final assembly of light vehicles, it is quite possible that the vast U.S. parts producing network for these vehicles would migrate to someplace outside of the continent,” Wilson says.