Does the stock market boom under Democratic presidents? Hillary Clinton said so during a town hall in Nashua, N.H., on July 28, 2015.

"You know the evidence is pretty clear that under Democratic presidents, going a ways back, people do better," Clinton said, at around 5:30 in this video. "And not only working people, middle class people. Even the stock market does better when you have a Democratic president in the White House."

We wondered: Is it true that "the stock market does better when you have a Democratic president in the White House"? We took a closer look.

Scrutinizing the stock ticker

There have been a couple studies addressing this question, and they all agree: For whatever reason, going back more than a century, the stock market has done better under Democratic presidents than Republican presidents.

A 2012 report by CMC Markets, an international financial firm, found that since 1900, the United States’ stock markets have posted an average annual return of 15.31 percent under Democratic presidents, compared to just 5.43 percent under Republicans.

Another study from 2012 by Adviser Perspectives newsletter, using somewhat different methodology, found that since 1900, the Dow Jones Industrial Average has gained 8.7 percent annually under a Democratic president, compared to 5.7 percent under Republicans.

And calculations by The Economist found that the Barclays U.S. equity index gained a cumulative 300 percent under Democratic presidents between 1929 and 2011, compared to about zero under Republican presidents.

To bring the data up to date, we checked in with Sam Stovall, the chief investment strategist at S&P Equity Research in New York. He had previously found a big Democratic advantage in stock market gains through 2012.

From 1901 through July 31, 2015, Stovall found, the stock market gained 8.7 percent under Democratic presidents, compared to 5.3 percent under Republican presidents. The same pattern held in Stovall’s data since the end of World War II — in fact, it was even more pronounced. Since 1945, the markets gained 11.2 percent under Democratic presidents and 6.3 percent under Republican presidents.

And it wasn’t just the stock market that chalked up better performance under Democratic presidents, according to a July 2014 paper by Princeton University economists Alan Blinder and Mark Watson. They found a performance gap between the parties that was "startlingly large" over a wide variety of economic metrics.

"The U.S. economy not only grows faster, according to real GDP and other measures, during Democratic versus Republican presidencies, it also produces more jobs, lowers the unemployment rate, generates higher corporate profits and investment, and turns in higher stock market returns," Blinder and Watson wrote. "Indeed, it outperforms under almost all standard macroeconomic metrics."

What does this mean?

So, multiple studies show that Clinton’s claim is numerically correct. But what, if anything, can we conclude from it?

Experts said it’s best not to go overboard in drawing conclusions about White House control and stock market performance. Here are some of the reasons why.

• A lot of this stems from luck and timing. Republicans are cursed by having Herbert Hoover on their presidential roster. The stock-market decline was so quick and deep under Hoover that it continues to hobble the party’s stock-market performance all these decades later. Meanwhile, starting at such a low point was a huge help to his Democratic successor, Franklin D. Roosevelt.

In fact, if you remove Hoover from the GOP column, the average monthly return for Republicans improves significantly, from a 0.38 percent average monthly return to a 0.61 percent monthly return. The Hoover-free GOP number is within striking distance of the Democratic mark of 0.73 percent, said Lawrence J. White, a professor at New York University’s Stern School of Business.

White doesn’t argue that it’s fairest to remove Hoover from the GOP’s calculation. Rather, he said, it’s a reminder that relatively small changes due at least in part to unlucky timing can have big effects on the end result.

• Partisan labels are only somewhat helpful. "What matters is the relationship of policy to the stock market, not partisan labels," said Dan Mitchell, an economist with the libertarian Cato Institute. "Economic policy under Bill Clinton was far more market-oriented than it was under either Bush or Nixon."

• A "good" stock market is harder to define than one might think. For instance, a healthy year-over-year increase in the stock market may sound good, but if it comes with high volatility throughout the year, that can be a lot less pleasant for investors, said Tom Arnold, a professor of finance at the University of Richmond Robins School of Business. Meanwhile, "down markets are buying opportunities and up markets are selling opportunities for the purpose of cashing in on profits, possibly from securities purchased in a down market," Arnold said. " ‘Better’ in one market is usually at the cost of another market."

• Market results don’t align neatly with presidential terms. "The stock market makes an anticipatory assessment of a president and his policies shortly after his election — or even before the election," White said. "So the market's anticipation of what an incoming president will do occurs during the last few months of the incumbent’s presidency."

He noted that this factor was even stronger prior to 1936, when the new president was inaugurated on March 4, leaving four months of stock market anticipation in the previous president’s column.

• A president is only one factor in determining stock market performance. Perhaps most important, experts urge caution in ascribing too much credit to a president for how the stock market performs on his watch. Often — including now, during a period of strong stock-market gains — Congress is held by the opposing party. Meanwhile, the Federal Reserve, which plays a crucial role in the economy by directing the nation’s monetary policy, operates independently once appointments are made by the president and confirmed by Congress. And a host of other factors that a president can’t control, including technological advances and international economic trends, play a role as well.

In their paper, Blinder and Watson focus on two factors as most important in determining economic performance. One is the presence or absence of an energy price shock -- something that, unfortunately for the GOP, hit during the presidencies of Richard Nixon, Gerald Ford and George W. Bush, compared to just once under a Democrat, Jimmy Carter.

The other factor they pointed to is what economists call "total factor productivity," defined as the portion of economic output not explained by the amount of inputs used in production. Think of it as the economy’s special sauce, or its extra bang for the buck. Although it’s unclear why, Democratic presidents have benefited from higher total factor productivity, most clearly during the technology boom under Bill Clinton, which produced significant productivity gains.

Hillary Clinton’s campaign emphasized to PolitiFact that she didn’t say that the president is the only factor that went into stock market results. Still, our experts agreed that while the numbers to back up her claim are clear, the meaning and significance of those numbers should be taken with a grain of salt.

"I wouldn't place much weight on it, one way or the other," White said.

Our ruling

Clinton said that "the stock market does better when you have a Democratic president in the White House." The numbers back her up, but it’s worth noting that luck, timing and several other factors in the broader economy also play a role in determining stock market performance.

The statement is accurate but needs clarification or additional information, so we rate it Mostly True.