Parents: The late-night feedings, midnight diaper changes and temper-tantruming toddlers might be worth it after all. A new study finds that while having more children makes young couples unhappy, bigger families bring parents joy in midlife and beyond.

Previous research has found that despite the oft-cited joys of parenting, raising kids can be psychologically tough on parents. Having a baby diminishes marital satisfaction, for instance. In response, parents may rationalize their decision to have children by idealizing parenthood.

But as kids grow up, the unhappiness melts away, according to a new study published in the March issue of the journal Population and Development Review. The more children parents over age 40 have, the happier they are, the study found.

"Children may be a long-term investment in happiness," study author Mikko Myrskyla, of the Max Planck Institute for Demographic Research in Germany, said in a statement.

The researchers surveyed over 200,000 women and men in 86 countries, including the United States and China, between 1981 and 2005. Globally, they found, parents under age 30 become less happy with the birth of each child. Parents between the ages of 30 and 39, on the other hand, stay as happy as childless couples as long as they keep their brood to four or fewer. From age 40 on, parents with one to three children are happier than childless couples. After age 50, mothers and fathers are happier than childless couples regardless of how many children they have. The results hold true regardless of sex, income or partnership status, the study found.

The researchers acknowledge that people who chose not to have children may be different in some way from those who chose to have children, differences that could affect their happiness. However, they wrote, analysis of the effects of having an additional child (a method that compared parents to other parents), suggests that it is children, not some other factor, causing the happiness change.

The study explains the long-standing discrepancy between people's belief that children cause happiness and the research findings that consistently show less happiness per child.

"Seeing the age trend of happiness independent of sex, income, partnership status and even fertility rates shows that one has to explain it from the perspective of the stage of parents' life," Myrskla said.

The reasons for the finding are expected, researchers say: As children grow up, they require less care – and cause less stress for moms and dads. Adult children can become a source of support for parents. This is especially true in former Soviet states like Russia, Poland and Hungary, the study found, where elderly people rely less on government welfare and more on their children for financial help.

In countries with well-developed welfare systems, on the other hand, the differences between childless couples and parents are smaller. In western Germany, Switzerland and Austria, the study found, adults are similarly happy whether they have children or not.

You can follow LiveScience Senior Writer Stephanie Pappas on Twitter @sipappas.