The secret to having a long and fulfilling life may be as simple as getting a puppy, new research suggests.

A new study found that owning a dog and having a happy marriage and plenty of good friends could be the key to longevity.

The 72-year-long Grant study, which examined 268 young, white, healthy male college sophomores living in the U.S. from 1940 to present day, found that these three factors are more important than any benefits inherited from birth like genes, wealth or class when pursuing long life.

The findings show that longevity is significantly more influenced by happiness than social class, suggesting that having a loving family and a wife is much more important that having a trust fund or being born upper class.

Study director George Vaillant of Harvard Medical School told BBC Radio Four's Today Program that fulfilling relationships were the key to happy and long life. He added that only four of the 31 single men in the study were still alive today compared with more than a third of those in good relationships.

"Having a loving family is terribly important, but from 70 to 90 years old you'd be surprised at the people who, despite enormous deprivation, manage to find love later on," he told BBC.

"If you want to be happy, and don't have a six-month-old baby to trade smiles with, get yourself a puppy," he said, adding that the finding on happiness is that "happiness" is the wrong word.

"The right words for happiness are emotional intelligence, relationships, joy, connections and resilience," he said.

The long-term study also found that marriages bring significantly more contentment after the age of 70, and the habits formed before the age of 50 is significantly more important than genetics in determining how people age after the age of 80.

"The credit for growing old with grace and vitality, it seems, goes more to ourselves than to our stellar genetic makeup," Vaillant said.

Vaillant said that the findings of the study gave him "an awful lot of hope," and that it is never too late to find happiness.

"Having a loving family is terribly important, but from 70 to 90 years old you'd be surprised at the people who, despite enormous deprivation, manage to find love later on," he said.

Findings from previous studies also showed that owning a pet dog improves a person's physical and mental wellbeing more than owning a cat.

A study from Queens University in the UK found that dogs prevented people from getting sick and helped people recover more quickly by boosting their owner's immune system. Dog owners were also found to get more exercise and have lower blood pressure and lower cholesterol.