Admirers and opponents alike agree on at least one thing concerning the late President Ronald Reagan — he was a happy man.

Having written a book on happiness (“Happiness Is a Serious Problem,” HarperCollins) and lectured on the subject on every continent (yes, including Antarctica), I would like to offer six explanations for the late president’s happiness.

First, he was a religious man. By this I mean two things: He had a deep connection to God, and a faith in a specific religion, in his case Christianity. Both are very helpful to most people’s happiness. There are, of course, people who believe in God but not in any religion, and in terms of attaining happiness, belief in God even without religion is far superior to no belief in God. But believing in a religion adds a great deal. It provides a way to express that connection to God, a community with whom to express it, and holy books of wisdom to guide one’s life.

Second, he had a deep American identity. As strongly as he believed in his religion, he believed in his country. He was therefore doubly rooted, as a Christian and as an American. Having roots, a sense of belonging to a group, is another vital aspect of happiness.

Third, his religion and his American identity both gave him purpose, another indispensable element to happiness. His Judeo-Christian values imbued in him a calling to lead people, to fight evil, and to glorify God with his life. His American identity gave him an equally fervent sense of purpose — to preserve and further America as a bright shining light to mankind. He believed in American exceptionalism, that America is called to play a role on the world stage with or without the approval of “world opinion.”

Fourth, thanks to his belief in God, he had an additional source of happiness — belief that life has meaning. Meaning and purpose are not necessarily the same. It is surely possible to be an atheist and have a strong sense of purpose — for example, a physician who does not believe in God can believe his purpose is to save lives. But belief in God and in a religion not only provide purpose, they also provide the belief that life has ultimate meaning.

A secular outlook undermines any belief that life itself has meaning. An undesigned, random, coincidence of molecules — which is what we and the universe are — has no meaning. And it is much harder to be happy when one concludes that life has no ultimate meaning.

Fifth, Ronald Reagan was an optimist. In the chapter on optimism in my book, I note that there are two types of optimism: 1) believing the future is bright; and 2) seeing the bright side of any situation (the proverbial ability to turn lemons into lemonade). Ronald Reagan was an optimist in both meanings of the word.

Sixth, he had a great marriage. Few marriages are as happy as the Reagans’. He and Nancy were best friends, partners in a higher cause, and lovers. As one eulogy put it, all it took for Ronald Reagan to feel lonely was for Nancy to leave the room.

There is a troubling conclusion to be drawn from this description of Ronald Reagan’s happiness: A generation of Americans has been raised with none of these vital attributes of happiness. Instead, Americans are being raised in secular schools and in secular society where God and religion are increasingly marginalized.

Likewise, too few young Americans are raised with a strong American identity. Like religious identity, national identity is either ignored or viewed with contempt.

As a result, many have no greater sense of purpose than getting good grades, getting into a good college, becoming famous and being successful. And thanks to the secular immersion they undergo, they do not believe there is any transcendent meaning to life. That is one reason so many young people are jaded as compared to their religious peers.

As for optimism, young Americans are raised to worry incessantly about their future — for example, that they will die of secondhand smoke, corporate pollution, global warming, AIDS, or some other threat to their health.

Finally, marriage is rarely encouraged. Girls, for example, are told that a career is more important to their happiness than marriage to a good man. So, they are less likely to meet their version of a Ronald Reagan. By the time they realize that a career does little to provide the happiness that a good marriage provides, they are less likely to meet the right man. Meanwhile, seeing that girls are no more interested than they are in marriage, young men are only too happy to get as much sex without commitment as they can.

This nation was deeply influenced by Ronald Reagan’s ideas. We need to be as influenced by his happiness.