Democrats finished their party convention in Philadelphia celebrating their monopoly on optimism. Under the headline “Hillary Clinton’s Democratic Party Reclaims Morning in America,” the Daily Beast’s Michael Tomasky wrote: “Donald Trump, and the millions who voted for him, turned the Republican Party into a party of rage about America. They spoke . . . about a country that has stage-four cancer. The Democrats spoke about a country that surely faces problems and challenges, but a country that has to and will choose optimism and hope.”

I examined Clinton’s and Trump’s convention speeches using a technique I’ve applied to almost every major-party nominee’s acceptance address going back to 1900, and I found that Clinton is indeed more optimistic than Trump by most measures. But Democrats may want to temper their optimism about that result.

The axiom that “the more optimistic candidate almost always wins” rests largely on research I published in 1990 with Harold Zullow showing that the more optimistic candidate won 18 out of 22 presidential elections, from the McKinley-Bryan race in 1900 through the Reagan-Mondale contest in 1984. We found that the optimism of their nomination acceptance speeches was an even better predictor than polling or fundraising numbers. And we theorized that optimism prevailed because it inspires hope in voters and motivates candidates to overcome campaign setbacks.

Yet optimism hasn’t been a reliable predictor since the Reagan era. Now that pretty much everyone follows a buoyant script, it doesn’t appear to give anyone much of an edge.

I analyzed Trump’s and Clinton’s convention speeches using a method — content analysis of verbatim explanations, or CAVE — that I helped develop in the ’80s. The idea is that we can measure optimism by looking at how people explain bad and good (from their point of view) events. Optimists tend to see problems as temporary, limited in scope and the result of external factors; pessimists see problems as intractable, pervasive and to some extent their fault. Good stuff goes in the opposite direction: Optimists expect good events to persist into the future, to have widespread benefits and to some extent reflect on them; pessimists expect good events to be short-lived, to have a narrow impact, and to have more to do with other people and circumstances than with themselves.

So, for example, here’s Trump: “Our convention occurs at a moment of crisis for our nation. The attacks on our police, and the terrorism in our cities, threaten our very way of life. Any politician who does not grasp this danger is not fit to lead our country. Americans watching this address tonight have seen the recent images of violence in our streets and the chaos in our communities. Many have witnessed this violence personally; some have even been its victims. I have a message for all of you: The crime and violence that today afflicts our nation will soon — and I mean very soon — come to an end. Beginning on January 20th, 2017, safety will be restored.”

This passage mentions a chain of bad events that will be resolved by a good event. “Attacks on our police” and “terrorism in our cities” are both “threatening our way of life,” which in turn is producing “a moment of crisis.” Trump displays a pessimist’s tendencies in characterizing these problems as serious and pervasive. But he’s optimistic in his suggestion that they are external to him and merely of the moment, with little or no future implications. He’s also optimistic in his claim that “safety will be restored.” He implies that as a result of his presidency, the issue of safety will be addressed fully, once and for all.

Now, let’s look at a passage from Clinton’s speech: “America is once again at a moment of reckoning. Powerful forces are threatening to pull us apart. Bonds of trust and respect are fraying. And just as with our founders, there are no guarantees. It truly is up to us. We have to decide whether we all will work together so we all can rise together. . . . But we are not afraid. We will rise to the challenge just as we always have.”

Here, Clinton is less pessimistic than Trump in characterizing the problems we face. We are not in a full-blown “crisis” but rather at a “moment of reckoning.” Under threat is not “our very way of life” but unity, along with “bonds of trust and respect.” These problems are still pretty important, but they aren’t catastrophic. Like Trump, Clinton is optimistic in explaining these problems as external to herself. But she’s somewhat less optimistic about their resolution. She offers a conditional statement — “we have to decide whether we all will work together so we all can rise together” — and then digresses for a minute or so before concluding, optimistically, that “we will rise to the challenge.”

To measure the optimism of a speech, I highlight every causal statement, separate them into good and bad events, and then rate each event based on whether the candidate explained it as internal or external, stable or temporary, global or specific. I also look at the candidate’s tendency to ruminate — to dwell on problems — by calculating the percentage of sentences referencing a bad event. (For my formal research, I train teams of coders who are blind to which candidate is responsible for each fragment they are rating. For Clinton and Trump, in the interest of timely albeit preliminary data, I coded the speeches myself.)

I found Trump’s speech to be extremely ruminative; 58 percent of his sentences mentioned a bad event. Clinton’s address, by contrast, was relatively upbeat: Only a third of her sentences mentioned problems.

Clinton was much more optimistic than Trump about bad events, and it is hope about bad events that matters most to the electorate in our previous work. The single area in which Trump showed more optimism than Clinton was in explanations of good events.

In the final calculation, taking pessimism about bad events multiplied by rumination, Clinton comes out way ahead as the more optimistic candidate.

Thirty years ago, I had high confidence in the power of optimism to predict election outcomes. Our analysis of acceptance speeches found that the sunnier candidate won 82 percent of the presidential elections from 1900 to 1984, and the numerical difference in optimism powerfully predicted the size of the electoral college majority. This was especially noteworthy in looking at the candidates who started lower in the polls but were strongly optimistic: Harry Truman in 1948, John Kennedy in 1960 and Ronald Reagan in 1980.

The four exceptions were intriguing. Three were the Franklin Roosevelt reelections in which FDR, leading the nation in the Great Depression and then into war, was more pessimistic than his opponent at a time when things were objectively miserable. The fourth was the Humphrey-Nixon election of 1968, in which Hubert Humphrey (the “Happy Warrior”) was more optimistic than Richard Nixon. But Humphrey, who started at a huge polling disadvantage after the Chicago police beat up antiwar demonstrators during his nominating convention, closed to within 0.8 percent of Nixon by the end of the campaign, leading to claims that if the race had lasted another week, Humphrey would have won.

In 1988, we tried a genuine prediction. We identified George H.W. Bush as the most optimistic of the seven declared Republican candidates and Michael Dukakis as the most optimistic of the six Democrats stumping in New Hampshire that January. Bob Dole was ahead of the Republican pack at the time, and Gary Hart was leading the Democrats. But sure enough, Bush and Dukakis went on to claim their respective party nominations.

The surprise came in the general election. Based on their convention speeches, we predicted in August that Dukakis would beat Bush by six or seven percentage points. I was so certain we were right that on a trip to Scotland I ventured into the betting shops of Edinburgh and wagered $17,000 — essentially all my savings — on a Dukakis win. Zullow, my co-author, refused to go in with me on the bet, which turned out to be a wise decision. Bush beat Dukakis by 7.7 points.

My subsequent predictions have been mixed. In 1996, David Fresco and I assessed that Bill Clinton’s convention speech was more optimistic than Bob Dole’s, correctly anticipating that election’s result. In 2000, Fresco, James Hambrick and I measured Al Gore and George W. Bush as nearly tied in their optimism, with Gore having a slight edge — that’s arguably in line with an election so close that it required a recount. But then in 2008, Stephen Schueller and I determined John McCain’s acceptance speech to be more optimistic than Barack Obama’s, even though Obama would go on to win by 7.3 percentage points. (I didn’t assess optimism in 1992, 2004 or 2012.)

In other words, for the last four elections that my psychology lab studied, convention-speech optimism was not a reliable predictor.

I still believe that voters are listening for hope, that we want leaders with a moral compass who will make a better future for us. But authentic optimism has gotten hard to hear.

For nearly three decades now, every presidential candidate has sought the optimist label. Dole proclaimed himself to be “the most optimistic man in America,” while Bill Clinton promoted himself as the man from Hope. Mitt Romney went with the slogan “a better future,” while Obama was the candidate of hope, change and “yes, we can.” John Kerry told us that “there is nothing more pessimistic than saying America can’t do better. We can do better and we will. We’re the optimists.” And George W. Bush announced his candidacy with a lecture on positive psychology: “I’ve learned that people want to follow an optimist. They don’t respond to the message: ‘Follow me, things are going to get worse.’ They respond to someone who appeals to our better angels, not our darker impulses. They respond to someone who sees better times — and I see better times.”

The need for candidates to embrace optimism is repeated in news analyses and op-eds each election cycle — often citing my research as empirical support. Following the correct 1988 primary predictions, I got requests from both major parties for advice on how to write optimistic speeches. (I sent them both the instructions for how to analyze speeches for optimism.) It doesn’t take a psychologist, however, to see the difference between Reagan’s “Morning in America” and Jimmy’s Carter’s “Malaise.” Every politician knows it would be disastrous to emulate Carter.

But when everyone is doing their best to sound like Reagan, it’s hard for any candidate to gain an optimism advantage. And it’s hard for voters, and sometimes researchers, to filter the authentic from the contrived.

Although convention speeches have long been scripted, I once had more faith that they reflected the underlying personality of the speaker. In the campaigns of 1960, 1976, 1980 and 1984, the candidates who were more optimistic at the conventions were also more optimistic in the fall debates, suggesting some consistency of style in both their scripted and spontaneous moments.

Now, with political consultants and savvy voter targeting so central to campaigns, it’s harder to decipher a candidate’s true personality. Indeed, candidates may sound very different in their improvised remarks than in their speeches. Dukakis was far more pessimistic in the debates than he had been at his convention (the great Kennedy speechwriter Ted Sorensen was rumored to have had a hand in his address). Obama, who had trailed McCain in optimism at the conventions, surpassed him in optimism by the end of their third debate.

And then there’s Trump. His convention speech, while very dark, was a departure from what we typically hear from him. It was one of the few times in his campaign he has used a prepared text, and some observers remarked that the style and cadence sounded more like classic Steve Miller, his speechwriter, than like signature Trump. The speech, therefore, may not be an accurate guide of what we’ll get from him this fall.

Clinton has been more consistent. Back in the spring, according to my analysis of the Republican and Democratic debates, Trump was rather more optimistic than the other leading Republicans, and Clinton was much more optimistic than Bernie Sanders. Yet Clinton, in the primary debates, was markedly more optimistic than Trump on basically every measure. She repeated that performance at her convention. And if the same thing happens when she goes head-to-head with Trump in the debates, she will be the clear victor on our psychological measures.

But expressions of hope have the best chance of influencing the votes of people who aren’t already committed — people who don’t vote based on party affiliation or ideology, people who don’t necessarily know much about the candidates and their positions. In this highly partisan environment, with an usually engaged electorate, optimism may have very little sway.

I certainly wouldn’t let it guide any bets on the outcome of this election.