By Chris Isidore, CNN Business

America is a money magnet. And one of the more powerful forces driving the US economy has long been investment in American businesses from other countries. But foreign direct investment in the United States has declined significantly over the past two years.

There are several reasons: President Donald Trump's go-it-alone trade policies, economic uncertainty, and the overall slowdown in global growth have stemmed the flow of foreign money into the United States.

The decline can be spotted in several measures of government and private data from the United States and abroad. The sharpest drop in money coming in is from China.

After hitting a high of $440 billion in 2015, overall foreign investment into the US fell sharply each of the next two years, according to the data. While it crept back up to $296 billion in 2018, the most recent government data available, that's still down 38% from its previous high.

That drop in foreign investment is a loss for the US economy.

Research shows that foreign owned companies pay more, spend more on research and development, and produce more exports than comparable US-owned businesses, said Gary Hufbauer, senior fellow at the Peterson Institute for International Economics.

"They shine," said Hufbauer. "They're often here because they want to reach the US market."

Trump has injected uncertainty in longstanding relationships between the United States and some of its most important trading partners. It might seem that tariffs on imports would cause foreign companies to move to the United States. In fact, Hufbauer said, companies are often scared off because those same tariffs would increase the costs of supplies they would need to import to make products.

A slowdown in economic activities overseas and a strong dollar can also act as headwinds for foreign investment.

The result is less foreign investment in the United States, not more.

President Trump has claimed, more than once, that foreign investment is increasing.

"Massive amounts of money from China and other parts of the world is pouring into the United States for reasons of safety, investment, and interest rates!" Trump tweeted last week, as markets were freaking out about an escalation in the trade war with China. "We are in a very strong position. Companies are also coming to the U.S. in big numbers. A beautiful thing to watch!"

To be sure, foreign money is indeed pouring into US debt. In the first quarter of 2019, investment in American bonds, largely US government Treasuries, increased by $144 billion. That's in large part because in times of market uncertainty, investors put money into bonds.

At the same time, purchases of US stocks by foreign investors is down. Data from the departments of Commerce and Treasury show a decline in net purchases of US stocks by foreign investors in 2018 compared to 2017. In the first quarter of this year, foreign investors sold $206 billion more in US stocks than they purchased, thought those were relatively minor drops compared to the trillions they held.

Those portfolio investment numbers don't include foreign direct investment, money spent on US plants and companies.

Foreign direct investment includes money that a foreign company spends to build a plant or open an office in the United States, such as the Foxconn facility under construction in Wisconsin, at an estimated cost of up to $10 billion, and a $1.6 billion auto plant being built in Alabama by Toyota and Mazda. And it can also count expansion of existing facilities, such as a $600 million investment in a BMW plant in South Carolina.

It also includes purchases of US businesses by foreign companies, such as when China's Haier bought the appliance business of General Electric in 2016.

The figures on foreign investment in the United States also don't count purchase of real estate by foreign individuals. There are signs that those real estate purchases are also declining.

The United States data doesn't break out where the foreign money is coming from. But others do.

A regular tracking of overseas investments from China to Europe and the United States done by consultant Baker McKenzie and the Rhodium Group, a research firm, shows that there was only $3.3 billion in investment from China in North America during the first half of this year. That's down 88% from the high point reached in the last six months of 2016.

Rod Hunter, a partner at Baker McKenzie, says the trade tensions between China and the Trump administration is just one factor causing the drop in foreign investment. A change in Chinese government policy also limited the amount of money that Chinese firms had to make investments around the globe.

"It's maybe two-thirds driven by Chinese domestic factors and one-third by US policy," he said. "There is a lot of noise in the trade space. But the Chinese government tightened the spigot of money that was available."

Hunter said there has been a similar drop in money that Chinese firms are investing in Europe during this period, with the amount of investment falling 72% to $9 billion in the first half of this year.