Preparing for a happy retirement is a lifelong process, largely because money is such an important ingredient and for most people it takes 40 years to build a nest egg. But retirement bliss is not just a financial quest. It turns out that having been a great parent and spouse are a big part of the equation too.

This is a relatively new finding emerging from parenthood and happiness research, and it suggests that you need to work on these relationships throughout your life—just like saving—in order to get to the promised land of a happy and secure retirement.

It may also help explain why so many retirees are unhappy. Just 60% say that their retirement is “very satisfying,” according to the Center for Retirement Research at Boston College. Nearly 20% say they are experiencing lower levels of overall well-being than they were before they retired. Insufficient assets alone do not account for such numbers; isolation is a big contributor.

People who are married report higher levels of happiness at all stages of adulthood, on average, and it doesn’t seem to matter if the marriage has produced children. Among married adults, 36% of those with children and 39% of those without are “very happy,” reports Pew Research. Among those not in a marriage, just 23% with children and 22% without say they are very happy. Single parents are more likely than any other group to say they are “not too happy” with their life.

Can it be that kids bring us no joy? Of course not. It’s just that child rearing tends to occur over the most stressful years of our lives. Happiness takes a U shape along our lifeline, other research shows. Younger adults and older adults report the highest levels of joy, probably because they have the least amount of stress-inducing responsibility.

What’s important for those with kids is doing their best to raise them well, Pew found. Those who give themselves high parenting ratings are the most likely to say they are very happy. So while parenthood itself is not a ticket to happiness, being a good parent is—and having been a good parent plays a large role in being happy in retirement.

Other factors including staying busy and engaged come into play, of course. Money may be the biggest determinant. A landmark study in the U.K. closely linked retirement happiness to a stable source of monthly income. “The key factor that comes out of research studies is whether or not retirees have a steady source of lifetime income to supplement Social Security,” says Alicia Munnell, director of the Center for Retirement Research at Boston College. “People with traditional defined benefit pension plans tend to be happier than those with 401(k) plans.”

Other important keys to retirement happiness, according to the Center for Retirement Research:

Purpose People who report high levels of concern for the welfare of others tend to be happier in retirement. Those who have “outward orientation” are much happier than those with an “inward orientation” that leaves them isolated.

Health The number and severity of illnesses in retirement, not surprisingly, predicts happiness. People who suffer from chronic, severe illnesses tend to be less happy.

Keeping traditions regularly celebrating holidays or family milestones can raise a retiree’s happiness—especially if they’ve done a good job with the kids and can celebrate with them.

Dan Kadlec is a journalist who has written about personal finance for TIME and other outlets for 25 years. He is the author of three books, a leading voice in the global financial literacy movement, and strategic adviser to the National Financial Educators Council.

Kadlec's latest is A New Purpose: Redefining Money, Family, Work,Retirement, and Success